Metadata-Version: 2.3
Name: pyproject_patcher
Version: 0.2.3
Summary: Collection of convenience functions to patch `pyproject.toml` in place
License: Apache-2.0
Author: Claudia Pellegrino
Author-email: clau@tiqua.de
Requires-Python: >=3.12
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Requires-Dist: colorama
Requires-Dist: distlib
Requires-Dist: in-place
Requires-Dist: tomlkit
Requires-Dist: typing-extensions
Description-Content-Type: text/markdown

# 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:

```shell
pip install pyproject-patcher
```

If that doesn’t work, try:

```shell
python3 -m pip install pyproject-patcher
```

### Installing from the AUR

Direct your favorite
[AUR helper](https://wiki.archlinux.org/title/AUR_helpers) to the
`python-pyproject-patcher` package.

## Usage

See [`USAGE.md`](https://github.com/claui/pyproject-patcher/blob/main/USAGE.md) for details.

## Contributing to pyproject-patcher

See [`CONTRIBUTING.md`](https://github.com/claui/pyproject-patcher/blob/main/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](LICENSE).

<!-- markdownlint-configure-file { "MD041": { "level": 1 } } -->

# 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:

```py
from pyproject_patcher import patch_in_place
```

## Set a static project version

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

## Strip the version constraint of a dependency

```py
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

```py
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

```py
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

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

