首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用``pip tools`中的``pip `dev_requirements.txt` `从`setup.cfg`文件的`extras_require`段创建编译?

如何使用``pip tools`中的``pip `dev_requirements.txt` `从`setup.cfg`文件的`extras_require`段创建编译?
EN

Stack Overflow用户
提问于 2021-08-09 13:27:23
回答 1查看 487关注 0票数 0

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

代码语言:javascript
复制
#! /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

代码语言:javascript
复制
...
[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会产生我的包要求:

代码语言:javascript
复制
...
async-timeout==3.0.1
    # via aiohttp
attrs==21.2.0
    # via aiohttp
bcrypt==3.2.0
...

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

如何使用pip-compilesetup.cfg文件的此extras_require部分创建单独的dev_requirements.txt,而不必创建dev_requirements.in文件?

提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-09 13:52:09

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

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68712892

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档