python - setup.py 忽略完整路径依赖,而是在 pypi 中查找 "best match"

标签 python pip setuptools setup.py

类似于 https://stackoverflow.com/questions/12518499/pip-ignores-dependency-links-in-setup-py

我正在修改 faker期待公开公关,我已经打开了 validators ,我希望能够测试我将拥有的新依赖项。

setup(
    name='Faker',
    ...
    install_requires=[
        "python-dateutil>=2.4",
        "six>=1.10",
        "text-unidecode==1.2",
    ],
    tests_require=[
        "validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0",  # TODO: this will change  # noqa
        "ukpostcodeparser>=1.1.1",
        ...
    ],
    ...
)

python setup.py test 拒绝安装 0.13.0 版本。

如果我将问题行移至 install_requires=[..](不应该存在)

setup(
    name='Faker',
    ...
    install_requires=[
        "python-dateutil>=2.4",
        "six>=1.10",
        "text-unidecode==1.2",
         "validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0",  # TODO: this will change  # noqa
    ],
    tests_require=[
        "ukpostcodeparser>=1.1.1",
        ...
    ],
    ...
)
  • 使用 pip install -e 。一切正常——安装了正确的版本。
  • 使用 python setup.py develop 同样的问题。

我的猜测是 setuptools/distutils 做了一些奇怪的事情——pip 似乎解决了这个问题。我的问题:我该如何解决这个问题?

有问题的代码和引用可以在这里找到:

查看当前问题的最简单方法:

docker run -it --rm python:3.7 bash -c "git clone https://github.com/kingbuzzman/faker.git; cd faker; pip install -e .; python setup.py test"

更新:由于此问题已得到修复,该问题将不再重复——所有测试都将通过

最佳答案

不幸的是,setup_requirestests_require 都不支持来自 PEP 508 的基于 URL 的查找或环境标记。你需要使用dependency_links,例如

setup(
    ...
    tests_require=["validators>=0.13.0"],
    dependency_links=['git+https://github.com/kingbuzzman/validators@master#egg=validators-0.13.0'],
)

关于python - setup.py 忽略完整路径依赖,而是在 pypi 中查找 "best match",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56046146/

相关文章:

python - 在 Python 中删除字符串中间的连续字符

python - python中的多元曲线拟合用于估计椭圆形状的参数和阶数

javascript - 为什么 Django 没有检测到我在 javascript fetch POST 请求中发送的数据?

python - 如何在 virtualenv 中安装包?

python - pip3 无法确定存档格式

python - 添加 [别名] 失败,错误为 : invalid command 'xyz'

python - 如何为年/月/日/小时/分钟/秒的日期时间创建 Pandas 列?

python - 安装 python 模块忽略版本要求

python - 如何在 setup.py 中使用 Numba 扩展?

python - 在 pypi 上注册包时为 "Server response (401): You must login to access this feature"