Skip to main content

A simple build-backend for Python.

Project description

simple-build

A simple build-backend for Python.

The package implements the build backend interface, defined in https://peps.python.org/pep-0517, and https://peps.python.org/pep-0660.

It is very similar to flit and hatch, but it has one key additional feature I required: pre-write hooks. This is bit similar to hatch's build hook, but offers a lot more freedom to modify the packaged files.

Usage

Simply add the following to your pyproject.toml:

[build-system]
requires = ["simple-build"]
build-backend = "simple_build.backend"

Features

modules in src folder

The module will be found by the project name (normalising - to _), and supports packages in the common src folder layout, or at the root of the package.

[project]
name = "my-project"
pyproject.toml
src/
    my_project/
        __init__.py

Dynamic project metadata

The following fields can be set as dynamic values:

[project]
dynamic = ["version", "description", "authors"]

The values are then read from the root file of the package (__init__.py or the single module file):

"""My project description."""
__version__ = "0.1.0"
__author__ = "John Doe"
__email__ = "johndoe@email.com"

Git integration

By default the packaging will respect the .gitignore file, and exclude all files listed in it.

You can also configure this in the pyproject.toml:

[tool.build.sdist]
use_git = true
include = ["my_file.txt", ...]
exclude = ["my_file.txt", ...]

pre-write hooks

In your pyproject.toml you can define a list of hooks that can modify the files before they are written to the sdist or wheel:

[tool.build]
pre_write_hooks = ["my_hook.py"]

A hook file should contain a function with the following signature:

from pathlib import Path
from typing import Literal
from simple_build.analyse import PackageAnalysis

def pre_write_hook(
    type: Literal["sdist", "wheel"], src: Path, module: str | None, analysis: PackageAnalysis
) -> None:
    """A pre-write hook, to modify files before writing them to the sdist or wheel.

    :param path: The path to the temporary folder containing the files that will be written to the sdist/wheel.
        This can be modified in place, including deleting files and adding new ones.
    :param module: The name of the module.
    :param package: The package analysis.
    """

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

simple_build-0.0.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

simple_build-0.0.1-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file simple_build-0.0.1.tar.gz.

File metadata

  • Download URL: simple_build-0.0.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for simple_build-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e38da8a17fb3366d7292d5181b6c859cb85ab9de13192c414819bc03f820f432
MD5 0e5361d5885fdd0ecad1d3e847958d0a
BLAKE2b-256 ba22484ecccdced2938f0d08e4097d679ef7eb1acd002279cf16a420d409bce1

See more details on using hashes here.

File details

Details for the file simple_build-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: simple_build-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for simple_build-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b41120030e5647a194a39834199dafbdbea14e5bd3ef69ba9ebaec84da1e480e
MD5 079d2cab7900ba2fb2fc0ffe15190341
BLAKE2b-256 581eab71852bbb9ffbda057ad9aa1682d3a5a366a4684038fe8320d3ac7e9872

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