Skip to content

Commit f06a8c7

Browse files
authored
Updates to PEP 660 (GH-1978)
1 parent 82cd151 commit f06a8c7

File tree

1 file changed

+84
-20
lines changed

1 file changed

+84
-20
lines changed

pep-0660.rst

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PEP: 660
2-
Title: Editable installs for PEP 517 style build backends
2+
Title: Editable installs for pyproject.toml based builds
33
Author: Daniel Holth <[email protected]>, Stéphane Bidoul <[email protected]>
44
Sponsor: Paul Moore <[email protected]>
55
Discussions-To: https://discuss.python.org/t/draft-pep-editable-installs-for-pep-517-style-build-backends/8510
@@ -67,11 +67,14 @@ require a compilation and/or installation step to become effective. The exact
6767
steps to perform will remain specific to the build backend used.
6868

6969
When a project is installed in editable mode, users expect the installation to
70-
behave identically as a regular installation. Depending on the way build
71-
backends implement this specification, some minor differences may be visible
72-
such as the presence of additional files that are in the source tree and would
73-
not be part of a regular install. Build backends are encouraged to document
74-
such potential differences.
70+
behave identically as a regular installation. In particular the code must be
71+
importable by other code, and metadata must be available to standard mechanisms
72+
such as ``importlib.metadata``.
73+
74+
Depending on the way build backends implement this specification, some minor
75+
differences may be visible such as the presence of additional files that are in
76+
the source tree and would not be part of a regular install. Build backends are
77+
encouraged to document such potential differences.
7578

7679
The Mechanism
7780
=============
@@ -85,17 +88,9 @@ build_wheel_for_editable
8588

8689
::
8790

88-
def build_wheel_for_editable(
89-
wheel_directory,
90-
scheme=scheme,
91-
config_settings=None):
91+
def build_wheel_for_editable(wheel_directory, config_settings=None):
9292
...
9393

94-
``scheme``: a dictionary of installation categories ``{ 'purelib':
95-
'/home/py/.../site-packages', 'platlib': '...'}``. This makes it possible to
96-
use relative paths to the source code, which might help the interpreter find
97-
the package after the root path changes with ``chroot`` or similar.
98-
9994
Must build a ``.whl`` file, and place it in the specified ``wheel_directory``.
10095
It must return the basename (not the full path) of the .whl file it creates, as
10196
a unicode string.
@@ -114,11 +109,11 @@ Build-backends must produce wheels that have the same dependencies
114109
with the exception that they can add dependencies necessary for their editable
115110
mechanism to function at runtime (such as `editables`_).
116111

117-
The filename for the editable wheel needs to be PEP 427 compliant too. It
112+
The filename for the "editable" wheel needs to be PEP 427 compliant too. It
118113
does not need to use the same tags as ``build_wheel`` but it must be tagged as
119114
compatible with the system.
120115

121-
An editable wheel uses the wheel format not for distribution but as ephemeral
116+
An "editable" wheel uses the wheel format not for distribution but as ephemeral
122117
communication between the build system and the front end. This avoids having
123118
the build backend install anything directly. This wheel must not be exposed
124119
to end users, nor cached, nor distributed.
@@ -142,7 +137,8 @@ If not defined, the default implementation is equivalent to ``return []``.
142137
What to put in the wheel
143138
------------------------
144139

145-
Build backends may use different techniques to achive the goals of an editable
140+
Build backends must populate the generated wheel with files that when installed will result in an editable install.
141+
Build backends may use different techniques to achieve the goals of an editable
146142
install. This section provides examples and is not normative.
147143

148144
* Build backends may choose to place a ``.pth`` file at the root of the ``.whl`` file,
@@ -157,11 +153,21 @@ install. This section provides examples and is not normative.
157153
a path importable, often including the project's own ``setup.py`` and other
158154
scripts that would not be part of a normal installation. The proxy strategy
159155
can achieve a higher level of fidelity than path-based methods.
156+
* Symbolic links are another useful mechanism to realize editable installs.
157+
Since, at the time this writing, the ``wheel`` specification does not support
158+
symbolic links, they are not directly usable to set-up symbolic links in the
159+
target environment. It is however possible for the backend to create a
160+
symlink structure in some ``build`` directory of the source tree, and add
161+
that directory to the python path via a ``.pth`` file in the "editable"
162+
wheel. If some files linked in this manner depend on python implementation or
163+
version, ABI or platform, care must be taken to generate the link structure
164+
in different directories depending on compatibility tags, so the same project
165+
tree can be installed in editable mode in multiple environments.
160166

