-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use uv run
to run the Python-based fuzzer
#13074
Conversation
This comment was marked as spam.
This comment was marked as spam.
|
Haha, and here is another use case asking for virtual workspace. This will make @charliermarsh so happy |
9e4337b
to
d39b034
Compare
Well... this works for the I think having a dev-dependency that's only available on newer Python versions than the one the package is declared as supporting is probably reasonable...? Hmm, but maybe if it's declared as a "virtual" workspace, uv assumes there is no package, so therefore the |
I kind of think these should just be PEP 723 scripts. Semantically, at least, that's what they want to be, right? |
I tried that at first, but I don't get the transitive dependencies pinned in the lockfile (and updated by Renovate) if I have them as PEP 723 scripts, right? We run |
Separately, why are the deps not in |
Would I have to |
Related astral-sh/uv#6733 |
Alternatively we could prioritize adding the lockfile to |
Ah, that would be the ideal solution if it's something you're considering! |
@AlexWaygood would you want it to be embedded in the script? It might be looong. |
Hrm... no, probably not! I think there's essentially two genres of single-file scripts:
These scripts definitely feel like they fit into category (2) rather than category (1). It's not like it's ever going to make sense to try to run them outside this repository, so shareability and portability aren't really important; it's okay if the lockfile gets output to a separate file, IMO. I guess the easiest way of doing that implementation-wise would be a separate lockfile for each script, since you'll probably want a separate virtual environment for each script? |
I think this should just be a project, personally. |
Summary
This converts the
scripts/fuzz-parser
script into a script runnable viauv run
.Since this is a single-file script, I considered using inline metadata here; it seemed like it might be a good fit. However, it seems as though inline dependencies aren't recorded in
uv.lock
at all, which wouldn't be ideal since we use this script in CI as a regression test. I therefore added the dependencies of the script to thepyproject.toml
in the Ruff repo root instead, which means that the dependencies are pinned in the project'suv.lock
file.Annoyingly,
uv run scripts/fuzz-parser.py
seems to build Ruff from source with this PR before it runs the script. I don't think there's any way currently to tell uv to only install the dev dependencies, and not bother with installing the project itself, when running scripts? Building Ruff from source isn't necessary with this script if you pass the--test-executable
flag. This might be a blocker for this PR? It means that theuv run
invocation takes ages to get going.I deliberately haven't tried to include any of the docs dependencies in this change, as @MichaReiser already tried in #12622, and the situation there is quite complicated with the two
requirements.txt
files.Overall this is something I'd love to do as it seems like it could be a really nice simplification... but I'm not sure it's a perfect fit right now?
Test Plan
uv run scripts/fuzz-parser.py 0-100
uv run scripts/generate_known_standard_library.py
cd scripts/knot_benchmark && uv run benchmark