Install pip by hand in virtualenv on Debian.
It seems Debian/Ubuntu don't have the ensurepip module, so Python's venv will fail unless started with --without-pip and us installing pip by hand via get-pip.py :( Related bugs: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772730 https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1290847 See #463.
This commit is contained in:
parent
2201ca600b
commit
7580473a43
@ -31,11 +31,20 @@ import subprocess
|
|||||||
import distutils.sysconfig # pylint: disable=import-error
|
import distutils.sysconfig # pylint: disable=import-error
|
||||||
# see https://bitbucket.org/logilab/pylint/issue/73/
|
# see https://bitbucket.org/logilab/pylint/issue/73/
|
||||||
import venv
|
import venv
|
||||||
|
import urllib.request
|
||||||
|
import tempfile
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
from scripts import utils
|
from scripts import utils
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ensurepip # pylint: disable=import-error
|
||||||
|
except ImportError:
|
||||||
|
# Debian-like systems don't have ensurepip...
|
||||||
|
ensurepip = None
|
||||||
|
|
||||||
|
|
||||||
g_path = None
|
g_path = None
|
||||||
g_args = None
|
g_args = None
|
||||||
|
|
||||||
@ -143,6 +152,19 @@ def link_pyqt():
|
|||||||
os.symlink(source, dest)
|
os.symlink(source, dest)
|
||||||
|
|
||||||
|
|
||||||
|
def install_pip():
|
||||||
|
"""Install pip on Debian-like systems which don't have ensurepip.
|
||||||
|
|
||||||
|
WORKAROUND for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772730 and
|
||||||
|
https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1290847
|
||||||
|
"""
|
||||||
|
utils.print_title("Installing pip/setuptools")
|
||||||
|
f = urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py')
|
||||||
|
with tempfile.NamedTemporaryFile() as tmp:
|
||||||
|
tmp.write(f.read())
|
||||||
|
venv_python(tmp.name)
|
||||||
|
|
||||||
|
|
||||||
def create_venv():
|
def create_venv():
|
||||||
"""Create a new venv."""
|
"""Create a new venv."""
|
||||||
utils.print_title("Creating venv")
|
utils.print_title("Creating venv")
|
||||||
@ -153,8 +175,11 @@ def create_venv():
|
|||||||
clear = g_args.clear or g_args.force
|
clear = g_args.clear or g_args.force
|
||||||
builder = venv.EnvBuilder(system_site_packages=False,
|
builder = venv.EnvBuilder(system_site_packages=False,
|
||||||
clear=clear, upgrade=g_args.upgrade,
|
clear=clear, upgrade=g_args.upgrade,
|
||||||
symlinks=symlinks, with_pip=True)
|
symlinks=symlinks, with_pip=ensurepip)
|
||||||
builder.create(g_path)
|
builder.create(g_path)
|
||||||
|
# If we don't have ensurepip, we have to do it by hand...
|
||||||
|
if not ensurepip:
|
||||||
|
install_pip()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -174,9 +199,6 @@ def main():
|
|||||||
|
|
||||||
create_venv()
|
create_venv()
|
||||||
|
|
||||||
utils.print_title("Installing setuptools")
|
|
||||||
venv_python('-m', 'pip', 'install', 'setuptools')
|
|
||||||
|
|
||||||
utils.print_title("Calling: setup.py develop")
|
utils.print_title("Calling: setup.py develop")
|
||||||
venv_python('setup.py', 'develop')
|
venv_python('setup.py', 'develop')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user