News for hackers. Stuff that matters.
Re:Python and manually creating the requirements.txt vs. pip... by bestcoder69 on Wednesday August 17, 2022 @08:04AM (#32495143)
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?

Re:Python and manually creating the requirements.txt vs. pip... by robinweiss on Wednesday August 17, 2022 @08:57AM (#32495694)
This ... 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.
Re:Python and manually creating the requirements.txt vs. pip... by tracnar on Wednesday August 17, 2022 @09:10AM (#32495857)
It's a thing with the nix package manager:

https://github.com/clhodapp/nix-runner