Skip to main content

pip-tools, layered

Project description

ptl: pip-tools, layered

PyPI - Version PyPI - Python Version GitHub License

GitHub Actions Workflow Status Codecov

Description

ptl is a pip-tools wrapper for multi-layered requirements. There is already a project with the similar goal — pip-compile-multi — but ptl has some key differences:

  • It is much, much simpler. All it does is find requirements input files (*.in), generate intermediate input files with all references include transitive ones, and call pip-compile in topological order.
  • It is supposed to be unopinionated — it doesn't have any options applied to the pip-compile command by default. Configure pip-tools as you wish.
  • It has no dependencies, including pip-tools. Bring your own tools.
  • It supports not only pip-tools, but also uv, or any other compatible tool.
  • It has pip-sync functionality as well.

Usage

  1. Install ptl:

    pip install ptl
    
  2. Install pip-tools or uv:

    pip install pip-tools
    

    or

    pip install uv
    
  3. Prepare input files. By default, ptl looks for input files in the requirements directory and the current working directory. <layer>.in and <layer>.requirements.in filename formats are supported (although the latter may seem unnecessarily verbose, it's better suited for syntax highlighting rules — basically, any *.requirements.{in,txt} file as a “pip requirements” file). You can check out the requirements directory of the ptl repository for an example (yes, we eat our own dog food).

  4. Run ptl compile:

    usage: ptl compile [--pip-tools | --uv | --tool TOOL] [-d DIR] [-v | -q] [-h]
    
    tool selection:
      --pip-tools           use `pip-compile`
      --uv                  use `uv pip compile`
      --tool TOOL           use custom tool
    
    compile options:
      -d DIR, --directory DIR
                            input directory
      -v, --verbose         get more output
      -q, --quiet           get less output
    

    By default, ptl checks for pip-tools and uv, and if both are installed, it conservatively prefers pip-tools. With --pip-tools/--uv/--tool TOOL you can explicitly choose the tool to use or provide your own tool.

    Any extra arguments are passed to the underlying tool.

    As part of the compile process, ptl generates temporary intermediate input files next to the original input files. Normally they are deleted at the end of the operation, but it's a good practice to add *.ptl.in (or *.ptl.requirements.in if you use the <layer>.requirements.in filename format) in your .gitignore anyway.

  5. Run ptl sync:

    usage: ptl sync [--pip-tools | --uv | --tool TOOL] [-d DIR] [-v | -q] [-h]
    
    tool selection:
      --pip-tools           use `pip-sync`
      --uv                  use `uv pip sync`
      --tool TOOL           use custom tool
    
    sync options:
      -d DIR, --directory DIR
                            input directory
      -v, --verbose         get more output
      -q, --quiet           get less output
    

    As with ptl compile, any extra arguments are passed to the sync tool.

Planned Features

  • Ability to compile/sync only some of the files (0.2.0)
  • Configuration via the config file and/or the enviroment variables.

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

ptl-0.2.0.tar.gz (16.6 kB view hashes)

Uploaded Source

Built Distribution

ptl-0.2.0-py3-none-any.whl (17.4 kB view hashes)

Uploaded Python 3

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