Okay okay, don’t parse the AST I want to respond to a couple things and then I’ll wrap up.
In that scenario, it’s going to invoke the specified python’s own version of
pip, yes? Furthermore, it makes sure
pip is up to date. It seems like the obstacle for that working is
pip having support for parsing embedded metadata. I certainly hope that happens, regardless of what version of this idea is eventually adopted.
A performance-sensitive tool should only parse the metadata if the file changes, not on every invocation. Outside of development (when the runner isn’t even needed, really) that should be very rare, I’d think?
For that matter there is at least one very fast AST parser out there, which will continue to be updated for new syntax as it is introduced. For tools that need the performance, it’s available without invoking python.
If the tool doesn’t know up-front what version of python to use, it’s going to fail when the script runs. It’s true that this PEP has support for
requires-python but there isn’t a proposal to install a new binary as far as I can tell. So either way, this ends in an error, and the important thing is to provide a good clue to the cause (like “we found a syntaxerror, are you using the right python version?”)
I understand the concerns here, but I wanted to hear the various arguments in more detail because it didn’t feel like such an obstacle to me (mostly I was responding to Paul’s post about that section).
I’m satisfied that parsing the AST has enough thorns that it shouldn’t be required for this to work–I brought it up more because I didn’t find the arguments against it so convincing .
The main thing I was interested in was fixing the spec for
__pyproject__ so that it doesn’t become a pseudo-TOML, and users can freely copy between real toml files and the metadata without worrying about breaking formatting. I hope that can be done with better parsing. A short regex is nice but it doesn’t have to be the actual answer.
I still don’t think it’s that big a deal but I’m happy to defer to the tool-writers about what they think is reasonable ↩︎