安装具有setup_requires的软件包,该软件包来自本地源发行版 [英] Install package which has setup_requires from local source distributions

查看:133
本文介绍了安装具有setup_requires的软件包,该软件包来自本地源发行版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用以下包含setup_requires的琐碎程序包:

Take the following trivial package which contains setup_requires:

from setuptools import setup
setup(name='my_package', setup_requires=['cython'])

假设我已经完成了以下操作,将其构建到源代码发行版中:

Assuming I have done the following to build it to a source distribution:

$ python setup.py sdist

并下载了Cython的源代码发行版

And downloaded the source distribution for Cython

$ pip install --download ./dist/ --no-use-wheel Cython

现在我有:

$ ls dist/
my_package-0.0.0.tar.gz
Cython-0.21.1.tar.gz

我想做的是使用--find-links等的组合将软件包安装在网络隔离的计算机上.

What I'd like to be able to do is install the package on a network-isolated machine using some combination of --find-links, etc.

我想我可以做些类似的事情

I'd imagine I could do something like

pip install --no-index --find-links="file:///$(pwd)/dists" dist/my_package-0.0.0.tar.gz

但是我收到如下错误:

No local packages or download links found for cython(此处为全文: http://paste.pound-python.org /show/IxmzEEfQ5yZRU45i2FBM/)

我尝试失败的地方:

设置以下内容

[easy_install]
allow_hosts = ''
find_links = file:///$(pwd)/emr-sdists

在:

/usr/lib/python2.6/distutils/distutils.cfg
~/.pydistutils.cfg
./setup.cfg

我目前正在使用docker的--net none设置来帮助调试此问题,如果它可以使您更轻松地进行复制.

I'm currently using the --net none setting of docker to help debug this if it makes it easier for you to get to a reproduction.

推荐答案

问题(除了您的--find-links被键入为dists而不是dist之外)是pip安装软件包的第一件事是运行python setup.py egg_info,而无需传递任何包查找信息. Pip实际上并不会想要 setuptools来安装任何依赖项!它希望setuptools将依赖项吐出为egg_info,以便pip可以读取它们并自己获取.

The problem (besides that your --find-links is typoed as dists instead of dist) is that the first thing pip does to install a package is run python setup.py egg_info, without bothering to pass along any of the package-finding information. Pip doesn't actually want setuptools to install any dependencies! It wants setuptools to spit out the dependencies as egg_info so pip can read them and go fetch them itself.

但是在setup.py any 调用中,总是 安装setup_requires中的依赖项.我什至可以说setup_requires与pip完全不兼容.

But dependencies in setup_requires are always installed on any invocation of setup.py. I'd go so far as to say that setup_requires is completely incompatible with pip.

替代方法是...仅将构建代码放入build步骤中.在安装了所有依赖项之前,Pip不会尝试构建您的程序包.

The alternative is... to just put your build code in the build step. Pip won't try to build your package until all of its dependencies are installed anyway.

这篇关于安装具有setup_requires的软件包,该软件包来自本地源发行版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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