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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_build-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 564070024b25f5e3a112475b2c7ffbc61fe78ee2e2da79452debce614ae7ea7f
MD5 991b355a77344b037a8880573fd199f1
BLAKE2b-256 69e2d063f2aea16a4f399a57d14392f02540c32db26efc70beba8d3d916a1311

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_build-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e6dfe0d5f24e7531d7859951deb850446f90110f1b631ea94500b4d92258db0
MD5 58bf9e6c2db390545f44bee5d761d66c
BLAKE2b-256 ba527a758050955368485fb24b60e0ee74b83934cc238f79558be3419ec5de42

See more details on using hashes here.

Supported by

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