3

I have a virtualenv that serves a few separate projects. I'd like to write a utility library that each of these projects can use. It seems to make sense to stick that in the virtualenv. By all means shoot me down now but please give an alternative if you do.

Assuming I'm not completely crazy though, Where's the best place to stick my library?

My virtualenv sticks everything I install with pip in lib/pyton2.7/site-packages. I wonder if it would make more sense to follow suit or to hack in a separate home (further up the directory tree) so if things do ever clash, my work isn't overwritten by pip (et al).

Oli
  • 235,628
  • 64
  • 220
  • 299

1 Answers1

2

If your project follows the standard packaging practices with setuptools, then all you have to do is run python setup.py develop inside the virtualenvs that you want the library to be used for. A .egg-link file will be created pointing to your package from which your other libraries will use much like any other packages, with the added benefit that your latest changes will be available to all packages at the same time (if that's your intention). If not, then either you could call python setup.py install or use multiple versions at different locations on the file system.

To get yourself started, take a look at Getting Started With setuptools and setup.py (you can skip the part on registering your package on pypi if this is your private work).

Another relevant stackoverflow thread: setup.py examples? The Hitchhiker's Guide to Packaging can also be quite useful.

Community
  • 1
  • 1
metatoaster
  • 17,419
  • 5
  • 55
  • 66
  • It's just a few utilities... I haven't followed *any* packaging practices (standard or otherwise)! Might be time to start though because this sounds like a good way of keeping my source out of the `virtualenv` directory-mess while being able to use it everywhere. – Oli Jul 01 '14 at 11:06