Skip to main content

Wrappers to build Python packages using PEP 517 hooks

Project description

PEP 517 specifies a standard API for systems which build Python packages.

This package contains wrappers around the hooks specified by PEP 517. It provides:

  • A mechanism to call the hooks in a subprocess, so they are isolated from the current process.

  • Fallbacks for the optional hooks, so that frontends can call the hooks without checking which are defined.

  • Higher-level functions which install the build dependencies into a temporary environment and build a wheel/sdist using them.

Run the tests with py.test.

High level usage, with build requirements handled:

import os
from pep517.envbuild import build_wheel, build_sdist

src = 'path/to/source'  # Folder containing 'pyproject.toml'
destination = 'also/a/folder'
whl_filename = build_wheel(src, destination)
assert os.path.isfile(os.path.join(destination, whl_filename))

targz_filename = build_sdist(src, destination)
assert os.path.isfile(os.path.join(destination, targz_filename))

Lower level usage—you are responsible for ensuring build requirements are available:

import os
import pytoml
from pep517.wrappers import Pep517HookCaller

src = 'path/to/source'  # Folder containing 'pyproject.toml'
with open(os.path.join(src, 'pyproject.toml')) as f:
    build_sys = pytoml.load(f)['build-system']

print(build_sys['requires'])  # List of static requirements

hooks = Pep517HookCaller(src, build_backend=build_sys['build_backend'])

config_options = {}   # Optional parameters for backend
# List of dynamic requirements:
print(hooks.get_requires_for_build_wheel(config_options))

destination = 'also/a/folder'
whl_filename = hooks.build_wheel(destination, config_options)
assert os.path.isfile(os.path.join(destination, whl_filename))

To test the build backend for a project, run in a system shell:

python3 -m pep517.check path/to/source  # source dir containing pyproject.toml

To build a backend into source and/or binary distributions, run in a shell:

python -m pep517.build path/to/source  # source dir containing pyproject.toml

This ‘build’ module should be considered experimental while the PyPA decides on the best place for this functionality.

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

pep517-0.6.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

pep517-0.6.0-py2.py3-none-any.whl (45.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pep517-0.6.0.tar.gz.

File metadata

  • Download URL: pep517-0.6.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.21.0

File hashes

Hashes for pep517-0.6.0.tar.gz
Algorithm Hash digest
SHA256 dde535e9a42de94f4cd941dbaa6feb0a4b5143ffd3906efea091c3826cb7d33d
MD5 954273e1b7609f4f39a8676d5449fce2
BLAKE2b-256 28c050f6c9e99d67eb720bf03c6224e77ff55ca61546f5e92b7d352d0720d032

See more details on using hashes here.

File details

Details for the file pep517-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pep517-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 45.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.21.0

File hashes

Hashes for pep517-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 273345f4538306f6e4056d8bbced566e186ab4defc188cb3be3e413b5d255912
MD5 afdbe97ec34c930c1ea2c20e98483d0a
BLAKE2b-256 a21fd99c4cb3c46cfe0c356e884ef26a23dd73b5d17d2b4efca201e03e63cc28

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