Reputation: 3016
For Python 3.x:
I'd like advice on best directory in which to locate modules that I want to use across multiple projects (and any related factors). I know about the import statement and PYTHONPATH, and various ways to make any location "work", but I want to be in line with standard practice.
So:
Should I be putting my modules in a package in "Pythonxx\Lib\site-packages"?
Does the site-packages directory get special treatment, or is it no different than other possible locations for modules? I'm confused as to whether it has special ".pth" and/or __init__.py
behavior.
To what extent are conventions influenced by what distutils does, which doesn't seem to be really ready for Python 3... and does that mean that I should be attending to some other conventions going forward?
What should I make of this: http://docs.python.org/py3k/install/index.html in which "How installation works" seems to claim (in the table) that 'site-packages' is not relevant to Windows, though I see an empty site-packages directory in my Windows Python 3.1 installation.
-- Thanks!
Upvotes: 1
Views: 2014
Reputation: 3016
Coincidentally, it's the anniversary of my asking this question. Though the respondents attempted to be helpful, I ended up investigating this issue in substantially more depth. That led to notes which I posted here: Python- Organization for common modules. Also some issue reports at python.org (same user name), and some revisions to their documentation. I hope that helps others who are similarly stumped.
Upvotes: 1
Reputation: 85252
Per-user site-packages directory is another option. You can try it with:
python setup.py install --user
Installing to %APPDATA%\Python\Python32
is much more lightweight than creating a whole new virtualenv. This is what PyPM does by default.
Upvotes: 0
Reputation: 82924
Yes -- but let your setup.py do it
No
Why do you think there is a problem?
The docs need fixing. The default Python install directory is C:\PythonXY, not C:\Python. The default package install directory is C:\PythonXY\Lib\site-packages.
Upvotes: 2
Reputation: 4212
You might wish to consider setting up a virtualenv, which is the standard way of bundling a set of modules for use across projects and platforms.
Upvotes: 1