Skip to content

ENH: implement editable loader with PEP 829 .start files - #881

Merged
rgommers merged 1 commit into
mesonbuild:mainfrom
dnicolodi:implement-pep829
Aug 25, 2026
Merged

ENH: implement editable loader with PEP 829 .start files#881
rgommers merged 1 commit into
mesonbuild:mainfrom
dnicolodi:implement-pep829

Conversation

@dnicolodi

Copy link
Copy Markdown
Member

on Python 3.15 and later. Editable wheels are Python version specific, thus there is no need to write both a .pth and a .start file for Python versions that support the latter.

Editable wheels implemented with .pth files just imported the implementation module and relied on the execution of the module body on import for the installation of the module loader. PEP 829 .start files need to specify a callable that takes no arguments. To keep the difference between .pth and .start file implementations to a minimum, define such callable in the implementation module and switch the .pth file to explicitly call it.

Fixes #846

@rgommers rgommers added the enhancement New feature or request label Aug 24, 2026

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dnicolodi. This LGTM, and it seems to work as advertised. One tiny stylistic comment.

I considered the "ship both" vs. "gate on >=3.15" - both are defensible, so happy to go with your preference here.

I also considered whether this needs more test coverage. A small test that actually checks whether .start is present and .pth is not could be added, however the current editable tests cover perfectly well that things are working and the chance that we'll regress to shipping a .pth file seems quite low, so it's fine as is.

Should be good to merge as is, or after addressing the small style comment.

Comment thread mesonpy/__init__.py Outdated
@dnicolodi

Copy link
Copy Markdown
Member Author

A small test that actually checks whether .start is present and .pth is not could be added

I hesitated adding this test when I implemented the PR. Given that you had the same instinct, I added it.

Should be good to merge as is, or after addressing the small style comment.

I went for a small refactoring that removed the indirection through the install() function. PTAL

@rgommers rgommers added this to the v0.21.0 milestone Aug 24, 2026

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring LGTM. One other very minor comment around readability. The commit message of the second commit is incomplete, so it needs squashing.

Comment thread tests/test_editable.py Outdated
def test_editable_contents(editable_simple):
artifact = wheel.wheelfile.WheelFile(editable_simple)

impl = 'start' if sys.version_info > (3, 15) else 'pth'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> (3, 15) is actually correct, but I had to do a double take here; >= (3, 15) behaves identically and matches the implementation and intuition better, so I'd change it to that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is practically correct but semantically incorrect.

Given that there is never actually a 3.15 release, only a 3.15.0 release, comparing this as a tuple of ints instead of as an "abstract version number" will always see the side with trailing bits as greater. However technically it is wrong to assume that you're checking for "at least patchlevel greater than <omitted argument>" (even NULL is sorta ironically not a good fit to model this case), quite aside from the intuition aspect.

on Python 3.15 and later. Editable wheels are Python version specific,
thus there is no need to write both a .pth and a .start file for
Python versions that support the latter.

Editable wheels implemented with .pth files just imported the
implementation module and relied on the execution of the module body
on import for the installation of the module loader.  PEP 829 .start
files need to specify a callable that takes no arguments. To keep the
difference between .pth and .start file implementations to a minimum,
define such callable in the implementation module and switch the .pth
file to explicitly call it.

Fixes mesonbuild#846
@rgommers
rgommers merged commit 3333005 into mesonbuild:main Aug 25, 2026
35 checks passed
@dnicolodi

Copy link
Copy Markdown
Member Author

One other very minor comment around readability.

That was actually a typo.

The commit message of the second commit is incomplete, so it needs squashing.

And I fat fingered something to get the silly commit message, the intention was fixup the previous commit.

Thanks for the review and for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update editable install support for PEP 829 (.start files)

3 participants