Skip to content

chore: add PEP 723 metadata for various bin/ scripts, drop bin dependency group#2819

Open
agriyakhetarpal wants to merge 12 commits intopypa:mainfrom
agriyakhetarpal:pep-723-metadata-for-scripts
Open

chore: add PEP 723 metadata for various bin/ scripts, drop bin dependency group#2819
agriyakhetarpal wants to merge 12 commits intopypa:mainfrom
agriyakhetarpal:pep-723-metadata-for-scripts

Conversation

@agriyakhetarpal
Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal commented Apr 10, 2026

See #2816 (comment). This PR adds inline script metadata for all our scripts. Some scripts import cibuildwheel, and not all of these scripts need such metadata because they run within a nox session that installs the bin dependency group. Still, it's nice to see all the dependencies up top from a quick look :)

I had to move the Playwright Chromium installation to a subprocess, which is a bit hacky, but it works all well. I regenerated the image, wherein I realised that Playwright does the exact same thing I did in #2815 (capture a screenshot of the node), except the difference is the font. My macOS machine uses Helvetica Neue, while this one looks like a different one (DejaVu Sans? Not sure). I kinda like this one better!

Edit: I restored the image with what we have on main, as suggested.

Copy link
Copy Markdown
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

Some of the nox sessions install script deps themselves too, for example update_constraints installs click, that can probably also be DRY'd up with a call to install_and_run_script. Maybe that's the only example actually...

agriyakhetarpal and others added 5 commits April 11, 2026 00:15
Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-Authored-By: Joe Rickerby <1244307+joerick@users.noreply.github.com>
@agriyakhetarpal
Copy link
Copy Markdown
Member Author

Locally, the session went from 50 seconds to 6 seconds (nice!):

nox > Running session update_how_it_works_image
nox > Creating virtual environment (uv) using python in .nox/update_how_it_works_image
nox > uv pip install playwright
nox > python bin/update_how_it_works_image.py
nox > Session update_how_it_works_image was successful in 6 seconds.

I restored the image with what we have on main, though, as suggested.

noxfile.py Outdated

nox.needs_version = ">=2025.2.9"
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.default_venv_backend = "uv"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I suppose it's okay to make uv the default, since it's the runner that we are going to use for PEP 723 going forward. Also, we're at 0.9.18 now, so 0.1.23 was pretty old!

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.

This means that a user running our noxfile must have uv installed. And we don't use uv to run it, we use nox (install_and_run_script)? <any PEP 723 runner> script.py works, the shabang is only for what is needed for ./script.py.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, I thought nox was delegating to uv for its PEP 723 runner implementation, instead of having its own. Thanks for the correction!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd prefer that people use uv for the bin scripts, though, or run them through nox. Unless you feel otherwise, or if there's a better way.

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.

If they use ./script.py, sure, but they can use whatever they want if they run it themselves.

@agriyakhetarpal agriyakhetarpal changed the title Add PEP 723 metadata for various bin scripts, regenerate platforms image chore: add PEP 723 metadata for various bin/ scripts, drop bin dependency group Apr 10, 2026
@henryiii
Copy link
Copy Markdown
Contributor

FWIW, I generally keep setup-python, as it's faster than uv on non-EoL Pythons since python is already installed on the runners, and not installing (<1 second) is faster than installing, even if uv is fast at installing (8 seconds on Windows).

@henryiii
Copy link
Copy Markdown
Contributor

Also setup-python installs universal macOS binaries, while uv doesn't.

@agriyakhetarpal
Copy link
Copy Markdown
Member Author

Thanks, I didn't know about that. Reverted!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants