JacquesLucke / code_autocomplete

Auto Completion and more in Blenders text editor.
137 stars 32 forks source link

Possible conflict with new version of Jedi, or unclear documentation #9

Open Jellybit opened 8 years ago

Jellybit commented 8 years ago

The documentation isn't quite clear on what code_autocomplete expects regarding Jedi. This is what it says:

When there is a error message Jedi library not found you have to use another .zip file in the beginning. Direct download from the github page is not supported, because the Jedi library is a submodule which isn’t included in these downloads. You can either use an official release or use git to download the repository and its submodules.

The documentation mentioned that the jedi module is not included in the github download. I tried adding the jedi module to the download, copying the contents of the "jedi" subfolder into code_autocomplete's own "jedi" subfolder, but it gives this error and refuses to run:

Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender\2.76\scripts\modules\addon_utils.py", line 324, in enable mod = __import__(module_name) File "C:\Users\HiddenUsername\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\code_autocomplete-master\__init__.py", line 45, in <module> modules = developer_utils.setup_addon_modules(__path__, __name__, "bpy" in locals()) File "C:\Users\HiddenUsername\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\code_autocomplete-master\developer_utils.py", line 39, in setup_addon_modules modules = import_submodules(names) File "C:\Users\HiddenUsername\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\code_autocomplete-master\developer_utils.py", line 30, in import_submodules modules.append(importlib.import_module("." + name, package_name)) File "C:\Program Files\Blender Foundation\Blender\2.76\python\lib\importlib\__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\HiddenUsername\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\code_autocomplete-master\jedi\__init__.py", line 41, in <module> from jedi.api import Script, Interpreter, NotFoundError, set_debug_function ImportError: No module named 'jedi'

I looked into my roaming appdata and it seems to be fine. Code_autocomplete's jedi folder has the contents of the jedi library (api, library, parser, init.py, etc...). If the problem is that I need to include the other root files/folders in the jedi git repository, I still get errors if I include those too. If I remove the jedi library, it installs fine but complains about the missing library.

Perhaps the documentation needs to be updated with what code_autocomplete expects from the user regarding how to include the jedi library? I would be happy to help write that. I just need to know the correct approach first. The other possibility is that jedi is no longer compatible with code_autocomplete or Blender, in which case the documentation should probably specify a working version.

mikebelanger commented 8 years ago

I stumbled onto the same issue. I tried reproducing the problem (on OS X, mind you):

  1. downloaded the autocomplete jedi that this Addon links to here: https://github.com/davidhalter/jedi/tree/7651157487511aadc118f7a8753adf709fad1708
  2. Moved the 'jedi' subfolder into the modules subfolder in my Blender.app package (I'm using Blender2.77a for Mac OS X): ../blender-2.77a-OSX_10.6-x86_64/blender.app/Contents/Resources/2.77/scripts/modules/jedi
  3. Restarted Blender.

While it now runs without complaining about not finding the module, I'm unsure if its actually working. The autocomplete sometimes flakes out, gives wrong suggestions. Not sure if that's Jedi, or its simply not working yet.

JacquesLucke commented 8 years ago

ok, not sure how it is on OS X but looks like you copied the jedi module into the wrong directory (maybe it works the way you did it as well but I'm not sure. Can you show me a screenshot what wrong suggestions jedi made? (and what happens when you turn jedi of?)

Normally you have to copy the jedi package into the code_autocomplete folder in the addons diretory..

mikebelanger commented 8 years ago

I'm beginning to think Blender's OS X package installs things a bit differently. The 'jedi' folder was already in a "global" user preferences directory (that is, outside the Blender.app package, which is more or less a bundled directory). This is usually under ~/Library/Application Support/Blender/2.xx/scripts/addon-name/. However, this jedi folder was empty!

So I replaced the empty directory with the full jedi folder. But then the Addon couldn't find the 'jedi' module when I tried enabling it in the User Preferences.

After that, I tried moving the 'jedi' directory to here: ../blender.app/Contents/Resources/2.77/scripts/addons/modules/jedi

Now the addon can find the jedi plugin, and appears to work. As far as it flaking out, I'm beginning to think I just don't understand the Blender Python API enough to judge it :P I'm going to try testing it in this existing configuration. Thanks Jacques!

mikebelanger commented 8 years ago

Ok I'm not sure the Addon is working to the full extent yet. Its autosuggesting top-level modules correctly, but it stumbles onto a few deeper ones. screen shot 2016-04-28 at 10 23 36 am

So I assumed I had to rebuild the fake bpy module (maybe some of the deeper ones are C-base? Not sure). When I clicked on that button, it returned this message:

` Traceback (most recent call last): File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 28, in execute regenerate_fake_bpy() File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 36, in regenerate_fake_bpy generate_fake_bpy() File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 46, in generate_fake_bpy create_private_subdirectory() File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 64, in create_private_subdirectory generate_code_files() File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 77, in generate_code_files write_code_file(name, code) File "/Users/mikebelanger/Library/Application Support/Blender/2.77/scripts/addons/code_autocomplete-master/autocompletion/suggestions/generate_fake_bpy.py", line 252, in write_code_file file.write(code) UnicodeEncodeError: 'ascii' codec can't encode character '\xb1' in position 27693: ordinal not in range(128)

location: :-1 `

I'm not sure if this is a separate issue, or is just a side-effect of me not installing something right.

JacquesLucke commented 8 years ago

This seams like a separate issue and I don't know why it happens :/ unfortunally I can't test this on OS X..

Maybe you copied the jedi package in the wrong folder, here is how it looks on my pc:

jedi installation

So you have to copy the complete jedi package into a folder called 'jedi' that is inside the Code Autocomplete main directory.

JacquesLucke commented 8 years ago

Oh and yes. The addon creates this fake module because most of blenders python api is implemented in C -> not accesable by jedi.