Improve some formatting
This commit is contained in:
+14
-9
@@ -120,11 +120,16 @@ def build(options: BuildOptions) -> None:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
log.step(f'Starting Docker image {docker_image}...')
|
||||||
with DockerContainer(docker_image, simulate_32_bit=platform_tag.endswith('i686'), cwd=container_project_path) as docker:
|
with DockerContainer(docker_image, simulate_32_bit=platform_tag.endswith('i686'), cwd=container_project_path) as docker:
|
||||||
|
log.step_end()
|
||||||
|
|
||||||
|
log.step('Copying project into Docker...')
|
||||||
docker.copy_into(Path.cwd(), container_project_path)
|
docker.copy_into(Path.cwd(), container_project_path)
|
||||||
|
log.step_end()
|
||||||
|
|
||||||
if options.before_all:
|
if options.before_all:
|
||||||
log.build_step('Running before_all...')
|
log.step('Running before_all...')
|
||||||
|
|
||||||
env = docker.get_environment()
|
env = docker.get_environment()
|
||||||
env['PATH'] = f'/opt/python/cp38-cp38:{env["PATH"]}'
|
env['PATH'] = f'/opt/python/cp38-cp38:{env["PATH"]}'
|
||||||
@@ -133,7 +138,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
before_all_prepared = prepare_command(options.before_all, project=container_project_path, package=container_package_dir)
|
before_all_prepared = prepare_command(options.before_all, project=container_project_path, package=container_package_dir)
|
||||||
docker.call(['sh', '-c', before_all_prepared], env=env)
|
docker.call(['sh', '-c', before_all_prepared], env=env)
|
||||||
|
|
||||||
log.build_step_end()
|
log.step_end()
|
||||||
|
|
||||||
for config in platform_configs:
|
for config in platform_configs:
|
||||||
log.build_start(config.identifier)
|
log.build_start(config.identifier)
|
||||||
@@ -153,7 +158,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
python_bin = config.path / 'bin'
|
python_bin = config.path / 'bin'
|
||||||
env['PATH'] = f'{python_bin}:{env["PATH"]}'
|
env['PATH'] = f'{python_bin}:{env["PATH"]}'
|
||||||
|
|
||||||
log.build_step('Setting up build environment...')
|
log.step('Setting up build environment...')
|
||||||
|
|
||||||
env = options.environment.as_dictionary(env, executor=docker.environment_executor)
|
env = options.environment.as_dictionary(env, executor=docker.environment_executor)
|
||||||
|
|
||||||
@@ -169,11 +174,11 @@ def build(options: BuildOptions) -> None:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if options.before_build:
|
if options.before_build:
|
||||||
log.build_step('Running before_build...')
|
log.step('Running before_build...')
|
||||||
before_build_prepared = prepare_command(options.before_build, project=container_project_path, package=container_package_dir)
|
before_build_prepared = prepare_command(options.before_build, project=container_project_path, package=container_package_dir)
|
||||||
docker.call(['sh', '-c', before_build_prepared], env=env)
|
docker.call(['sh', '-c', before_build_prepared], env=env)
|
||||||
|
|
||||||
log.build_step('Building wheel...')
|
log.step('Building wheel...')
|
||||||
|
|
||||||
temp_dir = PurePath('/tmp/cibuildwheel')
|
temp_dir = PurePath('/tmp/cibuildwheel')
|
||||||
built_wheel_dir = temp_dir / 'built_wheel'
|
built_wheel_dir = temp_dir / 'built_wheel'
|
||||||
@@ -198,7 +203,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
raise NonPlatformWheelError()
|
raise NonPlatformWheelError()
|
||||||
|
|
||||||
if options.repair_command:
|
if options.repair_command:
|
||||||
log.build_step('Repairing wheel...')
|
log.step('Repairing wheel...')
|
||||||
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
|
repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
|
||||||
docker.call(['sh', '-c', repair_command_prepared], env=env)
|
docker.call(['sh', '-c', repair_command_prepared], env=env)
|
||||||
else:
|
else:
|
||||||
@@ -207,7 +212,7 @@ def build(options: BuildOptions) -> None:
|
|||||||
repaired_wheels = docker.glob(repaired_wheel_dir, '*.whl')
|
repaired_wheels = docker.glob(repaired_wheel_dir, '*.whl')
|
||||||
|
|
||||||
if options.test_command:
|
if options.test_command:
|
||||||
log.build_step('Testing wheel...')
|
log.step('Testing wheel...')
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -249,10 +254,10 @@ def build(options: BuildOptions) -> None:
|
|||||||
|
|
||||||
log.build_end()
|
log.build_end()
|
||||||
|
|
||||||
log.build_step('Copying wheels back to host...')
|
log.step('Copying wheels back to host...')
|
||||||
# copy the output back into the host
|
# copy the output back into the host
|
||||||
docker.copy_out(container_output_dir, options.output_dir)
|
docker.copy_out(container_output_dir, options.output_dir)
|
||||||
log.build_step_end()
|
log.step_end()
|
||||||
except subprocess.CalledProcessError as error:
|
except subprocess.CalledProcessError as error:
|
||||||
print(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
|
print(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
|
||||||
troubleshoot(options.package_dir, error)
|
troubleshoot(options.package_dir, error)
|
||||||
|
|||||||
+16
-14
@@ -25,9 +25,9 @@ class Logger:
|
|||||||
fold_mode: str
|
fold_mode: str
|
||||||
colors_enabled: bool
|
colors_enabled: bool
|
||||||
active_build_identifier: Optional[str] = None
|
active_build_identifier: Optional[str] = None
|
||||||
build_start_time: Optional[float] = 0
|
build_start_time: Optional[float] = None
|
||||||
step_start_time: Optional[float] = 0
|
step_start_time: Optional[float] = None
|
||||||
active_fold_group_id: Optional[str] = None
|
active_fold_group_name: Optional[str] = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if 'AZURE_HTTP_USER_AGENT' in os.environ:
|
if 'AZURE_HTTP_USER_AGENT' in os.environ:
|
||||||
@@ -54,7 +54,7 @@ class Logger:
|
|||||||
c = self.colors
|
c = self.colors
|
||||||
print()
|
print()
|
||||||
print(f'{c.bold}Building {build_description_from_identifier(identifier)} wheel{c.end}')
|
print(f'{c.bold}Building {build_description_from_identifier(identifier)} wheel{c.end}')
|
||||||
print(f'Identifier: {identifier}')
|
print(f'Identifier: {c.bg_grey}{identifier}{c.end}')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
self.build_start_time = time.time()
|
self.build_start_time = time.time()
|
||||||
@@ -62,21 +62,23 @@ class Logger:
|
|||||||
|
|
||||||
def build_end(self):
|
def build_end(self):
|
||||||
assert self.build_start_time is not None
|
assert self.build_start_time is not None
|
||||||
self.build_step_end()
|
self.step_end()
|
||||||
|
|
||||||
c = self.colors
|
c = self.colors
|
||||||
duration = time.time() - self.build_start_time
|
duration = time.time() - self.build_start_time
|
||||||
|
print()
|
||||||
print(f'{c.green}Build {c.bg_grey}{self.active_build_identifier}{c.end}{c.green} completed in {duration:.2f}s{c.end}')
|
print(f'{c.green}Build {c.bg_grey}{self.active_build_identifier}{c.end}{c.green} completed in {duration:.2f}s{c.end}')
|
||||||
print()
|
print()
|
||||||
print('---')
|
print('---')
|
||||||
|
print()
|
||||||
self.build_start_time = None
|
self.build_start_time = None
|
||||||
|
|
||||||
def build_step(self, step_description: str):
|
def step(self, step_description: str):
|
||||||
self.build_step_end()
|
self.step_end()
|
||||||
self.step_start_time = time.time()
|
self.step_start_time = time.time()
|
||||||
self.start_fold_group(step_description)
|
self.start_fold_group(step_description)
|
||||||
|
|
||||||
def build_step_end(self):
|
def step_end(self):
|
||||||
if self.step_start_time is not None:
|
if self.step_start_time is not None:
|
||||||
self.end_fold_group()
|
self.end_fold_group()
|
||||||
c = self.colors
|
c = self.colors
|
||||||
@@ -86,16 +88,16 @@ class Logger:
|
|||||||
|
|
||||||
def start_fold_group(self, name: str):
|
def start_fold_group(self, name: str):
|
||||||
self.end_fold_group()
|
self.end_fold_group()
|
||||||
self.active_fold_group_id = re.sub(r'[^A-Za-z]', '', name)
|
self.active_fold_group_name = name
|
||||||
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, ('', ''))[0]
|
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, ('', ''))[0]
|
||||||
print(fold_start_pattern.format(name=self.active_fold_group_id))
|
print(fold_start_pattern.format(name=self.active_fold_group_name))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def end_fold_group(self):
|
def end_fold_group(self):
|
||||||
if self.active_fold_group_id:
|
if self.active_fold_group_name:
|
||||||
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, ('', ''))[1]
|
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, ('', ''))[1]
|
||||||
print(fold_start_pattern.format(name=self.active_fold_group_id))
|
print(fold_start_pattern.format(name=self.active_fold_group_name))
|
||||||
self.active_fold_group_id = None
|
self.active_fold_group_name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def colors(self):
|
def colors(self):
|
||||||
@@ -139,7 +141,7 @@ class Colors():
|
|||||||
bright_green = '\033[92m'
|
bright_green = '\033[92m'
|
||||||
white = '\033[37m\033[97m'
|
white = '\033[37m\033[97m'
|
||||||
|
|
||||||
bg_grey = '\033[48;5;244m'
|
bg_grey = '\033[48;5;235m'
|
||||||
|
|
||||||
bold = '\033[1m'
|
bold = '\033[1m'
|
||||||
faint = '\033[2m'
|
faint = '\033[2m'
|
||||||
|
|||||||
Reference in New Issue
Block a user