Skip to main content

Collection of convenience functions to patch `pyproject.toml` in place

Project description

pyproject-patcher

This Python package is an attempt to make it a little easier to patch pyproject.toml in place.

It is mainly useful for maintainers of system packages.
If you’re not a maintainer of system packages, or if you don’t know what that means, then pyproject-patcher is probably not for you.

Features

  • Hard code a version number into project.version

  • Disable all invocations of the dynamic version generator setuptools-git-versioning

  • Remove dependency to setuptools-git-versioning from build-system.requires

  • Configure setuptools-git-versioning to use a version template without a .dirty suffix

Installation

Installing from PyPI

To install pyproject-patcher from PyPI, open a shell and run:

pip install pyproject-patcher

If that doesn’t work, try:

python3 -m pip install pyproject-patcher

Installing from the AUR

Direct your favorite AUR helper to the python-pyproject-patcher package.

Usage

See USAGE.md for details.

Contributing to pyproject-patcher

See CONTRIBUTING.md.

License

Copyright (c) 2024 Claudia Pellegrino

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. For a copy of the License, see LICENSE.

Description

This Python package is an attempt to make it a little easier to patch pyproject.toml in place.

It is mainly useful for maintainers of system packages.
If you’re not a maintainer of system packages, or if you don’t know what that means, then pyproject-patcher is probably not for you.

Examples

Recommended import statement

The following examples all assume the following import statement:

from pyproject_patcher import patch_in_place

Set a static project version

with patch_in_place('pyproject.toml') as toml:
    toml.set_project_version('1.2.3')

Strip the version constraint of a dependency

with patch_in_place('pyproject.toml') as toml:
    toml.strip_build_system_dependency_constraint('setuptools-git-versioning')
    # or, equivalently:
    # toml.build_system_requires.strip_constraint('setuptools-git-versioning')

Remove an entry from a dependency list

with patch_in_place('pyproject.toml') as toml:
    toml.remove_build_system_dependency('setuptools-git-versioning')
    # or, equivalently:
    # toml.build_system_requires.remove_dependency('setuptools-git-versioning')

Remove setuptools-git-versioning from pyproject.toml entirely

with patch_in_place('pyproject.toml') as toml:
    toml.set_project_version('1.2.3')
    toml.tools.setuptools_git_versioning.remove()

Configure a version template without a .dirty suffix

with patch_in_place('pyproject.toml') as toml:
    toml.tools.setuptools_git_versioning.template_ignore_dirty_git()

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

pyproject_patcher-0.2.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

pyproject_patcher-0.2.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file pyproject_patcher-0.2.2.tar.gz.

File metadata

  • Download URL: pyproject_patcher-0.2.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyproject_patcher-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1fc23a38636984b12963b7fe61c719d62f42aae8b424f0fd7f6d6e59f0c92dbf
MD5 8f35aeeff894bc7bd0ab4fc55d010476
BLAKE2b-256 bd86ec3b2e863da551f49fd5c184fc808ef914af0d523cc64c4b5992c8024b4a

See more details on using hashes here.

File details

Details for the file pyproject_patcher-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyproject_patcher-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 688c7749fa44be333bfdd0b77aa464e5276a47c49abd02ca58e1b794f6c70beb
MD5 23ef735d4d21a7634d41a94ad7f9cf3e
BLAKE2b-256 18a69a1e71b8a85c2c957381ccfaa1476aade118cab00e2a1b0babdaf28ddaa4

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