From 44e31988805c30b1e22f43552094940dd2e30a86 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Fri, 10 Jul 2020 12:57:05 +0100 Subject: [PATCH] Convert glob to take a Path and a str pattern --- cibuildwheel/docker_container.py | 7 +++++-- cibuildwheel/linux.py | 4 ++-- unit_test/docker_container_test.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index f5d6e965..6bd5cdf3 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -1,5 +1,6 @@ import io import json +import os import shlex import subprocess import sys @@ -103,11 +104,13 @@ class DockerContainer: cwd=to_path ) - def glob(self, pattern: PurePath) -> List[PurePath]: + def glob(self, path: PurePath, pattern: str) -> List[PurePath]: + glob_pattern = os.path.join(str(path), pattern) + path_strs = json.loads(self.call([ self.UTILITY_PYTHON, '-c', - f'import sys, json, glob; json.dump(glob.glob({str(pattern)!r}), sys.stdout)' + f'import sys, json, glob; json.dump(glob.glob({glob_pattern!r}), sys.stdout)' ], capture_output=True)) return [PurePath(p) for p in path_strs] diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 60de4743..e4607f0c 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -167,7 +167,7 @@ def build(options: BuildOptions) -> None: *get_build_verbosity_extra_flags(options.build_verbosity) ], env=env) - built_wheel = docker.glob(built_wheel_dir / '*.whl')[0] + built_wheel = docker.glob(built_wheel_dir, '*.whl')[0] repaired_wheel_dir = temp_dir / 'repaired_wheel' docker.call(['rm', '-rf', repaired_wheel_dir]) @@ -179,7 +179,7 @@ def build(options: BuildOptions) -> None: 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) - repaired_wheels = docker.glob(repaired_wheel_dir / '*.whl') + repaired_wheels = docker.glob(repaired_wheel_dir, '*.whl') if options.test_command: # set up a virtual environment to install and test from, to make sure diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index c3b3c951..6fe9f957 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -138,7 +138,7 @@ def test_dir_operations(tmp_path: Path): assert test_binary_data == bytes(output, encoding='utf8', errors='surrogateescape') # test glob - assert container.glob(dst_dir / '*.dat') == [dst_file] + assert container.glob(dst_dir, '*.dat') == [dst_file] # test copy dir out new_test_dir = tmp_path / 'test_dir_new'