5

My project depends on lots of packages. Some are listed on pypi, some are not.

I now have a folder named "external-packages" where I keep .tar.gz files of the packages that I need that are not on pypi.

I want to alter setup.py so that when it reads the install_requires section and finds a package that is not yet installed, first, it should look in the "external-packages" folder, and then if that fails, then it should go search on pypi.

Is this possible? How to do this?

Thanks for the help.

1 Answers1

1

It seems you use setuptools/distribute (indicated by install_requires option). You could use dependency_links setting in setup.py but it limits your options to distribute your package. For example, you might use one set of dependencies for development, several sets for testing, yet another set for a debian package, etc.

Both easy_install, pip install provide --find-links, --index options that you could specify at the command-line, in config files. It allows to use the right set of requirements for each specific case without editing setup.py.

You could also use requirements files to specify what versions should be installed and where to get them.

jfs
  • 399,953
  • 195
  • 994
  • 1,670
  • So, if I write a requirements.txt file, I should probably remove the install_requires section from setup.py, right? – W. Matthew Wilson Aug 22 '12 at 20:00
  • @W.MatthewWilson: no/yes. It depends on your use case e.g., if your users should be able `pip install your_package` then [non-vendorized dependencies](http://bitprophet.org/blog/2012/06/07/on-vendorizing/) that are available on pypi could be specified in `install_requires`. To install development environment you could: `pip install -r requirements/dev.txt; pip install --no-deps -e .`. Your CI server could: `pip install -r requirements/test-py2.4.txt`. A rpm-package might use `python setup.py build` without installed `setuptools` and ignore both `install_requires` and `requirements` files. – jfs Aug 22 '12 at 20:45