检查 testpypi 上的设置工具 install_requires

Checking setuptools install_requires on testpypi

我正在尝试测试一个 python 包,我想使用测试 test.pypi 发布。

setup.py 文件中我有 install_requires=['numpy>=1.15','scipy>=0.0','scikit-learn>=0.2','numba>=0.0'],

Scipy 和 Numpy 按预期下载和安装。

我收到以下错误:ERROR: Could not find a version that satisfies the requirement numba>=0.0

请注意,如果我在我的测试包之前执行 pip install numba 它会起作用,但我正在努力使包正常工作。

我注意到当它首先执行 scipy 要求时,它显示 Downloading https://test-files.pythonhosted.org/packages/68/72/eb962a3ae2755af6b1f31f7a94dccc21bfc41bb1637c5877a043e711b1d7/scipy-0.1.tar.gz

所以从 url 来看,它似乎正在使用测试文件,但这是常规 pypi 还是只是测试文件?

我的问题是:编写 install_requires 的合适方法是什么,这样我就可以确保在将它放到实际的 pypi 站点之前测试有效?

您的语法没有任何问题,只是与 scipynumpyscikit-learn 不同,测试 PyPI 上没有托管 numba实例。比较:

https://pypi.org/project/numba/ <-- 200 行

https://test.pypi.org/project/numba/ <-- 404 未找到

My question is: what is the appropriate way to write the install_requires so I can make sure the test works before putting it on the actual pypi site?

你写的 install_requires 没问题。要对其进行冒烟测试,请上传您的包以测试 PyPI 并检查它是否安装正确,使用测试 PyPI 作为 extra 索引 url,而不是替代 --index-url:

pip install yourpackage --extra-index-url=https://test.pypi.org/simple/

这样 yourpackage 可以在测试 PyPI 中找到,但安装要求如 numba 仍然可以在主 PyPI 上解决。