Add log steps to macOS/Windows

This commit is contained in:
Joe Rickerby
2020-11-13 16:30:35 +00:00
parent 246aa0848e
commit 38297e6663
4 changed files with 226 additions and 186 deletions
+1 -3
View File
@@ -1,4 +1,3 @@
from cibuildwheel.logger import Logger
import platform import platform
import subprocess import subprocess
import sys import sys
@@ -8,6 +7,7 @@ from pathlib import Path, PurePath
from typing import List, NamedTuple, Union from typing import List, NamedTuple, Union
from .docker_container import DockerContainer from .docker_container import DockerContainer
from .logger import log
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError, from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
get_build_verbosity_extra_flags, prepare_command) get_build_verbosity_extra_flags, prepare_command)
@@ -112,8 +112,6 @@ def build(options: BuildOptions) -> None:
container_package_dir = container_project_path / abs_package_dir.relative_to(cwd) container_package_dir = container_project_path / abs_package_dir.relative_to(cwd)
container_output_dir = PurePath('/output') container_output_dir = PurePath('/output')
log = Logger()
for implementation, platform_tag, docker_image in platforms: for implementation, platform_tag, docker_image in platforms:
platform_configs = [c for c in python_configurations if c.identifier.startswith(implementation) and c.identifier.endswith(platform_tag)] platform_configs = [c for c in python_configurations if c.identifier.startswith(implementation) and c.identifier.endswith(platform_tag)]
if not platform_configs: if not platform_configs:
+9 -2
View File
@@ -1,7 +1,7 @@
import os import os
import time
import sys
import re import re
import sys
import time
from typing import Optional, Union from typing import Optional, Union
DEFAULT_FOLD_PATTERN = ('{name}', '') DEFAULT_FOLD_PATTERN = ('{name}', '')
@@ -142,6 +142,13 @@ class Logger:
return colors_disabled return colors_disabled
'''
Global instance of the Logger.
'''
# (there's only one stdout per-process, so a global instance is justified)
log = Logger()
def build_description_from_identifier(identifier: str): def build_description_from_identifier(identifier: str):
python_identifier, _, platform_identifier = identifier.partition('-') python_identifier, _, platform_identifier = identifier.partition('-')
+101 -84
View File
@@ -9,9 +9,10 @@ from pathlib import Path
from typing import Dict, List, NamedTuple, Optional, Sequence, Union from typing import Dict, List, NamedTuple, Optional, Sequence, Union
from .environment import ParsedEnvironment from .environment import ParsedEnvironment
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError, download, from .logger import log
get_build_verbosity_extra_flags, get_pip_script, from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
prepare_command, install_certifi_script) download, get_build_verbosity_extra_flags, get_pip_script,
install_certifi_script, prepare_command)
def call(args: Union[str, Sequence[Union[str, PathLike]]], env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None, shell: bool = False) -> int: def call(args: Union[str, Sequence[Union[str, PathLike]]], env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None, shell: bool = False) -> int:
@@ -116,13 +117,18 @@ def install_pypy(version: str, url: str) -> Path:
def setup_python(python_configuration: PythonConfiguration, def setup_python(python_configuration: PythonConfiguration,
dependency_constraint_flags: Sequence[Union[str, PathLike]], dependency_constraint_flags: Sequence[Union[str, PathLike]],
environment: ParsedEnvironment) -> Dict[str, str]: environment: ParsedEnvironment) -> Dict[str, str]:
if python_configuration.identifier.startswith('cp'): implementation_id = python_configuration.identifier.split("-")[0]
log.step(f'Installing Python {implementation_id}...')
if implementation_id.startswith('cp'):
installation_bin_path = install_cpython(python_configuration.version, python_configuration.url) installation_bin_path = install_cpython(python_configuration.version, python_configuration.url)
elif python_configuration.identifier.startswith('pp'): elif implementation_id.startswith('pp'):
installation_bin_path = install_pypy(python_configuration.version, python_configuration.url) installation_bin_path = install_pypy(python_configuration.version, python_configuration.url)
else: else:
raise ValueError("Unknown Python implementation") raise ValueError("Unknown Python implementation")
log.step('Setting up build environment...')
env = os.environ.copy() env = os.environ.copy()
env['PATH'] = os.pathsep.join([ env['PATH'] = os.pathsep.join([
str(SYMLINKS_DIR), str(SYMLINKS_DIR),
@@ -156,7 +162,6 @@ def setup_python(python_configuration: PythonConfiguration,
if which_pip != '/tmp/cibw_bin/pip': if which_pip != '/tmp/cibw_bin/pip':
print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) print("cibuildwheel: pip 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 pip above it.", file=sys.stderr)
exit(1) exit(1)
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate', *dependency_constraint_flags], env=env)
# Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it. # Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it.
# CPython 3.5 defaults to 10.6, and pypy defaults to 10.7, causing # CPython 3.5 defaults to 10.6, and pypy defaults to 10.7, causing
@@ -170,6 +175,9 @@ def setup_python(python_configuration: PythonConfiguration,
# https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260 # https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260
env.setdefault('ARCHFLAGS', '-arch x86_64') env.setdefault('ARCHFLAGS', '-arch x86_64')
log.step('Installing build tools...')
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate', *dependency_constraint_flags], env=env)
return env return env
@@ -178,102 +186,111 @@ def build(options: BuildOptions) -> None:
built_wheel_dir = temp_dir / 'built_wheel' built_wheel_dir = temp_dir / 'built_wheel'
repaired_wheel_dir = temp_dir / 'repaired_wheel' repaired_wheel_dir = temp_dir / 'repaired_wheel'
if options.before_all: try:
env = options.environment.as_dictionary(prev_environment=os.environ) if options.before_all:
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir) log.step('Running before_all...')
call([before_all_prepared], shell=True, env=env) env = options.environment.as_dictionary(prev_environment=os.environ)
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
call([before_all_prepared], shell=True, env=env)
python_configurations = get_python_configurations(options.build_selector) python_configurations = get_python_configurations(options.build_selector)
for config in python_configurations: for config in python_configurations:
dependency_constraint_flags: Sequence[Union[str, PathLike]] = [] log.build_start(config.identifier)
if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
]
env = setup_python(config, dependency_constraint_flags, options.environment) dependency_constraint_flags: Sequence[Union[str, PathLike]] = []
if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
]
# run the before_build command env = setup_python(config, dependency_constraint_flags, options.environment)
if options.before_build:
before_build_prepared = prepare_command(options.before_build, project='.', package=options.package_dir)
call(before_build_prepared, env=env, shell=True)
# build the wheel if options.before_build:
if built_wheel_dir.exists(): log.step('Running before_build...')
shutil.rmtree(built_wheel_dir) before_build_prepared = prepare_command(options.before_build, project='.', package=options.package_dir)
built_wheel_dir.mkdir(parents=True) call(before_build_prepared, env=env, shell=True)
# Path.resolve() is needed. Without it pip wheel may try to fetch package from pypi.org log.step('Building wheel...')
# see https://github.com/joerick/cibuildwheel/pull/369 if built_wheel_dir.exists():
call([ shutil.rmtree(built_wheel_dir)
'pip', 'wheel', built_wheel_dir.mkdir(parents=True)
options.package_dir.resolve(),
'-w', built_wheel_dir,
'--no-deps',
*get_build_verbosity_extra_flags(options.build_verbosity)
], env=env)
built_wheel = next(built_wheel_dir.glob('*.whl')) # Path.resolve() is needed. Without it pip wheel may try to fetch package from pypi.org
# see https://github.com/joerick/cibuildwheel/pull/369
call([
'pip', 'wheel',
options.package_dir.resolve(),
'-w', built_wheel_dir,
'--no-deps',
*get_build_verbosity_extra_flags(options.build_verbosity)
], env=env)
# repair the wheel built_wheel = next(built_wheel_dir.glob('*.whl'))
if repaired_wheel_dir.exists():
shutil.rmtree(repaired_wheel_dir)
repaired_wheel_dir.mkdir(parents=True)
if built_wheel.name.endswith('none-any.whl'): if repaired_wheel_dir.exists():
raise NonPlatformWheelError() shutil.rmtree(repaired_wheel_dir)
repaired_wheel_dir.mkdir(parents=True)
if options.repair_command: if built_wheel.name.endswith('none-any.whl'):
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) raise NonPlatformWheelError()
call(repair_command_prepared, env=env, shell=True)
else:
shutil.move(str(built_wheel), repaired_wheel_dir)
repaired_wheel = next(repaired_wheel_dir.glob('*.whl')) if options.repair_command:
log.step('Repairing wheel...')
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
call(repair_command_prepared, env=env, shell=True)
else:
shutil.move(str(built_wheel), repaired_wheel_dir)
if options.test_command: repaired_wheel = next(repaired_wheel_dir.glob('*.whl'))
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call(['pip', 'install', 'virtualenv', *dependency_constraint_flags], env=env)
venv_dir = Path(tempfile.mkdtemp())
# Use --no-download to ensure determinism by using seed libraries if options.test_command:
# built into virtualenv log.step('Testing wheel...')
call(['python', '-m', 'virtualenv', '--no-download', venv_dir], env=env) # set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call(['pip', 'install', 'virtualenv', *dependency_constraint_flags], env=env)
venv_dir = Path(tempfile.mkdtemp())
virtualenv_env = env.copy() # Use --no-download to ensure determinism by using seed libraries
virtualenv_env['PATH'] = os.pathsep.join([ # built into virtualenv
str(venv_dir / 'bin'), call(['python', '-m', 'virtualenv', '--no-download', venv_dir], env=env)
virtualenv_env['PATH'],
])
# check that we are using the Python from the virtual environment virtualenv_env = env.copy()
call(['which', 'python'], env=virtualenv_env) virtualenv_env['PATH'] = os.pathsep.join([
str(venv_dir / 'bin'),
virtualenv_env['PATH'],
])
if options.before_test: # check that we are using the Python from the virtual environment
before_test_prepared = prepare_command(options.before_test, project='.', package=options.package_dir) call(['which', 'python'], env=virtualenv_env)
call(before_test_prepared, env=virtualenv_env, shell=True)
# install the wheel if options.before_test:
call(['pip', 'install', str(repaired_wheel) + options.test_extras], env=virtualenv_env) before_test_prepared = prepare_command(options.before_test, project='.', package=options.package_dir)
call(before_test_prepared, env=virtualenv_env, shell=True)
# test the wheel # install the wheel
if options.test_requires: call(['pip', 'install', str(repaired_wheel) + options.test_extras], env=virtualenv_env)
call(['pip', 'install'] + options.test_requires, env=virtualenv_env)
# run the tests from $HOME, with an absolute path in the command # test the wheel
# (this ensures that Python runs the tests against the installed wheel if options.test_requires:
# and not the repo code) call(['pip', 'install'] + options.test_requires, env=virtualenv_env)
test_command_prepared = prepare_command(
options.test_command,
project=Path('.').resolve(),
package=options.package_dir.resolve()
)
call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True)
# clean up # run the tests from $HOME, with an absolute path in the command
shutil.rmtree(venv_dir) # (this ensures that Python runs the tests against the installed wheel
# and not the repo code)
test_command_prepared = prepare_command(
options.test_command,
project=Path('.').resolve(),
package=options.package_dir.resolve()
)
call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True)
# we're all done here; move it to output (overwrite existing) # clean up
shutil.move(str(repaired_wheel), options.output_dir) shutil.rmtree(venv_dir)
# we're all done here; move it to output (overwrite existing)
shutil.move(str(repaired_wheel), options.output_dir)
log.build_end()
except subprocess.CalledProcessError as error:
log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
exit(1)
+115 -97
View File
@@ -7,11 +7,13 @@ from os import PathLike
from pathlib import Path from pathlib import Path
from typing import Dict, List, NamedTuple, Optional, Sequence, Union from typing import Dict, List, NamedTuple, Optional, Sequence, Union
from zipfile import ZipFile from zipfile import ZipFile
import toml import toml
from .environment import ParsedEnvironment from .environment import ParsedEnvironment
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError, download, from .logger import log
get_build_verbosity_extra_flags, get_pip_script, from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
download, get_build_verbosity_extra_flags, get_pip_script,
prepare_command) prepare_command)
IS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists() IS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists()
@@ -109,11 +111,15 @@ def install_pypy(version: str, arch: str, url: str) -> Path:
def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: Sequence[Union[str, PathLike]], environment: ParsedEnvironment) -> Dict[str, str]: def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: Sequence[Union[str, PathLike]], environment: ParsedEnvironment) -> Dict[str, str]:
nuget = Path('C:\\cibw\\nuget.exe') nuget = Path('C:\\cibw\\nuget.exe')
if not nuget.exists(): if not nuget.exists():
log.step('Downloading 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)
if python_configuration.identifier.startswith('cp'): implementation_id = python_configuration.identifier.split("-")[0]
log.step(f'Installing Python {implementation_id}...')
if implementation_id.startswith('cp'):
installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget) installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget)
elif python_configuration.identifier.startswith('pp'): elif implementation_id.startswith('pp'):
assert python_configuration.url is not None assert python_configuration.url is not None
installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url) installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url)
else: else:
@@ -121,6 +127,8 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain
assert (installation_path / 'python.exe').exists() assert (installation_path / 'python.exe').exists()
log.step('Setting up build environment...')
# 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'] = python_configuration.version env['PYTHON_VERSION'] = python_configuration.version
@@ -151,7 +159,8 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain
print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) print("cibuildwheel: pip 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 pip above it.", file=sys.stderr)
exit(1) exit(1)
# prepare the Python environment log.step('Installing build tools...')
call(['python', '-m', 'pip', 'install', '--upgrade', 'pip', *dependency_constraint_flags], env=env) call(['python', '-m', 'pip', 'install', '--upgrade', 'pip', *dependency_constraint_flags], env=env)
call(['pip', '--version'], env=env) call(['pip', '--version'], env=env)
call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', *dependency_constraint_flags], env=env) call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', *dependency_constraint_flags], env=env)
@@ -182,6 +191,7 @@ def pep_518_cp35_workaround(package_dir: Path, env: Dict[str, str]) -> None:
) )
if requirements: if requirements:
log.step('Performing PEP518 workaround...')
with tempfile.TemporaryDirectory() as d: with tempfile.TemporaryDirectory() as d:
reqfile = Path(d) / "requirements.txt" reqfile = Path(d) / "requirements.txt"
with reqfile.open("w") as f: with reqfile.open("w") as f:
@@ -195,114 +205,122 @@ def build(options: BuildOptions) -> None:
built_wheel_dir = temp_dir / 'built_wheel' built_wheel_dir = temp_dir / 'built_wheel'
repaired_wheel_dir = temp_dir / 'repaired_wheel' repaired_wheel_dir = temp_dir / 'repaired_wheel'
# install nuget as best way to provide python try:
nuget = Path('C:\\cibw\\nuget.exe') if options.before_all:
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget) log.step('Running before_all...')
env = options.environment.as_dictionary(prev_environment=os.environ)
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
shell(before_all_prepared, env=env)
if options.before_all: python_configurations = get_python_configurations(options.build_selector)
env = options.environment.as_dictionary(prev_environment=os.environ)
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
shell(before_all_prepared, env=env)
python_configurations = get_python_configurations(options.build_selector) for config in python_configurations:
for config in python_configurations: log.build_start(config.identifier)
dependency_constraint_flags: Sequence[Union[str, PathLike]] = []
if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
]
# install Python dependency_constraint_flags: Sequence[Union[str, PathLike]] = []
env = setup_python(config, dependency_constraint_flags, options.environment) if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
]
# run the before_build command # install Python
if options.before_build: env = setup_python(config, dependency_constraint_flags, options.environment)
before_build_prepared = prepare_command(options.before_build, project='.', package=options.package_dir)
shell(before_build_prepared, env=env)
# activate the PEP 518 patch if on Windows Python 3.5 # run the before_build command
# (will only have an effect if PEP 517 builds are used): if options.before_build:
if config.version.startswith('3.5'): log.step('Running before_build...')
pep_518_cp35_workaround(options.package_dir, env) before_build_prepared = prepare_command(options.before_build, project='.', package=options.package_dir)
shell(before_build_prepared, env=env)
# build the wheel # activate the PEP 518 patch if on Windows Python 3.5
if built_wheel_dir.exists(): # (will only have an effect if PEP 517 builds are used):
shutil.rmtree(built_wheel_dir) if config.version.startswith('3.5'):
built_wheel_dir.mkdir(parents=True) pep_518_cp35_workaround(options.package_dir, env)
# Path.resolve() is needed. Without it pip wheel may try to fetch package from pypi.org
# see https://github.com/joerick/cibuildwheel/pull/369
call([
'pip', 'wheel',
options.package_dir.resolve(),
'-w', built_wheel_dir,
'--no-deps',
*get_build_verbosity_extra_flags(options.build_verbosity)
], env=env)
built_wheel = next(built_wheel_dir.glob('*.whl')) log.step('Building wheel...')
if built_wheel_dir.exists():
shutil.rmtree(built_wheel_dir)
built_wheel_dir.mkdir(parents=True)
# Path.resolve() is needed. Without it pip wheel may try to fetch package from pypi.org
# see https://github.com/joerick/cibuildwheel/pull/369
call([
'pip', 'wheel',
options.package_dir.resolve(),
'-w', built_wheel_dir,
'--no-deps',
*get_build_verbosity_extra_flags(options.build_verbosity)
], env=env)
# repair the wheel built_wheel = next(built_wheel_dir.glob('*.whl'))
if repaired_wheel_dir.exists():
shutil.rmtree(repaired_wheel_dir)
repaired_wheel_dir.mkdir(parents=True)
if built_wheel.name.endswith('none-any.whl'): # repair the wheel
raise NonPlatformWheelError() if repaired_wheel_dir.exists():
shutil.rmtree(repaired_wheel_dir)
repaired_wheel_dir.mkdir(parents=True)
if options.repair_command: if built_wheel.name.endswith('none-any.whl'):
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) raise NonPlatformWheelError()
shell(repair_command_prepared, env=env)
else:
shutil.move(str(built_wheel), repaired_wheel_dir)
repaired_wheel = next(repaired_wheel_dir.glob('*.whl')) if options.repair_command:
log.step('Repairing wheel...')
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
shell(repair_command_prepared, env=env)
else:
shutil.move(str(built_wheel), repaired_wheel_dir)
if options.test_command: repaired_wheel = next(repaired_wheel_dir.glob('*.whl'))
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call(['pip', 'install', 'virtualenv', *dependency_constraint_flags], env=env)
venv_dir = Path(tempfile.mkdtemp())
# Use --no-download to ensure determinism by using seed libraries if options.test_command:
# built into virtualenv log.step('Testing wheel...')
call(['python', '-m', 'virtualenv', '--no-download', venv_dir], env=env) # set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call(['pip', 'install', 'virtualenv', *dependency_constraint_flags], env=env)
venv_dir = Path(tempfile.mkdtemp())
virtualenv_env = env.copy() # Use --no-download to ensure determinism by using seed libraries
virtualenv_env['PATH'] = os.pathsep.join([ # built into virtualenv
str(venv_dir / 'Scripts'), call(['python', '-m', 'virtualenv', '--no-download', venv_dir], env=env)
virtualenv_env['PATH'],
])
# check that we are using the Python from the virtual environment virtualenv_env = env.copy()
call(['which', 'python'], env=virtualenv_env) virtualenv_env['PATH'] = os.pathsep.join([
str(venv_dir / 'Scripts'),
virtualenv_env['PATH'],
])
if options.before_test: # check that we are using the Python from the virtual environment
before_test_prepared = prepare_command( call(['which', 'python'], env=virtualenv_env)
options.before_test,
project='.', if options.before_test:
package=options.package_dir before_test_prepared = prepare_command(
options.before_test,
project='.',
package=options.package_dir
)
shell(before_test_prepared, env=virtualenv_env)
# install the wheel
call(['pip', 'install', str(repaired_wheel) + options.test_extras], env=virtualenv_env)
# test the wheel
if options.test_requires:
call(['pip', 'install'] + options.test_requires, env=virtualenv_env)
# run the tests from c:\, with an absolute path in the command
# (this ensures that Python runs the tests against the installed wheel
# and not the repo code)
test_command_prepared = prepare_command(
options.test_command,
project=Path('.').resolve(),
package=options.package_dir.resolve()
) )
shell(before_test_prepared, env=virtualenv_env) shell(test_command_prepared, cwd='c:\\', env=virtualenv_env)
# install the wheel # clean up
call(['pip', 'install', str(repaired_wheel) + options.test_extras], env=virtualenv_env) shutil.rmtree(venv_dir)
# test the wheel # we're all done here; move it to output (remove if already exists)
if options.test_requires: shutil.move(str(repaired_wheel), options.output_dir)
call(['pip', 'install'] + options.test_requires, env=virtualenv_env) log.build_end()
except subprocess.CalledProcessError as error:
# run the tests from c:\, with an absolute path in the command log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
# (this ensures that Python runs the tests against the installed wheel exit(1)
# and not the repo code)
test_command_prepared = prepare_command(
options.test_command,
project=Path('.').resolve(),
package=options.package_dir.resolve()
)
shell(test_command_prepared, cwd='c:\\', env=virtualenv_env)
# clean up
shutil.rmtree(venv_dir)
# we're all done here; move it to output (remove if already exists)
shutil.move(str(repaired_wheel), options.output_dir)