I'm working on a project where one of the dependencies is actually a .whl
that isn't on pypi (i.e. I had to download the wheel direct from the author and pip
install it directly). In my setup.py
file, is there a way to do something like:
install_requires=[
'library.whl',
'matplotlib==2.2.2',
'numpy==1.14.2',
'opencv-python==3.4.0.12',
'Pillow==5.1.0',
'PyYAML==3.12',
],
Or something along these lines since its not on pypi (and I would just add the library.whl
in the MANIFEST.in
file or something)? If not, is there a recommended way to do this for this type of situation? I'd ideally like to solve this in the setup.py
file so I can install my library easily with a single pip install
As provided in the comment use this answer for more information.
setup(
...
install_requires=[
'repo @ https://github.com/user/archive/master.zip#egg=repo-1.0.0'],
...
)
According to the docs, you need to specify dependency_links
in your setup arguments:
DEPRECATED
One alternative is to use a pip requirement files to install your dependencies. A requirement file specify each library and required version. You can use a URL to point to your wheel.
Example:
http://host/path/to/library.whl
matplotlib==2.2.2
numpy==1.14.2
opencv-python==3.4.0.12
Pillow==5.1.0
PyYAML==3.12
And simply specify ‘library’ to your setup.py
file.
Edit
The best practice is to have an additional PyPi server like DevPi. And change your pip configuration file to add this repository. Of course your library.whl
must be pushed in this private server.
Example of pip.conf
:
[global]
index-url = http://yourserver/group/user/
[install]
trusted-host = yourserver
[download]
trusted-host = yourserver
[list]
format = columns
You may also need to configure your .pypirc
file:
[distutils]
index-servers = pypi
private
[pypi]
repository: http://pypi.python.org/pypi
username:your-username
password:your-password
[private]
repository: http://yourserver
username:your-login
password:your-password
That way you could push your releases on your private server:
python setup.py bdist_wheel upload -r private register -r private
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With