On Wed, Sep 2, 2020 at 20:48 Charles Machalow <csm10495@gmail.com> wrote:
I may be in the minority, but sometimes it seems like having to spin up a venv, etc. to run a small script could be a little bit much.



What if we have something like this POC I wrote: https://pypi.org/project/pyensure/



We could have a switch or python interpreter argument to have packages get auto-installed (to a temp directory) in the event that we don't have it installed in the current environment.



One of the beauties of this is that it doesn't pollute the current environment, since packages are installed to a temp directory (which is then added to sys.path).



Further optimizations (like preventing a need to redownload, import specific package versions, or fixing imports that have a dot) could be made in a more complete solution.

I think it should be the responsibility of the packager to ensure their dependencies are met. Most of the time, this is handled well enough by pip. Based on the fact that you bring this up, I guess you have faced some pain in this area. I'm sorry if that happened.

If a packager wants to make extra sure that a package can be used without any knowledge of pip, they can use a zipapp with vendored dependencies, or a pyInstaller package (see awscli 2 for one example).

Even if your pain is caused by a package you don't own, repackaging is a thing (see Pillow for one example).

Installers downloading stuff is a whole security domain. But software I want to run implicitly invoking the installer adds a layer of complexity to that domain that I think outweighs the gain.

- Michael Smith