Skip to main content

hatch plugin to use pip-compile to manage project dependencies

Project description

hatch-pip-compile

hatch plugin to use pip-compile (or uv) to manage project dependencies and lockfiles.

PyPI PyPI - Python Version GitHub License docs Testing Status Hatch project Pip Tools project uv Ruff pre-commit semantic-release Gitmoji

Usage

The hatch-pip-compile plugin will automatically run pip-compile whenever your environment needs to be updated. Behind the scenes, this plugin creates a lockfile at requirements.txt (non-default lockfiles are located at requirements/requirements-{env_name}.txt). Once the dependencies are resolved the plugin will install the lockfile into your virtual environment and keep it up-to-date.

Installation

Declare hatch-pip-compile as a dependency in your pyproject.toml file under the [tool.hatch.env] table and hatch will automatically install it. You must also have your environment type set to pip-compile (see Configuration).

  • pyproject.toml

    [tool.hatch.env]
    requires = [
        "hatch-pip-compile"
    ]
    
    [tool.hatch.envs.default]
    type = "pip-compile"
    
  • hatch.toml

    [env]
    requires = [
        "hatch-pip-compile"
    ]
    
    [envs.default]
    type = "pip-compile"
    

Configuration

Set your environment type to pip-compile to use this plugin for the respective environment:

  • pyproject.toml

    [tool.hatch.envs.default]
    type = "pip-compile"
    
  • hatch.toml

    [envs.default]
    type = "pip-compile"
    

Common Scenarios

Configuration Options

The plugin gives you options to configure how lockfiles are generated and how they are installed into your environment.

The following example shows how to specify the pip-compile-hashes option on your environment in your pyproject.toml file:

[tool.hatch.envs.default]
type = "pip-compile"
pip-compile-hashes = true

Generating Lockfiles

name type description
lock-filename str The filename of the ultimate lockfile. default env is requirements.txt, non-default is requirements/requirements-{env_name}.txt
pip-compile-constraint str An environment to use as a constraint file, ensuring that all shared dependencies are pinned to the same versions.
pip-compile-hashes bool Whether to generate hashes in the lockfile. Defaults to false.
pip-compile-resolver str Whether to use pip-compile or uv to resolve dependencies into the project. Defaults to pip-compile
pip-compile-args list[str] Additional command-line arguments to pass to pip-compile-resolver
pip-compile-verbose bool Set to true to run pip-compile in verbose mode instead of quiet mode, set to false to silence warnings

Installing Lockfiles

name type description
pip-compile-installer str Whether to use pip, pip-sync, or uv to install dependencies into the project. Defaults to pip
pip-compile-install-args list[str] Additional command-line arguments to pass to pip-compile-installer


Check Out the Docs

Looking to contribute? See the Contributing Guide

See the Changelog

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

hatch_pip_compile-1.11.4.tar.gz (573.5 kB view details)

Uploaded Source

Built Distribution

hatch_pip_compile-1.11.4-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file hatch_pip_compile-1.11.4.tar.gz.

File metadata

  • Download URL: hatch_pip_compile-1.11.4.tar.gz
  • Upload date:
  • Size: 573.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hatch_pip_compile-1.11.4.tar.gz
Algorithm Hash digest
SHA256 77c1c5c550038c08f5c372a78bc535318a1c7ff28a6a36a3c348c62d7845d138
MD5 586b4e328ec30e78f974ea8fc424ef88
BLAKE2b-256 c7e8a0b9f88ab0f1c0c8846dcb72c502900806bfa393e126825b9d4926c3fdc4

See more details on using hashes here.

File details

Details for the file hatch_pip_compile-1.11.4-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_pip_compile-1.11.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c6cc19c0f2e940eca573aa3fff78508b61bdcee3e019ba3a2a4007c86b34e312
MD5 0139c04d100c32d5d96c9356415ef761
BLAKE2b-256 582df423505fd8c862d82adbb1cf72c1d74609b21b46454d2736b75636e7fa2e

See more details on using hashes here.

Supported by

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