Skip to content

Commit

Permalink
Explain deprecated parts of API in README
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Oct 18, 2020
1 parent b628791 commit 446d8fa
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
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.

Expand All @@ -8,28 +11,10 @@ provides:
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 ``pytest`` or `tox <https://pypi.org/project/tox>`_.

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))
Lower level usage—you are responsible for ensuring build requirements are
available:
Usage—you are responsible for ensuring build requirements are available:

.. code-block:: python
Expand All @@ -42,6 +27,8 @@ available:
build_sys = toml.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,
Expand All @@ -52,11 +39,38 @@ available:
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
Expand All @@ -69,6 +83,4 @@ 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
<https://github.com/pypa/packaging-problems/issues/219>`_.
All of this high-level functionality is deprecated.

0 comments on commit 446d8fa

Please sign in to comment.