- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Python 库 ( https://github.com/jcrozum/PyStableMotifs ),我想在 PyPI 上发布。它依赖于另一个我无法控制的库 ( https://github.com/hklarner/PyBoolNet ),它只在 GitHub 上可用,特别是在 PyPI 上不可用。我的 setup.py 看起来像这样:
from setuptools import
setup(
... <other metadata> ...,
install_requires=[
'PyBoolNet @ git+https://github.com/hklarner/PyBoolNet@2.3.0',
... <other packages> ...
]
)
运行 pip install git+https://github.com/jcrozum/PyStableMotifs
完美运行,但由于 twine 出现以下错误,我无法将其上传到 PyPI:
requires_dist 的值无效。错误:不能有直接依赖:'PyBoolNet @git+https://github.com/hklarner/PyBoolNet@2.3.0'
我的理解是,出于安全原因,PyPI 禁止直接链接。尽管如此,PyBoolNet 是 PyStableMotifs 的硬性要求。我该怎么办?放弃 PyPI?
我只想让 pip install PyStableMotifs
为我的用户工作。理想情况下,此命令应安装依赖项,我不必维护两个版本的 setup.py。
否则,我考虑在 PyPI 上创建一个“虚拟”包,指导用户使用命令 pip install git+https://github.com/jcrozum/PyStableMotifs
进行安装。这是一个坏主意(甚至可能)吗?
是否已经针对这种情况建立了最佳实践或其他常见的解决方法?
编辑:现在,我有一个笨拙且完全不能令人满意的解决方法。我保留了两个版本;一个完美运行的 GitHub 版本,以及一个删除了 PyBoolNet 要求的 PyPI 版本。如果用户尝试在未安装 PyBoolNet 的情况下导入 PyStableMotifs,则会显示一条错误消息,其中包含 PyBoolNet 的安装说明。这在我看来远非理想,但在我找到更好的解决方案或 PyPI 修复此错误(或删除此功能,具体取决于您询问的对象)之前,我必须这样做。
最佳答案
我的建议是摆脱 install_requires
中的直接 URL,并告诉您的用户他们可以在哪里找到该依赖项 PyBoolNet,因为它不在 上PyPI。不要强制他们采用特定的安装方法,而是向他们展示示例。
也许只是简单地告诉您的用户:
This project depends on PyBoolNet, which is not available on PyPI. One place where you can find it is at:
https://github.com/hklarner/PyBoolNet
.One way to install PyStableMotifs as well as its dependency PyBoolNet is to run the following command:
python -m pip install 'git+https://github.com/hklarner/PyBoolNet@2.3.0#egg=PyBoolNet' PyStableMotifs
您还可以准备一个 requirements.txt
文件并告诉您的用户:
Install with the following command:
python -m pip install --requirement https://raw.githubusercontent.com/jcrozum/PyStableMotifs/master/requirements.txt
requirements.txt
的内容可能是这样的:
git+https://github.com/hklarner/PyBoolNet@2.3.0#egg=PyBoolNet
PyStableMotifs
但最后,您真的应该让您的用户选择如何安装该依赖项。您的项目只需要声明它依赖于该库,而不是如何安装它。
关于github - PyPI install_requires 直接链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68073819/
这个问题在这里已经有了答案: Pip install from pypi works, but from testpypi fails (cannot find requirements) (2 个
我有一个 Python 库 ( https://github.com/jcrozum/PyStableMotifs ),我想在 PyPI 上发布。它依赖于另一个我无法控制的库 ( https://gi
我正在使用 setuptools 创建一个快速 setup.py 脚本来为用户安装依赖项。该软件包只需要 numpy 和 matlibplot。所以代码看起来像这样: from setuptools
我使用 python bdist_rpm 创建了一个新的 RPM。通常 python setup.py install 会安装 python 依赖项,如 websocket-client 或任何其他包
要制作一个python包,在setup.py中,我有以下内容: setup( name='TowelStuff', version='0.1.0', author='J. Ra
我在这里的问题可能看起来很幼稚,但我从未在网络资源上找到任何关于它的线索。 问题是,关于 install_requires 函数或 setup() 文件的 setup.cfg 参数, 提及使用的每个包
我有多个共享内部库,许多存储库都依赖这些库。现在,这些库位于同一个 git 存储库中,并在需要时被子模块到每个应用程序中。在构建期间,我将 pip 安装库。我面临的问题是这些内部库也相互依赖,但由于它
这是我的代码的一部分:(setup.py) args = { 'name' : 'ModernGL.PyQt5', 'version' : Version, 'descript
我需要添加 rjsmin通过 install_require 添加到我的依赖项在 setup.py 中。 rjsmin提供了一种使用 --without-c-extensions 禁用 c 扩展的方法
在上传之前,我在包目录中使用 pip3 install -e . 测试我的 PyPI 包。 依赖于pillow(在代码中导入PIL) 当我使用已安装的枕头进行测试时,它起作用了。 但是,我卸载了 pi
我有一个适用于 python 2 和 python 3 的模块。在 Python=3.2。 类似: install_requires=[ "threadpool >= 1.2.7 if py
我无法使用 setup.py 安装本地软件包 这是项目结构: my-project/ lib/ local1/ local1.1.0.whl index.
我需要使用 pip install SomePackage.tar.gz 安装一个 python 包。在此包的 setup.py 中,install_requires 下列出的一些库已成为 Pytho
我写了一个依赖openpyxl的python模块。我希望使用 setuptools 将 openpxyl 作为依赖项自动安装。我读到正确的方法是在 setup.py 脚本中包含以下内容: setup(
我想制作一个依赖于特定版本范围的包,例如>= 0.5.0, , =, == or !=, followed by a version identifier. 文档给出了一个这样的简单示例: docut
我有一个如下所示的 setup.py: from setuptools import setup from subprocess import call from setuptools.command
是否可以让 setuptools 的 extras_require 覆盖 install_requires 中的要求集?我的猜测是不,因为 extras_require 是一个 ...dictiona
我注意到一些 python 项目在所需模块列表中包含 setuptools。没有它,我的代码可以正常安装和执行。 我可能错了,但我认为 install_requires 列表的目的是指定安装后执行所需
我已经使用 pip 安装 PIL。安装时需要两个额外的参数。所以安装命令看起来像这样。 pip install PIL --allow-external PIL --allow-unverified
我正在创建一个 setup.py依赖于私有(private) GitHub 存储库的项目的文件。文件的相关部分如下所示: from setuptools import setup setup(name
我是一名优秀的程序员,十分优秀!