diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 916b117e..7099bc8f 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -197,7 +197,6 @@ def main(): manylinux_images = None build_options = BuildOptions( - project_dir='.', package_dir=package_dir, output_dir=output_dir, test_command=test_command, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 2942c9af..f7e34586 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -96,11 +96,10 @@ def build(options: BuildOptions): ('pp', 'manylinux_x86_64', options.manylinux_images['pypy_x86_64']), ] - abs_project_dir = os.path.abspath(options.project_dir) - abs_package_dir = os.path.abspath(options.package_dir) + if not os.path.realpath(options.package_dir).startswith(os.path.realpath('.')): + raise Exception('package_dir must be inside the working directory') - container_project_dir = '/project' - container_package_dir = os.path.join(container_project_dir, os.path.relpath(abs_package_dir, os.path.commonprefix([abs_project_dir, abs_package_dir]))), + container_package_dir = os.path.join('/project', os.path.relpath(options.package_dir, '.')) 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)] @@ -108,6 +107,7 @@ def build(options: BuildOptions): continue container_name = 'cibuildwheel-{}'.format(uuid.uuid4()) + try: call(['docker', 'create', '--env', 'CIBUILDWHEEL', @@ -244,10 +244,10 @@ def build(options: BuildOptions): test_requires=' '.join(options.test_requires), test_extras=options.test_extras, test_command=shlex.quote( - prepare_command(options.test_command, project='/project') if options.test_command else '' + prepare_command(options.test_command, project='/project', package=container_package_dir) if options.test_command else '' ), before_build=shlex.quote( - prepare_command(options.before_build, project='/project') if options.before_build else '' + prepare_command(options.before_build, project='/project', package=container_package_dir) if options.before_build else '' ), build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(options.build_verbosity)), repair_command=shlex.quote( @@ -257,7 +257,7 @@ def build(options: BuildOptions): uid=os.getuid(), gid=os.getgid(), before_test=shlex.quote( - prepare_command(options.before_test, project='/project') if options.before_test else '' + prepare_command(options.before_test, project='/project', package=container_package_dir) if options.before_test else '' ), dependency_install_flags='-c /constraints.txt' if options.dependency_constraints else '', ) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index b903dcb9..599e9b23 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -168,8 +168,6 @@ def setup_python(python_configuration, dependency_constraint_flags, environment) def build(options: BuildOptions): - abs_project_dir = os.path.abspath(options.project_dir) - abs_package_dir = os.path.abspath(options.package_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') built_wheel_dir = os.path.join(temp_dir, 'built_wheel') repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel') @@ -187,14 +185,14 @@ def build(options: BuildOptions): # run the before_build command if options.before_build: - before_build_prepared = prepare_command(options.before_build, project=abs_project_dir, package=abs_package_dir) + 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 os.path.exists(built_wheel_dir): shutil.rmtree(built_wheel_dir) os.makedirs(built_wheel_dir) - call(['pip', 'wheel', abs_package_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) + call(['pip', 'wheel', options.package_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) built_wheel = glob(os.path.join(built_wheel_dir, '*.whl'))[0] # repair the wheel @@ -230,7 +228,7 @@ def build(options: BuildOptions): call(['which', 'python'], env=virtualenv_env) if options.before_test: - before_test_prepared = prepare_command(options.before_test, project=abs_project_dir, package=abs_package_dir) + before_test_prepared = prepare_command(options.before_test, project='.', package=options.package_dir) call(before_test_prepared, env=virtualenv_env, shell=True) # install the wheel @@ -243,7 +241,11 @@ def build(options: BuildOptions): # run the tests from $HOME, 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=abs_project_dir, package=abs_package_dir) + test_command_prepared = prepare_command( + options.test_command, + project=os.path.abspath('.'), + package=os.path.abspath(options.package_dir) + ) call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True) # clean up diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index d42dcc38..64f561a1 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -107,7 +107,6 @@ class DependencyConstraints: BuildOptions = NamedTuple("BuildOptions", [ - ("project_dir", str), ("package_dir", str), ("output_dir", str), ("test_command", Optional[str]), diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 2a5df54d..e6f14ed9 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -143,8 +143,6 @@ def setup_python(python_configuration, dependency_constraint_flags, environment) def build(options: BuildOptions): - abs_project_dir = os.path.abspath(options.project_dir) - abs_package_dir = os.path.abspath(options.package_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') built_wheel_dir = os.path.join(temp_dir, 'built_wheel') repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel') @@ -166,14 +164,14 @@ def build(options: BuildOptions): # run the before_build command if options.before_build: - before_build_prepared = prepare_command(options.before_build, project=abs_project_dir, package=abs_package_dir) + before_build_prepared = prepare_command(options.before_build, project='.', package=options.package_dir) shell([before_build_prepared], env=env) # build the wheel if os.path.exists(built_wheel_dir): shutil.rmtree(built_wheel_dir) os.makedirs(built_wheel_dir) - shell(['pip', 'wheel', abs_package_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) + shell(['pip', 'wheel', options.package_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) built_wheel = glob(os.path.join(built_wheel_dir, '*.whl'))[0] # repair the wheel @@ -214,7 +212,11 @@ def build(options: BuildOptions): shell(['which', 'python'], env=virtualenv_env) if options.before_test: - before_test_prepared = prepare_command(options.before_test, project=abs_project_dir, package=abs_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 @@ -227,7 +229,11 @@ def build(options: BuildOptions): # 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=abs_project_dir, package=abs_package_dir) + test_command_prepared = prepare_command( + options.test_command, + project=os.path.abspath('.'), + package=os.path.abspath(options.package_dir) + ) shell([test_command_prepared], cwd='c:\\', env=virtualenv_env) # clean up