pipx
pipx copied to clipboard
Support running & installing scripts with dependencies specified in __requires__
So pipx can run scripts specified as URLs on the command line, but it seems that they're always run in the system Python environment, with no isolation or installation of any dependencies. What would be useful would be if the script's dependencies were read from __requires__ à la pip-run and then the script was run in an isolated environment with those dependencies installed. It'd be even more useful if pipx could then permanently install a script with its dependencies, instead of keeping them around only for one run.
This would enable highly lightweight "packaging" of scripts. Instead of having to fill out a setup.py or pyproject.toml and going through all that, authors would be able to distribute single-file programs by just specifying the dependencies in __requires__ and telling their users to install with pipx.
This is a pretty cool idea. Is __requires__ a standard or is it just something pip-run made up? I took a look at pip-run's code and it wouldn't be too hard to adapt to pipx.
I was toying around with another project called importation that does runtime dependency installation like deno, but instead of searching out special variables like __requires__ it monkeypatches the import system itself. It still needs more work though.
Regarding pipx running the script not in a virtual environment, that should probably be reconsidered regardless.
__requires__ is not a standard. It originated in setuptools, and then one of the setuptools developers combined the idea with support for pip to create pip-run.
__requires__is not a standard. It originated in setuptools, and then one of the setuptools developers combined the idea with support for pip to create pip-run.