File: PKG-INFO

package info (click to toggle)
pep517 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 376 kB
  • sloc: python: 1,388; makefile: 12; sh: 5
file content (106 lines) | stat: -rw-r--r-- 3,802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Metadata-Version: 2.1
Name: pep517
Version: 0.13.0
Summary: Wrappers to build Python packages using PEP 517 hooks
Home-page: https://github.com/pypa/pep517
Author: Thomas Kluyver
Author-email: thomas@kluyver.me.uk
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Dist: tomli >=1.1.0;python_version<'3.11'
Requires-Dist: importlib_metadata;python_version<'3.8'
Requires-Dist: zipp;python_version<'3.8'

API to call PEP 517 hooks
=========================

`PEP 517 <https://www.python.org/dev/peps/pep-0517/>`_ specifies a standard
API for systems which build Python packages.

`PEP 660 <https://www.python.org/dev/peps/pep-0660/>`_ extends it with a build
mode that leads to editable installs.

This package contains wrappers around the hooks specified by PEP 517 and
PEP 660. 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.

Run the tests with ``pytest`` or `tox <https://pypi.org/project/tox>`_.

Usage—you are responsible for ensuring build requirements are available:

.. code-block:: python

    import os
    import tomli
    from pep517.wrappers import Pep517HookCaller

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

    print(build_sys['requires'])  # List of static requirements
    # The caller is responsible for installing these and running the hooks in
    # an environment where they are available.

    hooks = Pep517HookCaller(
        src, 
        build_backend=build_sys['build-backend'],
        backend_path=build_sys.get('backend-path'),
    )

    config_options = {}   # Optional parameters for backend
    # List of dynamic requirements:
    print(hooks.get_requires_for_build_wheel(config_options))
    # Again, the caller is responsible for installing these build requirements

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

Deprecated high-level
---------------------

For now, ``pep517`` also contains higher-level functions which install the build
dependencies into a temporary environment and build a wheel/sdist using them.
This is a rough implementation, e.g. it does not do proper build isolation.
The `PyPA build project <https://github.com/pypa/build>`_ is recommended as an
alternative, although it's still quite young in October 2020.
This layer of functionality in ``pep517`` is now deprecated, but won't be
removed for some time, as there is code relying on it.

High level usage, with build requirements handled:

.. code-block:: python

    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))

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

.. code-block:: 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:

.. code-block:: shell

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

All of this high-level functionality is deprecated.