4 ms·
The idea is as follows: * A recently-published PEP specificies how Python scripts can declare dependencies in opening comments. * uv is a Python script-runner
by einpoklum 2y ago
The idea is as follows:
* A recently-published PEP specificies how Python scripts can declare dependencies in opening comments.
* uv is a Python script-runner/package manager which scans for those dependencies, arranges for them to be met, and runs the script with those dependency modules available for importing
* If, in a Python script, you use the first line comment - the shebang line - to have the file invoked using uv rather than python itself, you'll get that effect automagically when "running" the Python script
The result: Python scripts which require setup of dependencies will now "just run".
- bityard 2y ago(If you have `uv` installed in your $PATH.) Also, uv will install the dependencies, but I am not clear on whether or not it will automatically install a Python interpreter for you using this method.
- kjkjadksj 2y agoWill now “just run” after you satisfied the dependency of installing uv on your system and prepending these dependency lines to all your scripts, that is. Imo this saves you no time over just constructing and calling environments the old way. I’m not sure either whether uv lets you load the env only in an interactive session or if its just for script running.
- einpoklum 2y agoI'll first day I'm not a proponent of uv, I just read the post and tried to clarify what it says... but I think what it saves you is the trouble of setting up a virtual environment the "old" way. So, it's about making things easier, not faster.
- fastasucan 2y agoOfcourse it does, after you have installed uv and prepending the dependencies you never have to do it again. Calling environments etc have to be done every time. You also have to keep these env around.
- kjkjadksj 2y agoYou could easily wrap something that activates an env as the relevant script is called. And you can just store the env in text and build as needed too.