Getting rid of virtual environments with a better dependency system

Peter J. Holzer hjp-python at hjp.at
Thu Nov 12 17:40:18 EST 2020


On 2020-11-12 10:56:45 +1100, Chris Angelico wrote:
> On Thu, Nov 12, 2020 at 10:44 AM Dan Stromberg <drsalists at gmail.com> wrote:
> > I do get a .../bin/backshift though, which is a bash script that
> > knows how to start up python on the main module.  So the user need
> > not source something at install time or at run time.
> >
> > The install process is ./configure and make install, where
> > ./configure is Not autoconf, but acts sort of like an autoconf
> > script.
> >
> 
> Ah, fair enough.
> 
> Did you know that, with a vanilla venv, you can actually just run a
> Python interpreter from within there, without sourcing anything? Very
> handy for automated scripts.

This also works with the Python interpreter in the shebang line. 

So if your "make install" for "mytool" creates a venv in
/usr/local/lib/mytool/venv and then replaces the shebang in
/usr/local/bin/mytool with "#!/usr/local/lib/mytool/venv/python", the
user can just invoke "mytool" without caring about the virtual
environment.

If you do that for every Python script, size may be a problem, though: I
just checked a few of my venvs, and they are between 13 and 418 MB:
Average 81 MB. 

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20201112/c0e96604/attachment.sig>


More information about the Python-list mailing list