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.2.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

simple_build-0.0.2-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_build-0.0.2.tar.gz
  • Upload date:
  • Size: 22.1 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.2.tar.gz
Algorithm Hash digest
SHA256 d10ccf1a0bec6aa63e4e4c5bf38759d1a71bfb9069ae68996ab6b656798f376a
MD5 e36e2fc6bfb95a7a2eb7e8f93f807f2b
BLAKE2b-256 7a46f5532806a228d249f98ebc9c52d4dc0aa14a7c2f8ddf0e88804e14a508b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_build-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 24.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0230b9664745394ea12ee1fd00aac2bde66373a005f3b7e75aecdfe668df2c3a
MD5 50c61c5740c1494905059d2829fd1bef
BLAKE2b-256 80c496ecc5667048dc1743c0c73c3fc1be575cd282ec7f28073d7b1eb75373f8

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