161167
Frontend requirements
162168
---------------------
163169

164-
Frontends must install editable wheels in the same way as regular wheels.
170+
Frontends must install "editable" wheels in the same way as regular wheels.
165171
This also means uninstallation of editables does not require any special treatment.
166172

167173
Frontends must create a ``direct_url.json`` file in the ``.dist-info``
@@ -186,15 +192,73 @@ Frontends must not expose the wheel obtained from ``build_wheel_for_editable``
186192
to end users. The wheel must be discarded after installation and must not be
187193
cached nor distributed.
188194

195+
Limitations
196+
===========
197+
198+
With regard to the wheel ``.data`` directory, this PEP focuses on making the
199+
``purelib`` and ``platlib`` categories (installed into site-packages)
200+
"editable". It does not make special provision for the other categories such as
201+
``headers``, ``data`` and ``scripts``. Package authors are encouraged to use
202+
``console_scripts``, make their ``scripts`` tiny wrappers around library
203+
functionality, or manage these from the source checkout during development.
204+
189205
Rejected ideas
190206
==============
191207

208+
``editable`` local version identifier
209+
-------------------------------------
210+
192211
The ideas of having build backends append or modify the local version
193212
identifier to include the ``editable`` string has been rejected because it
194213
would not satisfy ``==`` version speicifier that include the local version
195-
identifier. In other workds ``pkg==1.0+local`` is not satisfied by version
214+
identifier. In other words ``pkg==1.0+local`` is not satisfied by version
196215
``1.0+local.editable``.
197216

217+
Virtual wheel
218+
-------------
219+
220+
Another approach was proposed in PEP 662, where
221+
the build backend returns a mapping from source files and directories to the
222+
installed layout. It is then up to the installer frontend to realize the
223+
editable installation by whatever means it deems adequate for its users.
224+
225+
In terms of capabilities, both proposals provide the core "editable" feature.
226+
227+
The key difference is that PEP 662 leaves it to the frontend to decide how the
228+
editable installation will be realized, while with this PEP, the choice must be
229+
made by the backend. Both approaches can in principle provide several editable
230+
installation methods for a given project, and let the developer choose one at
231+
install time.
232+
233+
At the time of writing this PEP, it is clear that the community has a wide
234+
range of theoretical and practical expectations about editable installs. The
235+
reality is that the only one there is wide experience with is path insertion
236+
via .pth (i.e. what setup.py develop does).
237+
238+
We believe that PEP 660 better addresses these "unknown unknowns" today in the
239+
most reliable way, by letting project authors select the backend or implement
240+
the method that provides the editable mechanism that best suit their
241+
requirements, and test it works correctly. Since the frontend has no latitude
242+
in *how* to install the "editable" wheel, in case of issue, there is only one
243+
place to investigate: the build backend.
244+
245+
With PEP 662, issues need to be investigated in the frontend,
246+
the backend and possiblty the specification. There is also a high probability
247+
that different frontends, implementing the specification in different ways,
248+
will produce installations that behave differently than project authors
249+
intended, creating confusion, or worse, projects that only work with specific
250+
frontends or IDEs.
251+
252+
Unpacked wheel
253+
--------------
254+
255+
A `prototype <https://github.com/pypa/pip/pull/8154/files>`_ was made that
256+
created an unpacked wheel in a temporary directory, to be copied to the target
257+
environment by the frontend. This approach was not pursued because a wheel
258+
archive is easy to create for the backend, and using a wheel as communication
259+
mechanism is a better fit with the PEP 517 philosophy, and therefore keeps
260+
things simpler for the frontend.
261+
198262
References
199263
==========
200264

0 commit comments

Comments
 (0)