pip-split-requirements
Split a pip requirement files according to regular expression patterns rules.
Table of Contents
Installation
pipx install pip-split-requirements
Quick start
Assume the following requirements.txt:
--find-links wheelhouse
pkga
git+https://github.com/some/project
pkgb
Running
pip-split-requirements -g slow:git requirements.txt
Will create requirementsgroup-slow.txt:
--find-links wheelhouse
git+https://github.com/some/project
and requirementsgroup-other.txt:
--find-links wheelhouse
pkga
pkgb
CLI Usage
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.
Configuration in pyproject.toml
pip-split-requirements can be configured using pyproject.toml. The following values are read from the tool.pip-split_requirements section:
- group_specs: list of strings
- prefix: string
- default_group: boolean
- remove_empty: boolean
- requirements_files: list of strings
Command line options and argument have precedence over pyproject.toml values.
The following example configuration split requirements.txt and requirements-test.txt
into a group named vcs with requirements containing the word git+https or git+ssh
and another group with everything else, as build/reqgroup-*.txt.
[tool.pip-split-requirements]
prefix = "build/reqgroup"
group_specs = ["vcs:git.(https|ssh)"]
requirements_files = ["requirements.txt", "requirements-test.txt"]
Usage as a pre-commit hook
The following section of .pre-commit-config.yaml will run pip-split-requirements
according using the configuration in pyproject.toml. This pre-commit hook runs when
either pyproject.toml, .pre-commit-config.yaml, or any file matching the pattern
.*requirement.*\.txt change.
- repo: https://github.com/sbidoul/pip-split-requirements
rev: v0.7.0
hooks:
- id: pip-split-requirements
License
pip-split-requirements is distributed under the terms of the
MIT license.
Metadata
Release files for pip-split-requirements 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pip_split_requirements-0.7.0.tar.gz | 9.2 kB | Without provenance | Details for pip_split_requirements-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pip_split_requirements-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for pip_split_requirements-0.7.0-py3-none-any.whl |
Total release size: 16.9 kB
Release files / pip_split_requirements-0.7.0.tar.gz
| Download URL | pip_split_requirements-0.7.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3b2cfbbf4f918f03bd042d01863a7bd9b661b2a7c2a52cdccfbb9b32546ed6b
|
|
BLAKE2b-256 checksum How to use checksums |
a782edb25dbab8c688533def9a636db3939d1f3f143747d5e8100b426d46ff7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / pip_split_requirements-0.7.0-py3-none-any.whl
| Download URL | pip_split_requirements-0.7.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddcea386300a7adafe09cf302cdb083fa3bb4648db8b66cad266d7c7c20cf7aa
|
|
BLAKE2b-256 checksum How to use checksums |
f438c3099b88df50a277e1644f117d540f59f3a17d01d98eb8bcf31358e87b97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Security for pip-split-requirements 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.