Pip.wtf: Inline dependencies for small Python scripts
1–10 of 13 posts
Re: Pip.wtf: Inline dependencies for small Python scripts
#2Now someone upload it to pypi for even more hilarity.
Re: Pip.wtf: Inline dependencies for small Python scripts
#3Re: Pip.wtf: Inline dependencies for small Python scripts
#4I was going to mention that an official solution to this problem is around the corner, but the corresponding PEP has been rejected. Anyone know what happened there? https://peps.python.org/pep-0722/
Re: Pip.wtf: Inline dependencies for small Python scripts
#5Cool. I'm surprised this didn't exist earlier. Now someone upload it to pypi for even more hilarity.
Re: Pip.wtf: Inline dependencies for small Python scripts
#6I was going to mention that an official solution to this problem is around the corner, but the corresponding PEP has been rejected. Anyone know what happened there? https://peps.python.org/pep-0722/
Looks like https://peps.python.org/pep-0723/ was accepted instead. See discussion here: https://discuss.python.org/t/pep-722-723-decision/36763
# /// pyproject
# [run]
# requires-python = ">=3.11"
# dependencies = [
# "requestsRe: Pip.wtf: Inline dependencies for small Python scripts
#7In your script example.py, you would specify your dependencies in a special comment like this:
# Requirements:
# requests
import requests
...
Then you could run the script like this: pipx run file:example.py
This would install the dependencies in a temporary virtual environment, and run the script in that virtual environment.Re: Pip.wtf: Inline dependencies for small Python scripts
#8Re: Pip.wtf: Inline dependencies for small Python scripts
#9Cool. I'm surprised this didn't exist earlier. Now someone upload it to pypi for even more hilarity.
There was (and is) no reason for it to exist since python supports running .zip files that contain all the dependencies.