[Python-modules-team] Bug#752467: (no subject)

Marvin Renich mrvn at renich.org
Thu Mar 22 16:41:33 UTC 2018


Control: tags -1 patch

[I'm now subscribed to this bug; no need to CC me.]

On Tue, 18 Nov 2014 01:59:18 +0200 Stefano Rivera <stefanor at debian.org> wrote:
> Hi Barry (2014.11.17_22:53:01_+0200)
> > The question still remains: how best to upgrade people who have
> > /usr/bin/virtualenv provided by python-virtualenv in Wheezy, so that they now
> > get /usr/bin/virtualenv provided by virtualenv in Jessie?  Using Recommends
> > was an attempt at that, but clearly it's not good enough.
> 
> Taking a step back, I think the only way to reliably do this is to have
> virtualenv be Python2 for jessie, and change it to Python 3 in stretch.
> 
> so:
> python-virtualenv Depends virtualenv
> virtualenv Depends python-virtualenv (ick a loop. Avoidable?)
> 
> and in stretch:
> virtualenv Depends python3-virtualenv
> 
> By then, anybody using virtualenv has had the virtualenv package
> installed.

I just ran into this issue.  I am installing OctoPrint from source on a
BeagleBone Black, and OctoPrint uses python2, and I would rather not
install python3 if I can avoid it.

My (strong) opinion is that the correct solution should involve a single
/usr/bin/virtualenv command that works correctly with both python2 and
python3.  I have attached such a script (only tested with python2) based
on Brian May's suggestion to use the trick from django-admin.

Once this is done, the dependencies sort themselves out very nicely:

python-virtualenv Recommends: virtualenv
python3-virtualenv Recommends: virtualenv
virtualenv Depends: python3-virtualenv (>= someversion) | python-virtualenv (>= someversion)

virtualenv should not depend on python or python3; this will happen
transitively from the python{,3}-virtualenv dependencies.

A Depends is the correct dependency in virtualenv, because it is useless
and doesn't function unless one of the modules is installed.

A Recommends is the correct dependency in python*-virtualenv because
either can by used as a python module without the virtualenv command,
but a user would normally have the command installed as well.

Anyone with a default apt configuration (i.e. installs Recommends by
default) will upgrade correctly.  Those (like me) who don't install
Recommends by default should be looking for new Recommends when
upgrading and should be able to handle the situation.

I believe that replacing the current /usr/bin/virtualenv with the
attached script and adjusting the dependencies as described above will
allow closing this bug, and I see no downsides.

...Marvin

-------------- next part --------------
#!/bin/sh
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==15.1.0','console_scripts','virtualenv'
shell_code=''' '
# shell code
if command -v python3 > /dev/null && test -e /usr/lib/python3/dist-packages/virtualenv.py
then
    exec python3 "$0" "$@"
elif command -v python2.7 > /dev/null && test -e /usr/lib/python2.7/dist-packages/virtualenv.py
then
    exec python2.7 "$0" "$@"
else
    echo "Cannot find installed version of python-virtualenv or python3-virtualenv." >&2
    exit 1
fi

python_code='''
# python code
# ONLY use DOUBLE quotes <"> after this line
__requires__ = "virtualenv==15.1.0"
import re
import sys
from pkg_resources import load_entry_point

if __name__ == "__main__":
    sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
    sys.exit(
        load_entry_point("virtualenv==15.1.0", "console_scripts", "virtualenv")()
    )

# End of Python code. Do not modify this line. #'


More information about the Python-modules-team mailing list