Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if using xdist may help with performance problems #412

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
name: Test cibuildwheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
python_version: ['3.7']
Expand Down
2 changes: 1 addition & 1 deletion bin/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
subprocess.check_call(unit_test_args)

# run the integration tests
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test'])
subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test', '-n', '2', '--dist=loadfile'])
17 changes: 10 additions & 7 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
IS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists()
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'

INSTALL_PATH = 'C:\\cibw'


def call(args: Sequence[Union[str, PathLike]], env: Optional[Dict[str, str]] = None,
cwd: Optional[str] = None) -> None:
Expand All @@ -35,7 +37,7 @@ def get_nuget_args(version: str, arch: str) -> List[str]:
python_name = 'python' if version[0] == '3' else 'python2'
if arch == '32':
python_name = python_name + 'x86'
return [python_name, '-Version', version, '-OutputDirectory', 'C:\\cibw\\python']
return [python_name, '-Version', version, '-OutputDirectory', INSTALL_PATH + '\\python']


class PythonConfiguration(NamedTuple):
Expand Down Expand Up @@ -84,7 +86,8 @@ def extract_zip(zip_src: Path, dest: Path) -> None:
def install_cpython(version: str, arch: str, nuget: Path) -> Path:
nuget_args = get_nuget_args(version, arch)
installation_path = Path(nuget_args[-1]) / (nuget_args[0] + '.' + version) / 'tools'
call([nuget, 'install', *nuget_args])
if not installation_path.exists():
call([nuget, 'install', *nuget_args])
return installation_path


Expand All @@ -94,9 +97,9 @@ def install_pypy(version: str, arch: str, url: str) -> Path:
zip_filename = url.rsplit('/', 1)[-1]
extension = ".zip"
assert zip_filename.endswith(extension)
installation_path = Path('C:\\cibw') / zip_filename[:-len(extension)]
installation_path = Path(INSTALL_PATH) / zip_filename[:-len(extension)]
if not installation_path.exists():
pypy_zip = Path('C:\\cibw') / zip_filename
pypy_zip = Path(INSTALL_PATH) / zip_filename
download(url, pypy_zip)
# Extract to the parent directory because the zip file still contains a directory
extract_zip(pypy_zip, installation_path.parent)
Expand All @@ -106,7 +109,7 @@ def install_pypy(version: str, arch: str, url: str) -> Path:


def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: Sequence[Union[str, PathLike]], environment: ParsedEnvironment) -> Dict[str, str]:
nuget = Path('C:\\cibw\\nuget.exe')
nuget = Path(INSTALL_PATH + '\\nuget.exe')
if not nuget.exists():
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)

Expand Down Expand Up @@ -143,7 +146,7 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain

# make sure pip is installed
if not (installation_path / 'Scripts' / 'pip.exe').exists():
call(['python', get_pip_script, *dependency_constraint_flags], env=env, cwd="C:\\cibw")
call(['python', get_pip_script, *dependency_constraint_flags], env=env, cwd=INSTALL_PATH)
assert (installation_path / 'Scripts' / 'pip.exe').exists()
where_pip = subprocess.check_output(['where', 'pip'], env=env, universal_newlines=True).splitlines()[0].strip()
if where_pip.strip() != str(installation_path / 'Scripts' / 'pip.exe'):
Expand Down Expand Up @@ -195,7 +198,7 @@ def build(options: BuildOptions) -> None:
repaired_wheel_dir = temp_dir / 'repaired_wheel'

# install nuget as best way to provide python
nuget = Path('C:\\cibw\\nuget.exe')
nuget = Path(INSTALL_PATH + '\\nuget.exe')
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)

if options.before_all:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-e .
-e ./docs/mkdocs_include_markdown_plugin
pytest
pytest-xdist
mkdocs==1.0.4
pymdown-extensions
pip-tools
Expand Down
13 changes: 13 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest

import cibuildwheel.windows


@pytest.fixture(autouse=True)
def setup_python(monkeypatch, request):
try:
from xdist.plugin import get_xdist_worker_id
worker_id = get_xdist_worker_id(request)
monkeypatch.setattr(cibuildwheel.windows, "INSTALL_PATH", 'C:\\cibw\\{}'.format(worker_id))
except ImportError:
pass