python - 如何使用 `dev_requirements.txt` 中的 `extras_require` 从 `setup.cfg` 文件的 `pip-compile` 部分创建 `pip-tools`?

标签 python pip setuptools pip-tools

我使用 pip-tools管理我的依赖项和环境,它完美地为我的包生成一个 requirements.txt 文件,该文件由一个 setup.py 组成,如下所示:

#! /usr/bin/env python
import os
from setuptools import setup


if "CI_COMMIT_TAG" in os.environ:
    VERSION = os.environ["CI_COMMIT_TAG"]
else:
    VERSION = "0.0.0"

setup(version=VERSION)

和这样的 setup.cfg:

...
[options]
python_requires = >=3.7
zip_safe = False
packages = find:
include_package_data = True
install_requires =
    PyYAML
    Cython
    numpy==1.17.5
    pandas==0.25.3
    ...
package_dir=
    foo=bar

[options.extras_require]
testing =
    tox>=3.1.2
    pytest>=3.4.0
coverage =
    coverage
    pytest-cov>=2.5.1
other =
    anybadge
...

运行 $ pip-compile --index-url https://foo@bar@gitlab.my.host/api/v4/projects/236/packages/pypi/simple --no-header -- allow-unsafe 产生我的包要求:

...
async-timeout==3.0.1
    # via aiohttp
attrs==21.2.0
    # via aiohttp
bcrypt==3.2.0
...

但这只包括我的 setup.cfg 文件的 install_requires 部分中的所有包,而不包括 extras_require 中的要求。它应该与 dev_requirements.in 文件一起使用,如 here 所述但我宁愿只使用一个配置文件。

如何使用 pip-compile 从我的 setup.cfg 文件的这个 extras_require 部分创建一个单独的 dev_requirements.txt 无需创建 dev_requirements.in 文件?

提前致谢!

最佳答案

挖了一段时间后,我在另一个issue中找到了我的答案:

$ pip-compile --extra testing --extra other

关于python - 如何使用 `dev_requirements.txt` 中的 `extras_require` 从 `setup.cfg` 文件的 `pip-compile` 部分创建 `pip-tools`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68712892/

相关文章:

python - 如何使用 Python 将 JSONB 插入到 Postgresql 中?

python - Python 请求 Session 对象是否在 gevent greenlet 之间共享,线程安全(在 greenlet 之间)?

Windows 上的 Pip 安装无法结合 '--user' 和 '--target'

python - linux离线模式下的pip安装要求

python - 从源安装 setuptools "No module named numbers"错误

Python - setuptools - 处理两个依赖包(在一个 repo 中?)

python - 在 Python 中更新 2D 数组值 - 更新整列错误?

python - 行系列中不完全匹配的搜索算法

pip - 如何在 Apple M1 Silicon 笔记本电脑上安装 GRPCIO?

python - 在 Python 中安装本地附加功能