跳转到主要内容

未提供项目描述

项目描述

pip-split-requirements

PyPI - Version PyPI - Python Version


根据正则表达式模式规则拆分pip需求文件。

目录

安装

pipx install pip-split-requirements

快速开始

假设以下requirements.txt

--find-links wheelhouse
pkga
git+https://github.com/some/project
pkgb

运行

pip-split-requirements -g slow:git requirements.txt

将创建requirementsgroup-slow.txt

--find-links wheelhouse
git+https://github.com/some/project

requirementsgroup-other.txt

--find-links wheelhouse
pkga
pkgb

CLI使用

Usage: pip-split-requirements [OPTIONS] REQUIREMENTS_FILE...

  Split a pip requirements file into multiple files according to patterns.

  Patterns are regular expressions against which requirement lines are
  searched to determine if they belong to a group. Group specs are evaluated
  in order, and the first match determines in which group the line goes.

  Comment lines are ignored.

  Option lines are emitted in all groups.

Arguments:
  REQUIREMENTS_FILE...  The requirements files to split. If not specified,
                        they are read from pyproject.toml.

Options:
  -g, --group-spec TEXT           Group specifications in form name:pattern.
  -p, --prefix TEXT               Each requirements group file will be named
                                  {prefix}-{group_name}.txt. The prefix can
                                  contain path separators, to generate files
                                  into a chosen directory.  [default:
                                  requirementsgroup]
  --default-group / --no-default-group
                                  Automatically append a group named 'other',
                                  matching all lines not matched by other
                                  groups.  [default: default-group]
  --remove-empty / --no-remove-empty
                                  Remove empty requirements group files.
                                  [default: no-remove-empty]
  -r, --project-root DIRECTORY    The project root directory. The generated
                                  requirements files will be relative to this
                                  directory. Default options and arguments are
                                  read from pyproject.toml in this directory.
                                  [default: .]
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  --help                          Show this message and exit.

在pyproject.toml中的配置

pip-split-requirements可以使用pyproject.toml配置。以下值从tool.pip-split_requirements部分读取

  • group_specs: 字符串列表
  • prefix: 字符串
  • default_group: 布尔值
  • remove_empty: 布尔值
  • requirements_files: 字符串列表

命令行选项和参数的优先级高于pyproject.toml值。

以下示例配置将requirements.txtrequirements-test.txt拆分为名为vcs的组,其中包含包含单词git+httpsgit+ssh的需求,以及另一个包含所有其他内容的组,作为build/reqgroup-*.txt

[tool.pip-split-requirements]
prefix = "build/reqgroup"
group_specs = ["vcs:git.(https|ssh)"]
requirements_files = ["requirements.txt", "requirements-test.txt"]

作为pre-commit钩子使用

以下.pre-commit-config.yaml部分的配置将运行pip-split-requirements。此pre-commit钩子在pyproject.toml.pre-commit-config.yaml或任何匹配模式.*requirement.*\.txt的文件更改时运行。

  - repo: https://github.com/sbidoul/pip-split-requirements
    rev: v0.7.0
    hooks:
      - id: pip-split-requirements

许可证

pip-split-requirements根据MIT许可证分发。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码发行版

pip_split_requirements-0.7.0.tar.gz (9.2 kB 查看哈希值)

上传时间 源代码

构建发行版

pip_split_requirements-0.7.0-py3-none-any.whl (7.8 kB 查看哈希值)

上传时间 Python 3

由 ... 支持