在setup.py中添加自定义滚轮文件作为依赖项? [英] Add a custom wheel file as a dependency in setup.py?

查看:75
本文介绍了在setup.py中添加自定义滚轮文件作为依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,其中一个依赖项实际上是一个不在pypi上的.whl(即,我必须直接从作者那里下载该转轮,然后直接pip进行安装).在我的setup.py文件中,有没有办法做类似的事情:

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',
],

或者由于它们不在pypi上而遵循这些原则(我会在MANIFEST.in文件中添加library.whl或其他内容)?如果没有,是否有针对这种情况的推荐方法?理想情况下,我想在setup.py文件中解决此问题,以便可以使用单个pip install

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

推荐答案

一种替代方法是使用要求文件指定每个库和所需的版本.您可以使用URL指向您的方向盘.

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.

示例:

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

只需在您的setup.py文件中指定库".

And simply specify ‘library’ to your setup.py file.

修改

最佳做法是拥有一个额外的PyPi服务器,例如 DevPi .并更改您的pip 配置文件以添加此存储库.当然,必须将library.whl推送到此专用服务器中.

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.

pip.conf的示例:

[global]
index-url = http://yourserver/group/user/

[install]
trusted-host = yourserver

[download]
trusted-host = yourserver

[list]
format = columns

您可能还需要配置.pypirc文件:

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

这篇关于在setup.py中添加自定义滚轮文件作为依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