From 265708854a8e6e71642d6d4675f76149cda80886 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Wed, 17 Jun 2020 00:18:40 +0200 Subject: [PATCH] Attend to review remarks --- cibuildwheel/__main__.py | 5 +++-- cibuildwheel/linux.py | 10 +++++----- cibuildwheel/macos.py | 8 ++++---- cibuildwheel/util.py | 6 +++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index fd4c418e..521710a6 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -21,6 +21,7 @@ from cibuildwheel.util import ( BuildSelector, DependencyConstraints, Unbuffered, + resources_dir, ) @@ -165,7 +166,7 @@ def main() -> None: # This needs to be passed on to the docker container in linux.py 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"]): print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr) exit(2) @@ -176,7 +177,7 @@ def main() -> None: manylinux_images: Optional[Dict[str, str]] = None 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.read(pinned_docker_images_file) # all_pinned_docker_images looks like a dict of dicts, e.g. diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index cdaef019..99e779c4 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -5,7 +5,7 @@ import subprocess import sys import textwrap import uuid -from pathlib import Path +from pathlib import Path, PurePath 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']), ] - pwd = Path().resolve() + cwd = Path.cwd() 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') - 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: 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('\n'.join([' ' + str(f) for f in so_files])) + print('\n'.join([f' {f}' for f in so_files])) print('') diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 5576641f..0e24f22d 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -24,7 +24,7 @@ def call(args: Union[str, List[str]], env: Optional[Dict[str, str]] = None, cwd: if shell: print(f'+ {args}') 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) @@ -65,9 +65,9 @@ def make_symlinks(installation_bin_path: Path, python_executable: str, pip_execu shutil.rmtree(SYMLINKS_DIR) SYMLINKS_DIR.mkdir(parents=True) - (SYMLINKS_DIR / 'python').symlink_to(installation_bin_path / python_executable) - (SYMLINKS_DIR / 'python-config').symlink_to(installation_bin_path / (python_executable + '-config')) - (SYMLINKS_DIR / 'pip').symlink_to(installation_bin_path / pip_executable) + SYMLINKS_DIR.joinpath('python').symlink_to(installation_bin_path / python_executable) + SYMLINKS_DIR.joinpath('python-config').symlink_to(installation_bin_path / (python_executable + '-config')) + SYMLINKS_DIR.joinpath('pip').symlink_to(installation_bin_path / pip_executable) def install_cpython(version: str, url: str) -> Path: diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 0b585b86..feef6185 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -90,7 +90,7 @@ class DependencyConstraints: @staticmethod def with_defaults() -> '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: @@ -99,8 +99,8 @@ class DependencyConstraints: # try to find a version-specific dependency file e.g. if # ./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]}' - sepcific_name = specific_stem + self.base_file_path.suffix - specific_file_path = self.base_file_path.with_name(sepcific_name) + specific_name = specific_stem + self.base_file_path.suffix + specific_file_path = self.base_file_path.with_name(specific_name) if specific_file_path.exists(): return specific_file_path else: