Commit 221d6a16 authored by Freedesktop SDK Merge Bot's avatar Freedesktop SDK Merge Bot

Merge branch 'nanonyme/really-fix-python3-pip' into '18.08'

Properly fix Python3 pip

See merge request !1310
parents 85bcceef 7101034b
Pipeline #62518719 passed with stages
in 42 minutes and 14 seconds
......@@ -6,11 +6,11 @@ depends:
config:
install-commands:
- |
install -m 644 -D python2-sitecustomize.py "%{install-root}%{indep-libdir}/python2.7/sitecustomize.py"
install -m 644 -D python3-sitecustomize.py "%{install-root}%{indep-libdir}/python2.7/sitecustomize.py"
python2 -m compileall "%{install-root}%{indep-libdir}/python2.7/sitecustomize.py"
python2 -O -m compileall "%{install-root}%{indep-libdir}/python2.7/sitecustomize.py"
python2 -OO -m compileall "%{install-root}%{indep-libdir}/python2.7/sitecustomize.py"
sources:
- kind: local
path: files/python2-sitecustomize.py
path: files/python3-sitecustomize.py
import sys
import site
import os
import sysconfig
old_user_site = os.path.abspath(site.USER_SITE)
site.USER_SITE = None
site.USER_BASE = os.environ.setdefault("PYTHONUSERBASE", "/var/data/python")
sysconfig._CONFIG_VARS = None
site.USER_SITE = site.getusersitepackages()
old_index = sys.path.index(old_user_site)
sys.path.remove(old_user_site)
sys.path.insert(old_index, os.path.abspath(site.USER_SITE))
......@@ -2,15 +2,15 @@ import sys
import site
import os
old_user_site = os.path.abspath(site.USER_SITE)
try:
old_index = sys.path.index(old_user_site)
except ValueError:
# Unknon what causes this but let's not do anything if this happens
getusersitepackages = site.getusersitepackages
except AttributeError:
# Probably virtualenv. Don't do anything
pass
else:
old_user_site = getusersitepackages()
site.USER_BASE = os.environ.get("PYTHONUSERBASE", "/var/data/python")
sys.path.remove(old_user_site)
site.USER_SITE = None
sys.path.insert(old_index, site.getusersitepackages())
site.USER_SITE = getusersitepackages()
sys.path = [item for item in sys.path if not item.startswith(old_user_site)]
site.addusersitepackages(site.removeduppaths())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment