Skip to main content

No project description provided

Project description

pip-split-requirements

PyPI - Version PyPI - Python Version


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...  [required]

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]
  --help                          Show this message and exit.

Usage as a pre-commit hook

The following section of .pre-commit-config.yaml will 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.

  - repo: https://github.com/sbidoul/pip-split-requirements
    rev: v0.1.0
    hooks:
      - id: pip-split-requirements
        files: ^requirements.*.txt$
        args:
          - --prefix=build/reqgroup
          - --group-spec=vcs:git.(https|ssh)
          - requirements.txt
          - requirements-test.txt

License

pip-split-requirements is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pip_split_requirements-0.6.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

pip_split_requirements-0.6.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pip_split_requirements-0.6.0.tar.gz.

File metadata

File hashes

Hashes for pip_split_requirements-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ccb291ee1d853556ad14b50e3b100bfbdb902689d3fbf617d19d4f8ca12a91ac
MD5 e387348eff4e67b8738582e0f98b8c2b
BLAKE2b-256 b4c0cbdffd2dab079430ed81b44a98deb364664f9c03e8527c83566d3ebfdd5c

See more details on using hashes here.

File details

Details for the file pip_split_requirements-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pip_split_requirements-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce46bbcd15ce1bf68702fbc30ba8aa929b07c7a46e08c6f56b0859eac28255b1
MD5 f877a6ccb71a0bf2e305fb162f487790
BLAKE2b-256 2bcf3a360c2eb48a9457237b0a7366869f8ad9145a69fb73bb18be366f2b89e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page