[quote=“Kronuz”]
Regarding the eggs, how would that work? I don’t work much with eggs or .pth files …please if anyone knows exactly how they should be supported, explain and I’ll try to add support for it [/quote]
Let me try to show you with a buildout.
First, download the file at gist.github.com/1140588 and save it in a new directory as buildout.cfg.
Then go into this directory and run:
$ python bootstrap.py
$ bin/buildout
At this point, you’ll have an ‘eggs’ directory with some files in it and a ‘bin/mkrelease’. This will look a bit like this:
#!/usr/local/bin/python2.6
import sys
sys.path[0:0] =
'/Users/optilude/tmp/testbuild/eggs/jarn.mkrelease-3.1-py2.6.egg',
'/Users/optilude/tmp/testbuild/eggs/lazy-1.0-py2.6.egg',
'/Users/optilude/tmp/testbuild/eggs/setuptools_git-0.4.2-py2.6.egg',
'/Users/optilude/tmp/testbuild/eggs/setuptools_hg-0.2.1-py2.6.egg',
'/Users/optilude/tmp/testbuild/eggs/distribute-0.6.19-py2.6.egg',
]
import jarn.mkrelease.mkrelease
if __name__ == '__main__':
jarn.mkrelease.mkrelease.main()
This is a wrapper script that mangles sys.path with the “working set” of eggs, inserting those eggs directly on sys.path, before executing the main function. If you look at the items it adds to the path, they are directories with Python packages and modules and an EGG-INFO directory with egg metadata.
Note that in some cases (e.g. eggs/jarn.mkrelease-3.1-py2.6.egg/jarn/init.py) these will use setuptools/distribute namespace packages (with some boilerplate in init.py). Assuming setuptools is on sys.path, it should deal with these as sys.path is searched when modules are imported.
…
Another approach to get some test eggs would be to use virtualenv. For example:
$ virtualenv eggtest
$ cd eggtest
$ bin/easy_install jarn.mkrelease
At this point, we have in lib/python2.6/site-packages an easy-install.pth that looks like this:
import sys; sys.__plen = len(sys.path)
./distribute-0.6.10-py2.6.egg
./pip-0.7.2-py2.6.egg
./jarn.mkrelease-3.1-py2.6.egg
./lazy-1.0-py2.6.egg
./setuptools_git-0.4.2-py2.6.egg
./setuptools_hg-0.2.1-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
These .egg files are the same as the ones found in the eggs/ directory in the buildout. In this case, we rely on the scanning of .pth files in site-packages to tell Python to add the *.egg directories to sys.path, but the end result is the same.
…
Now, I tried to use a .codeintel/config like this:
{
"Python": {
"python": "/usr/local/bin/python2.6",
"pythonExtraPaths":
"/Users/optilude/tmp/testbuild/eggs/jarn.mkrelease-3.1-py2.6.egg",
"/Users/optilude/tmp/testbuild/eggs/lazy-1.0-py2.6.egg",
"/Users/optilude/tmp/testbuild/eggs/setuptools_git-0.4.2-py2.6.egg",
"/Users/optilude/tmp/testbuild/eggs/setuptools_hg-0.2.1-py2.6.egg",
"/Users/optilude/tmp/testbuild/eggs/distribute-0.6.19-py2.6.egg"
]
}
}
Unfortunately, this didn’t work (e.g. I couldn’t get import completion from the jarn namespace except when actually in a module inside jarn.mkrelease).
Ultimately, what I’d like to do is to write a buildout recipe that spits out such a file when buildout is run. However, the above doesn’t work. I saw some explicit code referencing .egg files and skipping them, but even commenting this out, it didn’t work. I tried to understand how the path loading works in the codeintel package, but I failed.
Martin