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.

2
  • Have you tried adding external-packages to your PYTHONPATH? Commented Aug 22, 2012 at 15:24
  • I have not tried that. The files in external-packages are .tar.gz files of source code. Commented Aug 22, 2012 at 17:05

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

So, if I write a requirements.txt file, I should probably remove the install_requires section from setup.py, right?
@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 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.