Attend to review remarks

This commit is contained in:
Yannick Jadoul
2020-06-18 00:23:25 +02:00
parent e58aed1731
commit 265708854a
4 changed files with 15 additions and 14 deletions
+3 -2
View File
@@ -21,6 +21,7 @@ from cibuildwheel.util import (
BuildSelector, BuildSelector,
DependencyConstraints, DependencyConstraints,
Unbuffered, Unbuffered,
resources_dir,
) )
@@ -165,7 +166,7 @@ def main() -> None:
# This needs to be passed on to the docker container in linux.py # This needs to be passed on to the docker container in linux.py
os.environ['CIBUILDWHEEL'] = '1' os.environ['CIBUILDWHEEL'] = '1'
if not any((package_dir / name).exists() if not any(package_dir.joinpath(name).exists()
for name in ["setup.py", "setup.cfg", "pyproject.toml"]): for name in ["setup.py", "setup.cfg", "pyproject.toml"]):
print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr) print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr)
exit(2) exit(2)
@@ -176,7 +177,7 @@ def main() -> None:
manylinux_images: Optional[Dict[str, str]] = None manylinux_images: Optional[Dict[str, str]] = None
if platform == 'linux': if platform == 'linux':
pinned_docker_images_file = Path(__file__).parent / 'resources' / 'pinned_docker_images.cfg' pinned_docker_images_file = resources_dir / 'pinned_docker_images.cfg'
all_pinned_docker_images = ConfigParser() all_pinned_docker_images = ConfigParser()
all_pinned_docker_images.read(pinned_docker_images_file) all_pinned_docker_images.read(pinned_docker_images_file)
# all_pinned_docker_images looks like a dict of dicts, e.g. # all_pinned_docker_images looks like a dict of dicts, e.g.
+5 -5
View File
@@ -5,7 +5,7 @@ import subprocess
import sys import sys
import textwrap import textwrap
import uuid import uuid
from pathlib import Path from pathlib import Path, PurePath
from typing import List, NamedTuple, Optional, Union from typing import List, NamedTuple, Optional, Union
@@ -105,12 +105,12 @@ def build(options: BuildOptions) -> None:
('pp', 'manylinux_x86_64', options.manylinux_images['pypy_x86_64']), ('pp', 'manylinux_x86_64', options.manylinux_images['pypy_x86_64']),
] ]
pwd = Path().resolve() cwd = Path.cwd()
abs_package_dir = options.package_dir.resolve() abs_package_dir = options.package_dir.resolve()
if pwd != abs_package_dir and pwd not in abs_package_dir.parents: if cwd != abs_package_dir and cwd not in abs_package_dir.parents:
raise Exception('package_dir must be inside the working directory') raise Exception('package_dir must be inside the working directory')
container_package_dir = Path('/project') / abs_package_dir.relative_to(pwd) container_package_dir = PurePath('/project') / abs_package_dir.relative_to(cwd)
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)]
@@ -302,5 +302,5 @@ def troubleshoot(package_dir: Path, error: Exception) -> None:
''')) '''))
print(' Files detected:') print(' Files detected:')
print('\n'.join([' ' + str(f) for f in so_files])) print('\n'.join([f' {f}' for f in so_files]))
print('') print('')
+4 -4
View File
@@ -24,7 +24,7 @@ def call(args: Union[str, List[str]], env: Optional[Dict[str, str]] = None, cwd:
if shell: if shell:
print(f'+ {args}') print(f'+ {args}')
else: else:
print('+ ' + ' '.join(shlex.quote(str(a)) for a in args)) print('+ ' + ' '.join(shlex.quote(a) for a in args))
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell) return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
@@ -65,9 +65,9 @@ def make_symlinks(installation_bin_path: Path, python_executable: str, pip_execu
shutil.rmtree(SYMLINKS_DIR) shutil.rmtree(SYMLINKS_DIR)
SYMLINKS_DIR.mkdir(parents=True) SYMLINKS_DIR.mkdir(parents=True)
(SYMLINKS_DIR / 'python').symlink_to(installation_bin_path / python_executable) SYMLINKS_DIR.joinpath('python').symlink_to(installation_bin_path / python_executable)
(SYMLINKS_DIR / 'python-config').symlink_to(installation_bin_path / (python_executable + '-config')) SYMLINKS_DIR.joinpath('python-config').symlink_to(installation_bin_path / (python_executable + '-config'))
(SYMLINKS_DIR / 'pip').symlink_to(installation_bin_path / pip_executable) SYMLINKS_DIR.joinpath('pip').symlink_to(installation_bin_path / pip_executable)
def install_cpython(version: str, url: str) -> Path: def install_cpython(version: str, url: str) -> Path:
+3 -3
View File
@@ -90,7 +90,7 @@ class DependencyConstraints:
@staticmethod @staticmethod
def with_defaults() -> 'DependencyConstraints': def with_defaults() -> 'DependencyConstraints':
return DependencyConstraints( return DependencyConstraints(
base_file_path=Path(__file__).parent / 'resources' / 'constraints.txt' base_file_path=resources_dir / 'constraints.txt'
) )
def get_for_python_version(self, version: str) -> Path: def get_for_python_version(self, version: str) -> Path:
@@ -99,8 +99,8 @@ class DependencyConstraints:
# try to find a version-specific dependency file e.g. if # try to find a version-specific dependency file e.g. if
# ./constraints.txt is the base, look for ./constraints-python27.txt # ./constraints.txt is the base, look for ./constraints-python27.txt
specific_stem = self.base_file_path.stem + f'-python{version_parts[0]}{version_parts[1]}' specific_stem = self.base_file_path.stem + f'-python{version_parts[0]}{version_parts[1]}'
sepcific_name = specific_stem + self.base_file_path.suffix specific_name = specific_stem + self.base_file_path.suffix
specific_file_path = self.base_file_path.with_name(sepcific_name) specific_file_path = self.base_file_path.with_name(specific_name)
if specific_file_path.exists(): if specific_file_path.exists():
return specific_file_path return specific_file_path
else: else: