4 ms·
Tangentially related, I came up with something atrocious last night. If you install pex with pipx (or put pex in $PATH another way), you can declare your pytho
by bestcoder69 4y ago
Tangentially related, I came up with something atrocious last night.
If you install pex with pipx (or put pex in $PATH another way), you can declare your python script dependencies in the shebang line, like:
#!/usr/bin/env pex requests==2.28.1 other_dep=1.2.3 --exe
import requests
def main():
...
Then, you can `chmod +x` your script and call it with "--" between the script name and your arguments, if any:
./main.py -- arg1 arg2
Requests will be installed the first time you run it, then pex should use its cache for subsequent invocations.
I wonder if anyone's done this in earnest?
- robinweiss 4y agoThis ... I don't know what to say :D I guess I have to thank you, this helps me see the bigger picture and not be too hung up on the manual requirements.txt files of my colleagues. Things truly could be worse.
- tracnar 4y agoIt's a thing with the nix package manager: https://github.com/clhodapp/nix-runner https://github.com/clhodapp/nix-runner