3 ms·
What are the reasons that Python can't implement the same sort of module/packaging system as NodeJS? That seems to work well enough. Executing a Python script
by russellbeattie 1y ago
What are the reasons that Python can't implement the same sort of module/packaging system as NodeJS? That seems to work well enough.
Executing a Python script in the same directory as some sort of project.json file that contains all the complicated dependency details would be a pretty good solution to me. But I'm probably missing a whole bunch of details. (Feel free to educate me).
In general I really dislike the current system of having to use new environment variables in a new session in order to isolate Py scripts. It has always seemed like a hack with lots of footguns. Especially if you forget which console is open.
- kouteiheika 1y agoIt can. That's what uv is. Put an '#!/usr/bin/env -S uv run python' shebang in your script, add a `pyproject.toml` with all of your deps, and you're done.
- dwattttt 1y ago> add a `pyproject.toml` with all of your deps Or put your dependencies inline in the script (https://packaging.python.org/en/latest/specifications/inline-script-metadata/ https://packaging.python.org/en/latest/specifications/inline...), and it's just a single file script again. But with dependency support EDIT to clarify it was just the pyproject.toml that inline metadata could replace
- russellbeattie 1y agoAgain, you're creating a new session with special environmental variables. It's nice that it uses pyproject.toml (well, except for the toml part), but it still needs uv. I was suggesting that the Python executable have this sort of functionality built in, with no need for a new session.