I have a python library that has a dependency on importlib. importlib is in the standard library in Python 2.7, but is a third-party package for older pythons. I typically keep my dependencies in a pip-style requirements.txt. Of course, if I put importlib in here, it will fail if installed on 2.7. How can I conditionally install importlib only if it's not available in the standard lib?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|||
|
|
|
I don't think this is possible with pip and a single requirements file. I can think of two options I'd choose from: Multiple requirements filesCreate a base.txt file that contains most of your packages:
And create a requirements file for python 2.6:
and one for 2.7:
Requirements in setup.pyIf your library has a setup.py file, you can check the version of python, or just check if the library already exists, like this:
|
|||||||||||||
|