Skip to content

Commit 06526e7

Browse files
committed
pip-micropython: Apply more workarounds for setuptools, pip, etc misfeatures.
1 parent 82c7b1b commit 06526e7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tools/pip-micropython

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ fi
3030
# installed if it's already installed for main python distribution.
3131
if [ ! -d /tmp/pip-micropy-venv ]; then
3232
virtualenv --no-site-packages /tmp/pip-micropy-venv
33+
# distutils, setuptools, pip are buggy and allow target packages affect
34+
# their execution environment. For example, if distribution they install
35+
# has re.py, they will import that instead of system re. So, we need
36+
# to remove current dir from sys.path, but that appear to be quite uneasy
37+
# with CPython, so we hook __import__ and exterminate it persistently.
38+
# See also https://bitbucket.org/pypa/setuptools/issue/187/
39+
cat > $(ls -1d /tmp/pip-micropy-venv/lib/python*/)/sitecustomize.py <<EOF
40+
import sys
41+
import __builtin__
42+
old_imp = __import__
43+
def new_imp(*a, **kw):
44+
if not sys.path[0]: sys.path.pop(0)
45+
return old_imp(*a, **kw)
46+
__builtin__.__import__ = new_imp
47+
EOF
3348
fi
3449
. /tmp/pip-micropy-venv/bin/activate
3550

0 commit comments

Comments
 (0)