PEP 650: Fix typos, improve example (#1792)
This commit is contained in:
parent
9b64c6ea75
commit
3b0098ad9a
28
pep-0650.rst
28
pep-0650.rst
|
@ -49,7 +49,7 @@ Installer interface
|
||||||
Universal installer
|
Universal installer
|
||||||
An installer that can invoke an *installer backend* by calling the
|
An installer that can invoke an *installer backend* by calling the
|
||||||
optional invocation methods of the *installer interface*. This can
|
optional invocation methods of the *installer interface*. This can
|
||||||
also be thought of as the installer frontend, ala the build_
|
also be thought of as the installer frontend, à la the build_
|
||||||
project for :pep:`517`.
|
project for :pep:`517`.
|
||||||
|
|
||||||
Installer backend
|
Installer backend
|
||||||
|
@ -338,7 +338,7 @@ Installs the dependencies::
|
||||||
group that the *installer backend* should install. The install will
|
group that the *installer backend* should install. The install will
|
||||||
error if the dependency group doesn't exist. A user can find all
|
error if the dependency group doesn't exist. A user can find all
|
||||||
dependency groups by calling
|
dependency groups by calling
|
||||||
``get_dependencies_groups()`` if dependency groups are
|
``get_dependency_groups()`` if dependency groups are
|
||||||
supported by the *installer backend*.
|
supported by the *installer backend*.
|
||||||
* ``**kwargs`` : Arbitrary parameters that a *installer backend* may
|
* ``**kwargs`` : Arbitrary parameters that a *installer backend* may
|
||||||
require that are not already specified, allows for backwards
|
require that are not already specified, allows for backwards
|
||||||
|
@ -480,20 +480,25 @@ Let's consider implementing an *installer backend* that uses pip and
|
||||||
its requirements files for *dependency groups*. An implementation may
|
its requirements files for *dependency groups*. An implementation may
|
||||||
(very roughly) look like the following::
|
(very roughly) look like the following::
|
||||||
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def invoke_install(path, *, dependency_group=None, **kwargs):
|
def invoke_install(path, *, dependency_group=None, **kwargs):
|
||||||
file_name = "requirements.txt"
|
try:
|
||||||
if dependency_group:
|
return subprocess.run(
|
||||||
file_name = f"{dependency_group}-{file_name}"
|
[
|
||||||
requirements_path = pathlib.Path(path) / file_name
|
sys.executable,
|
||||||
return subprocess.call(
|
"-m",
|
||||||
[sys.executable, "-m", "pip", "install", "-r", os.fspath(requirements_path)]
|
"pip",
|
||||||
)
|
"install",
|
||||||
|
"-r",
|
||||||
|
dependency_group or "requirements.txt",
|
||||||
|
],
|
||||||
|
cwd=path,
|
||||||
|
).returncode
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return e.returncode
|
||||||
|
|
||||||
If we named this package ``pep650pip``, then we could specify in
|
If we named this package ``pep650pip``, then we could specify in
|
||||||
``pyproject.toml``::
|
``pyproject.toml``::
|
||||||
|
@ -663,4 +668,3 @@ CC0-1.0-Universal license, whichever is more permissive.
|
||||||
fill-column: 70
|
fill-column: 70
|
||||||
coding: utf-8
|
coding: utf-8
|
||||||
End:
|
End:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue