最近很多小伙伴都在问Pythonsetuptools:如何在install_requires下列出私有存储库?这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展ez_setup.py
最近很多小伙伴都在问Python setuptools:如何在install_requires下列出私有存储库?这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展ez_setup.py(setuptools安装工具easy_install)、install_requires在setup.py中,取决于安装的Python版本、install_requires基于python版本、pip是否可以处理来自setuptools / distribute来源的extras_requires?等相关知识,下面开始了哦!
本文目录一览:- Python setuptools:如何在install_requires下列出私有存储库?
- ez_setup.py(setuptools安装工具easy_install)
- install_requires在setup.py中,取决于安装的Python版本
- install_requires基于python版本
- pip是否可以处理来自setuptools / distribute来源的extras_requires?
Python setuptools:如何在install_requires下列出私有存储库?
我正在setup.py
为依赖私有GitHub存储库的项目创建文件。文件的相关部分如下所示:
from setuptools import setupsetup(name=''my_project'', ..., install_requires=[ ''public_package'', ''other_public_package'', ''private_repo_1'', ''private_repo_2'', ], dependency_links=[ ''https://github.com/my_account/private_repo_1/master/tarball/'', ''https://github.com/my_account/private_repo_2/master/tarball/'', ], ...,)
我使用setuptools
而不是distutils
因为后者不支持此答案的install_requires
和dependency_links
参数。
上述设置文件无法访问私有存储库,并显示404错误-
这是可以预期的,因为GitHub将404返回给未经授权的私有存储库请求。但是,我不知道如何进行setuptools
身份验证。
这是我尝试过的一些方法:
如果使用
git+ssh://
来安装仓库,请使用而不是https://
in 。这会失败,因为setuptools无法识别此协议(“未知的url类型:git + ssh”),尽管分发文档说可以。同上和。dependency_links``pip
git+https``git+http
https://<username>:<password>@github.com/...
-仍然获得了404(此方法不工作,curl
或者wget
在命令行或者-尽管curl -u <username> <repo_url> -O <output_file_name>
不工作。)将setuptools(0.9.7)和virtualenv(1.10)升级到最新版本。也尝试安装分发,尽管此概述说它已合并回setuptools。无论哪种方式,都没有骰子。
目前,我只是setup.py
打印出一条警告,指出必须单独下载私有存储库。这显然不理想。我觉得似乎有些明显的东西我不见了,但是无法想像是什么。:)
答案1
小编典典我试图使它能与pip一起安装,但以上内容对我而言不起作用。从[1]我理解PEP508
应该使用该标准,从[2]我检索了一个确实有效的示例(至少对我而言)。
请注意; 这与pip 20.0.2
上Python 3.7.4
setup( name=''<package>'',... install_requires=[ ''<normal_dependency>'', # Private repository ''<dependency_name> @ git+ssh://git@github.com/<user>/<repo_name>@<branch>'', # Public repository ''<dependency_name> @ git+https://github.com/<user>/<repo_name>@<branch>'', ],)
在以这种方式指定我的软件包后,安装可以正常工作(也可以使用-e
设置,而无需指定--process-dependency-links
)。
参考文献 [1]
https://github.com/pypa/pip/issues/4187
[2]
https://github.com/pypa/pip/issues/5566
ez_setup.py(setuptools安装工具easy_install)
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
安装完成后就可以用easy_install安装python的库了,比如:
easy_install pip
install_requires在setup.py中,取决于安装的Python版本
我的setup.py看起来像这样:
from distutils.core import setup
setup(
[...]
install_requires=['gevent','ssl','configobj','simplejson','mechanize'],[...]
)
在Python 2.6(或更高版本)下,ssl模块的安装由于以下原因而失败:
ValueError: This extension should not be used with Python 2.6 or later (already built in),and has not been tested with Python 2.3.4 or earlier.
有没有一种标准的方法来定义仅针对特定python版本的依赖关系?我当然可以做到,if float(sys.version[:3]) <2.6:
但也许有更好的方法可以做到。
install_requires基于python版本
我有一个在python 2和python 3上均可使用的模块。在Python <3.2中,我想安装特定的软件包作为依赖项。对于Python> = 3.2。
就像是:
install_requires=[ "threadpool >= 1.2.7 if python_version < 3.2.0", ],
如何做到这一点?
答案1
小编典典使用环境标记:
install_requires=[ ''threadpool >= 1.2.7; python_version < "3.2.0"'',]
Setuptools的特定用法在其文档中有详细说明。上面显示的语法需要setuptools v36.2 +
(更改日志)。
pip是否可以处理来自setuptools / distribute来源的extras_requires?
我有带有“ setup.py”和“
extras_requires”行的软件包“ A”,例如:
extras_require = {
'ssh': ['paramiko'],},
还有一个依赖于util的“ B”包:
install_requires = ['A[ssh]']
如果我在引擎盖下python setup.py
install
使用的软件包B上运行setuptools.command.easy_install
,则extras_requires
可以正确解决该问题,并安装了paramiko。
但是,如果我运行pip /path/to/B
或pip
hxxp://.../b-version.tar.gz
,则安装了软件包A,但没有安装paramiko。
因为pip是“从源代码安装”,所以我不确定为什么它不起作用。它应该调用B的setup.py,然后解析并安装B和A的依赖关系。
点子可以吗?
关于Python setuptools:如何在install_requires下列出私有存储库?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于ez_setup.py(setuptools安装工具easy_install)、install_requires在setup.py中,取决于安装的Python版本、install_requires基于python版本、pip是否可以处理来自setuptools / distribute来源的extras_requires?等相关知识的信息别忘了在本站进行查找喔。
本文标签: