Making sure that python and pip are the ones we expect
This commit is contained in:
+14
-6
@@ -63,17 +63,25 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
mkdir /output
|
mkdir /output
|
||||||
cd /project
|
cd /project
|
||||||
|
|
||||||
|
for PYBIN in {pybin_paths}; do (
|
||||||
|
# Temporary hack/workaround, putting loop body in subshell; fixed in PR #256
|
||||||
|
|
||||||
|
export PATH="$PYBIN:$PATH"
|
||||||
{environment_exports}
|
{environment_exports}
|
||||||
|
|
||||||
for PYBIN in {pybin_paths}; do
|
# check the active python and pip are in PYBIN
|
||||||
|
# if `test` returns false, the script will exit due to errexit
|
||||||
|
test "$(which pip)" = "$PYBIN/pip"
|
||||||
|
test "$(which python)" = "$PYBIN/python"
|
||||||
|
|
||||||
if [ ! -z {before_build} ]; then
|
if [ ! -z {before_build} ]; then
|
||||||
PATH="$PYBIN:$PATH" sh -c {before_build}
|
sh -c {before_build}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the wheel
|
# Build the wheel
|
||||||
rm -rf /tmp/built_wheel
|
rm -rf /tmp/built_wheel
|
||||||
mkdir /tmp/built_wheel
|
mkdir /tmp/built_wheel
|
||||||
PATH="$PYBIN:$PATH" "$PYBIN/pip" wheel . -w /tmp/built_wheel --no-deps {build_verbosity_flag}
|
pip wheel . -w /tmp/built_wheel --no-deps {build_verbosity_flag}
|
||||||
built_wheel=(/tmp/built_wheel/*.whl)
|
built_wheel=(/tmp/built_wheel/*.whl)
|
||||||
|
|
||||||
# repair the wheel
|
# repair the wheel
|
||||||
@@ -92,9 +100,9 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
if [ ! -z {test_command} ]; then
|
if [ ! -z {test_command} ]; then
|
||||||
# Set up a virtual environment to install and test from, to make sure
|
# Set up a virtual environment to install and test from, to make sure
|
||||||
# there are no dependencies that were pulled in at build time.
|
# there are no dependencies that were pulled in at build time.
|
||||||
"$PYBIN/pip" install virtualenv
|
pip install virtualenv
|
||||||
venv_dir=`mktemp -d`/venv
|
venv_dir=`mktemp -d`/venv
|
||||||
"$PYBIN/python" -m virtualenv "$venv_dir"
|
python -m virtualenv "$venv_dir"
|
||||||
|
|
||||||
# run the tests in a subshell to keep that `activate`
|
# run the tests in a subshell to keep that `activate`
|
||||||
# script from polluting the env
|
# script from polluting the env
|
||||||
@@ -133,7 +141,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
# we're all done here; move it to output
|
# we're all done here; move it to output
|
||||||
mv "${{repaired_wheels[@]}}" /output
|
mv "${{repaired_wheels[@]}}" /output
|
||||||
for repaired_wheel in "${{repaired_wheels[@]}}"; do chown {uid}:{gid} "/output/$(basename "$repaired_wheel")"; done
|
for repaired_wheel in "${{repaired_wheels[@]}}"; do chown {uid}:{gid} "/output/$(basename "$repaired_wheel")"; done
|
||||||
done
|
) done
|
||||||
'''.format(
|
'''.format(
|
||||||
pybin_paths=' '.join(c.path + '/bin' for c in platform_configs),
|
pybin_paths=' '.join(c.path + '/bin' for c in platform_configs),
|
||||||
test_requires=' '.join(test_requires),
|
test_requires=' '.join(test_requires),
|
||||||
|
|||||||
@@ -137,11 +137,15 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
# check what version we're on
|
# check what version we're on
|
||||||
call(['which', 'python'], env=env)
|
call(['which', 'python'], env=env)
|
||||||
call(['python', '--version'], env=env)
|
call(['python', '--version'], env=env)
|
||||||
|
# TODO Cleanup/merge with above `call` once we have `subprocess.run` after dropping Python 2 support?
|
||||||
|
assert subprocess.check_output(['which', 'python'], env=env, universal_newlines=True).strip() == '/tmp/cibw_bin/python'
|
||||||
|
|
||||||
# install pip & wheel
|
# install pip & wheel
|
||||||
call(['python', get_pip_script], env=env, cwd="/tmp")
|
call(['python', get_pip_script], env=env, cwd="/tmp")
|
||||||
assert os.path.exists(os.path.join(installation_bin_path, 'pip'))
|
assert os.path.exists(os.path.join(installation_bin_path, 'pip'))
|
||||||
call(['pip', '--version'], env=env)
|
call(['pip', '--version'], env=env)
|
||||||
|
# TODO Cleanup/merge with above `call` once we have `subprocess.run` after dropping Python 2 support?
|
||||||
|
assert subprocess.check_output(['which', 'pip'], env=env, universal_newlines=True).strip() == '/tmp/cibw_bin/pip'
|
||||||
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'], env=env)
|
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'], env=env)
|
||||||
|
|
||||||
# setup target platform, only required for python 3.5
|
# setup target platform, only required for python 3.5
|
||||||
|
|||||||
@@ -141,11 +141,15 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
simple_shell(['where', 'python'], env=env)
|
simple_shell(['where', 'python'], env=env)
|
||||||
simple_shell(['python', '--version'], env=env)
|
simple_shell(['python', '--version'], env=env)
|
||||||
simple_shell(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)"'], env=env)
|
simple_shell(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)"'], env=env)
|
||||||
|
# TODO Cleanup/merge with above `simple_shell` once we have `subprocess.run` after dropping Python 2 support?
|
||||||
|
assert subprocess.check_output(['where', 'python'], env=env, universal_newlines=True).splitlines()[0] == os.path.join(installation_path, 'python.exe')
|
||||||
|
|
||||||
# make sure pip is installed
|
# make sure pip is installed
|
||||||
if not os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe')):
|
if not os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe')):
|
||||||
simple_shell(['python', get_pip_script], env=env, cwd="C:\\cibw")
|
simple_shell(['python', get_pip_script], env=env, cwd="C:\\cibw")
|
||||||
assert os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe'))
|
assert os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe'))
|
||||||
|
# TODO Cleanup/merge with above `simple_shell` once we have `subprocess.run` after dropping Python 2 support?
|
||||||
|
assert subprocess.check_output(['where', 'pip'], env=env, universal_newlines=True).splitlines()[0] == os.path.join(installation_path, 'Scripts', 'pip.exe')
|
||||||
|
|
||||||
# prepare the Python environment
|
# prepare the Python environment
|
||||||
simple_shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env)
|
simple_shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env)
|
||||||
|
|||||||
Reference in New Issue
Block a user