Reputation: 7134
I have a Python project which contains three components: main executable scripts, modules which those scripts rely on, and data (sqlite3 databases, flat files, etc.) which those scripts manipulate. The top level has an __init__.py
file so that other programs can also borrow from the modules if needed.
The question is, is it more "Pythonic" or "correct" to move my project into the default site-packages directory, or to modify PYTHONPATH to include one directory above my project (so that the project can be imported from)? On the one hand, what I've described is not strictly a "package", but a "project" with data that can be treated as a package. So I'm leaning in the direction of modifying PYTHONPATH (after all, PYTHONPATH must exist for a reason, right?)
Upvotes: 2
Views: 941
Reputation: 44142
Definitely do not add your project to site-packages this is going to spoil your system Python installation and will fire back at the moment some other app would come there or you would need to install something.
There are at last two popular options for installing python apps in isolated manner
See virtualenv project. It allows
activate
, you can run pip install
etc. and it will affect only given virtualenv install.activate
)zc.buildout
This package provides command buildout
. With this, you can use special configuration file and this allows creation of local python environment with all packages and scripts.
virtualenv
seems more popular today and I find it much easier to learn and usezc.buildout
might be also working for you, but be prepared for a bit longer learning timevirtualenv
already providesUpvotes: 3