Merge pull request #307 from Czaki/setup_python_separate

Setup python extracted from build function
This commit is contained in:
Joe Rickerby
2020-04-07 18:24:55 +01:00
committed by GitHub
3 changed files with 114 additions and 96 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ build: off
init: init:
- cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH%
install: python -m pip install -r requirements-dev.txt install: python -m pip install --retries 3 -r requirements-dev.txt
# the '-u' flag is required so the output is in the correct order. # the '-u' flag is required so the output is in the correct order.
# See https://github.com/joerick/cibuildwheel/pull/24 for more info. # See https://github.com/joerick/cibuildwheel/pull/24 for more info.
+28 -20
View File
@@ -108,19 +108,11 @@ def install_pypy(version, url):
return installation_bin_path return installation_bin_path
def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints): def setup_python(python_configuration, dependency_constraint_flags, environment):
abs_project_dir = os.path.abspath(project_dir) if python_configuration.identifier.startswith('cp'):
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') installation_bin_path = install_cpython(python_configuration.version, python_configuration.url)
built_wheel_dir = os.path.join(temp_dir, 'built_wheel') elif python_configuration.identifier.startswith('pp'):
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel') installation_bin_path = install_pypy(python_configuration.version, python_configuration.url)
python_configurations = get_python_configurations(build_selector)
for config in python_configurations:
if config.identifier.startswith('cp'):
installation_bin_path = install_cpython(config.version, config.url)
elif config.identifier.startswith('pp'):
installation_bin_path = install_pypy(config.version, config.url)
else: else:
raise ValueError("Unknown Python implementation") raise ValueError("Unknown Python implementation")
@@ -148,12 +140,6 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr) print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr)
exit(1) exit(1)
dependency_constraint_flags = []
if dependency_constraints:
dependency_constraint_flags = [
'-c', dependency_constraints.get_for_python_version(config.version)
]
# install pip & wheel # install pip & wheel
call(['python', get_pip_script] + dependency_constraint_flags, env=env, cwd="/tmp") call(['python', get_pip_script] + dependency_constraint_flags, 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'))
@@ -166,7 +152,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'] + dependency_constraint_flags, env=env) call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'] + dependency_constraint_flags, env=env)
# setup target platform, only required for python 3.5 # setup target platform, only required for python 3.5
if config.version == '3.5': if python_configuration.version == '3.5':
if '_PYTHON_HOST_PLATFORM' not in env: if '_PYTHON_HOST_PLATFORM' not in env:
# cross-compilation platform override # cross-compilation platform override
env['_PYTHON_HOST_PLATFORM'] = 'macosx-10.9-x86_64' env['_PYTHON_HOST_PLATFORM'] = 'macosx-10.9-x86_64'
@@ -176,6 +162,28 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
if 'MACOSX_DEPLOYMENT_TARGET' not in env: if 'MACOSX_DEPLOYMENT_TARGET' not in env:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.9' env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
return env
def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints):
abs_project_dir = os.path.abspath(project_dir)
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
python_configurations = get_python_configurations(build_selector)
for config in python_configurations:
dependency_constraint_flags = []
if dependency_constraints:
dependency_constraint_flags = [
'-c', dependency_constraints.get_for_python_version(config.version)
]
env = setup_python(config, dependency_constraint_flags, environment)
# run the before_build command # run the before_build command
if before_build: if before_build:
before_build_prepared = prepare_command(before_build, project=abs_project_dir) before_build_prepared = prepare_command(before_build, project=abs_project_dir)
+32 -22
View File
@@ -89,23 +89,15 @@ def install_pypy(version, arch, url):
return installation_path return installation_path
def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints): def setup_python(python_configuration, dependency_constraint_flags, environment):
abs_project_dir = os.path.abspath(project_dir)
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
# install nuget as best way to provide python
nuget = 'C:\\cibw\\nuget.exe' nuget = 'C:\\cibw\\nuget.exe'
if not os.path.exists(nuget):
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget) download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)
python_configurations = get_python_configurations(build_selector) if python_configuration.identifier.startswith('cp'):
for config in python_configurations: installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget)
# install Python elif python_configuration.identifier.startswith('pp'):
if config.identifier.startswith('cp'): installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url)
installation_path = install_cpython(config.version, config.arch, nuget)
elif config.identifier.startswith('pp'):
installation_path = install_pypy(config.version, config.arch, config.url)
else: else:
raise ValueError("Unknown Python implementation") raise ValueError("Unknown Python implementation")
@@ -113,8 +105,8 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
# set up PATH and environment variables for run_with_env # set up PATH and environment variables for run_with_env
env = os.environ.copy() env = os.environ.copy()
env['PYTHON_VERSION'] = config.version env['PYTHON_VERSION'] = python_configuration.version
env['PYTHON_ARCH'] = config.arch env['PYTHON_ARCH'] = python_configuration.arch
env['PATH'] = os.pathsep.join([ env['PATH'] = os.pathsep.join([
installation_path, installation_path,
os.path.join(installation_path, 'Scripts'), os.path.join(installation_path, 'Scripts'),
@@ -132,12 +124,6 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr) print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr)
exit(1) exit(1)
dependency_constraint_flags = []
if dependency_constraints:
dependency_constraint_flags = [
'-c', dependency_constraints.get_for_python_version(config.version)
]
# 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')):
shell(['python', get_pip_script] + dependency_constraint_flags, env=env, cwd="C:\\cibw") shell(['python', get_pip_script] + dependency_constraint_flags, env=env, cwd="C:\\cibw")
@@ -152,6 +138,30 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
shell(['pip', '--version'], env=env) shell(['pip', '--version'], env=env)
shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'] + dependency_constraint_flags, env=env) shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'] + dependency_constraint_flags, env=env)
return env
def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints):
abs_project_dir = os.path.abspath(project_dir)
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
# install nuget as best way to provide python
nuget = 'C:\\cibw\\nuget.exe'
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)
python_configurations = get_python_configurations(build_selector)
for config in python_configurations:
dependency_constraint_flags = []
if dependency_constraints:
dependency_constraint_flags = [
'-c', dependency_constraints.get_for_python_version(config.version)
]
# install Python
env = setup_python(config, dependency_constraint_flags, environment)
# run the before_build command # run the before_build command
if before_build: if before_build:
before_build_prepared = prepare_command(before_build, project=abs_project_dir) before_build_prepared = prepare_command(before_build, project=abs_project_dir)