Tuesday, July 19, 2011

Django Playdoh Package Locations

I was confused when reading how to add packages and seeing that packages live in different locations.

jsocol clarified:

/packages is old-and-busted, use lib/python for non-git things
but you can't put any libraries with compiled components into the vendor lib (it means vendor can't contain anything with c/c++ components)
it's just a question of installing via git (or, well, pip install vcs+vcs://) or using PyPI and the name (e.g. "pip install foo")


pip install foo gives vendor-local/lib/python/foo

using git to install foo gives vendor-local/src/foo



This is what I did, with help from groovecoder. :D

playdoh (master)$ pip install --no-install --build=vendor-local/packages --src=vendor-local/src -I cef
Downloading/unpacking cef
  Downloading cef-0.2.tar.gz
  Running setup.py egg_info for package cef
    
Successfully downloaded cef

And then I found that cef is inside vendor-local/packages. :D

Now I need to add this path to vendor.pth. Groovecoder told me that "*.pth files are automatically included by the python interpreter"

playdoh/vendor-local (master)$ cat vendor.pth 
packages/cef

Now I can use cef!
playdoh (master)$ python manage.py shell
...
>>> from cef import log_cef
>>>

I could also have done
/playdoh (master)$ pip install -I --install-option="--home=`pwd`/vendor-local" cef
Downloading/unpacking cef
  Downloading cef-0.2.tar.gz
  Running setup.py egg_info for package cef
    
Installing collected packages: cef
  Running setup.py install for cef
    
Successfully installed cef
Cleaning up...
and have
playdoh/vendor-local/lib/python (master)$ ls
cef-0.2-py2.7.egg-info cef.py                 cef.pyc

No comments:

Post a Comment