How can I make my Python package depend on a remote wheel, not stored in a PyPI repository?
I'm developing a Python project on Windows for my organisation. I would like to be able to distribute this in a clean and easy way for others to install and use it.
One dependency of my project is the MySQL-python package. A precompiled build of this package is not available in the PyPI repository (AFAIK). Compiling the package on Windows requires Visual Studio, which I can't assume will be available on all target computers.
So far, I've been using the pre-compiled wheel of this package kindly provided by Christoph Gohlke at http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python.
I can manually install this package in my development virtualenv very easily by downloading the package, and running pip install MySQL_python-1.2.5-cp27-none-win_amd64.whl
.
However, I can't figure out how to refer to this package in my project so that it will automatically downloaded and installed by anyone who uses my project.
Based on this document it seems that setuptools' install_requires
keyword is not appropriate:
install_requires is a listing of “Abstract” requirements, i.e just names and version restrictions that don’t determine where the dependencies will be fulfilled from (i.e. from what index or source)
The same document seems to indicate that the requirements.txt
file would be suitable to refer to alternate PyPI indices, as in this answer. This shows that this requirements.txt
:
-i http://dist.repoze.org/zope2/2.10/simple
zopelib
would be equivalent to the following command line pip install zopelib --index-url http://dist.repoze.org/zope2/2.10/simple
. However, Christopher Gohlke's website is not a PyPI repo, so this doesn't work for me. It seems like the --find-links
option would make sense, but when I try
pip install MySQL-python --find-links http://www.lfd.uci.edu/~gohlke/pythonlibs/zpx9vnfu/ --trusted-host www.lfd.uci.edu --no-index
it doesn't work either:
Ignoring indexes: https://pypi.python.org/simple
Collecting MySQL-python
Could not find a version that satisfies the requirement MySQL-python (from versions: )
No matching distribution found for MySQL-python
If it's simply not possible to ask pip to look for a remote package, I've considered downloading the wheel file and checking it into my project's Git repository. This may have licensing concerns if the package is release publicly, but ought to be acceptable for an internal project (right?). However, while this command line works: pip install MySQL-python --find-links .\wheelhouse\ --no-index
, I can't seem to incorporate the --find-links
argument into my requirements.txt
in the same way. This does not work:
--find-links .\wheelhouse
--no-index
MySQL-python==1.2.5
pip install -r requirements.txt
results in:
You are using pip version 7.0.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting MySQL-python==1.2.5 (from -r .\requirements.txt (line 3))
Could not find a version that satisfies the requirement MySQL-python==1.2.5 (from -r .\requirements.txt (line 3)) (from versions: )
No matching distribution found for MySQL-python==1.2.5 (from -r .\requirements.txt (line 3))
I've tried playing with the path the folder where the wheel has been downloaded:
file:///C:\Users\blaffoy\my_project\wheelhouse
and C:\Users\blaffoy\my_project\wheelhouse
don't work either.
Another option that I haven't tried, though I think would work, would be to setup my own devpi server. I'd like to avoid this if possible, because it seems to add an ongoing maintenance task for somebody in my organisation to look after it.
Any suggestions or ideas are welcome. This seems like it should be relatively simple, so I think I might be missing something obvious.
--- edit ---
I forgot to mention that I have tried setuptools' dependency_links
keyword too. I couldn't get this to work either for a remote link to Christopher Gohlke's website or pointing to a local path. I also read somewhere that this is not considered good practise, and may be deprecated.