【问题标题】:Does python's new 'pip wheel' have any support for building wheels for the dependencies listed in tests_requires?python 的新“pip wheel”是否支持为tests_requires 中列出的依赖项构建轮子?
【发布时间】:2023-03-23 22:29:02
【问题描述】:

我使用 setuptools 'tests_require' 来指定测试我的包所需的依赖项。

tests_require - http://pythonhosted.org/distribute/setuptools.html#new-and-changed-setup-keywords

我已经开始使用轮子包装了

http://wheel.readthedocs.org/en/latest/

并为我当前的包及其所有依赖项构建一个轮子目录。

pip wheel --wheel-dir=/tmp/wheelhouse .

但是,我还想为任何包 test_require 中列出的所有包构建轮子。

显然我可以在重复的 test_requirements.txt 文件中明确指定要求:

pip wheel --wheel-dir=/mnt/wheelhouse -r test-requirements.txt

但是我在测试需求文件和 tests_require 列表中都复制了依赖项。我可以将测试需求文件读入 tests_require ,但这似乎是在滥用需求文件,据我了解,这些文件旨在让用户能够控制指定已知可以协同工作的包的环境。

Requirements files - http://www.pip-installer.org/en/latest/cookbook.html

【问题讨论】:

    标签: python pip setuptools python-wheel


    【解决方案1】:

    不,对此没有明确的支持。最简单的方法是将extra 添加到您的 setup.py:

    setup(
        extras_require={
            "test": ["pytest", "your other requirements"],
        },
    )
    

    您当然可以重复使用与test_requires 相同的list,然后您可以使用pip wheel .[test],它会为所有这些制造轮子。

    【讨论】:

    • 语法“pip wheel .[test]”是否可以在 python-2.7 上工作?我得到一个:“zsh:找不到匹配项:[test]”
    • 您可能只需要引用 '.[test]' 这样它就不会尝试搜索与该 shell 通配符模式匹配的文件名。
    猜你喜欢
    • 2018-10-14
    • 1970-01-01
    • 2014-11-21
    • 1970-01-01
    • 2021-04-29
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多