mad*_*ote 2 python dependencies setuptools setup.py
根据我的研究,以下应该有效:
from setuptools import setup
from setuptools import find_packages
...
REQUIRES_INSTALL = [
'spacy==2.3.2',
'tensorflow==1.14.0',
'Keras==2.2.4',
'keras-contrib@git+https://github.com/keras-team/keras-contrib.git#egg=keras-contrib',
'en-core-web-sm@https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.0/en_core_web_sm-2.3.0.tar.gz#egg=en-core-web-sm'
]
...
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
install_requires=REQUIRES_INSTALL,
...
)
Run Code Online (Sandbox Code Playgroud)
当建造轮子或鸡蛋时,一切都很好:python setup.py bdist_wheel。
但是当尝试使用pip install -U dist/mypack-....whl.
我得到:
ERROR: Could not find a version that satisfies the requirement keras-contrib (from mypack==0.3.5) (from versions: none)
ERROR: No matching distribution found for keras-contrib (from mypack==0.3.5)
...
ERROR: Could not find a version that satisfies the requirement en-core-web-sm (from mypack==0.3.5) (from versions: none)
ERROR: No matching distribution found for en-core-web-sm (from mypack==0.3.5)
Run Code Online (Sandbox Code Playgroud)
我尝试过同样的方法setup.cfg,但仍然没有运气。
requirments.txt作为参考 - 所有这些依赖项在首先从轮子安装然后安装轮子时都起作用。
spacy==2.3.2
tensorflow==1.14.0
Keras==2.2.4
keras-contrib@git+https://github.com/keras-team/keras-contrib.git#egg=keras-contrib
en-core-web-sm@https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.0/en_core_web_sm-2.3.0.tar.gz#egg=en-core-web-sm
Run Code Online (Sandbox Code Playgroud)
ERROR: Could not find a version that satisfies the requirement keras-contrib (from mypack==0.3.5) (from versions: none)
ERROR: No matching distribution found for keras-contrib (from mypack==0.3.5)
...
ERROR: Could not find a version that satisfies the requirement en-core-web-sm (from mypack==0.3.5) (from versions: none)
ERROR: No matching distribution found for en-core-web-sm (from mypack==0.3.5)
Run Code Online (Sandbox Code Playgroud)
但这不是干净的方式,因为轮子应该是独立的。
谢谢您的任何提示!
环境
不久前,可以定义一个requirements.txt或类似的包,其中包含 PyPI 包的规范以及存储库和档案的链接。
这需要解析requirements.txt并将它们分成“需求”和“依赖项”,其中“需求”将包含 PyPI 包和“依赖项”\xe2\x80\x94 链接的定义。
对于这些, Setuptools 有不同的参数setup():install_requires和dependency_links。
它确实有效:人们能够定义 arequirements.txt并安装一个包 aspython setup.py install和 as pip install .。此外,可以通过pip install -r requirements.txt. 所有方法都有效,并且允许在一个地方定义所有需求,包括非 PyPI 链接。
然而,自 v19 以来,对dependency_linksarg 的支持已被取消pip。这是奇怪的部分:它没有被 掉落setuptools。但还有更多。
截至今日,pip:
install_requires.install_requires对于包 ( ) 和独立或类似定义中的依赖关系,更喜欢使用 PEP 508 表示法requirements.txt。install_requires.您的依赖项定义混合了 2 种符号:前缀keras-contrib@来自 PEP 508,#egg=部分来自setuptools链接符号。
这不是问题:pip将忽略“eggs”,因为名称之前已定义@。
我相信通过以下方式安装软件包pip效果很好,即:
pip install .\nRun Code Online (Sandbox Code Playgroud)\n但是,如果通过安装包就会出现问题setuptools,即:
python setup.py install\nRun Code Online (Sandbox Code Playgroud)\nsetuptools不理解 PEP 508 符号并忽略install_requires. 截至今天,要建立setuptools以下链接,必须同时install_requires使用 和dependency_links,例如:
setup(\n ...\n install_requires=[\n ...\n "keras_contrib==2.0.8",\n ...\n ],\n dependency_links=[\n "https://github.com/keras-team/keras-contrib/tarball/master#egg=keras_contrib-2.0.8",\n ...\n ],\n)\nRun Code Online (Sandbox Code Playgroud)\n这里有几个棘手的点:
\ninstall_requires链接。dependency_linksgit+https://.../....git,但它是一个存档链接:https://.../tarball/...。snake_case,不是在dash-case。虽然可以使用dash-case,但这不允许指定版本。install_requires通过 分隔==,在dependency_links\xe2\x80\x94 中通过 分隔-。糟糕的是:修复链接将会setuptools中断pip,因为 PEP 508 不允许指定版本。保留keras-contrib==x.y.z @ ...将使搜索包,其中不是版本,而是名称的一部分install_requires。同时,不指定版本将导致获取 PyPI 上可用的最新版本,而不是来自.pipkeras-contrib==x.y.z==x.y.zsetuptoolsdependency_links
在您的情况下,PyPI 中既不存在keras-contrib也不en-core-web-sm存在,因此使用不指定版本的keras_contrib@git+https://...+可能会起作用。dependency_links
否则,如果包依赖于链接,请坚持pip install .并避免使用。python setup.py install
也可以看看:
\n--process-dependency-links在实施替代方案之前取消弃用\n\n琐事:GitHub 上的几个问题仍然悬而未决,PEP 508
\nActive自 2015 年以来仍然处于状态。深入研究源代码会发现setuptools是 Python 的distutils的包装器。setuptools不是Python stdlib 的一部分,但distutils暗示stdlib 文档将在更新后删除setuptools。同时pip已经作为Python 的模块与Python 的安装捆绑在一起。然而我们还有pipfiles、pipenv、poetry、conda、pipx、pip-tools、shiv、spack以及其余的。看起来有点势不可挡。
| 归档时间: |
|
| 查看次数: |
2247 次 |
| 最近记录: |