|
17 | 17 | import subprocess |
18 | 18 | from unittest import mock |
19 | 19 |
|
20 | | -import filelock |
21 | 20 | import pytest |
22 | | -import xdist |
23 | 21 |
|
24 | 22 | from dev_tools import shell_tools |
25 | 23 | from dev_tools.modules import list_modules |
|
34 | 32 | # the "isolation" fails and for example cirq-core would be on the PATH |
35 | 33 | @mock.patch.dict(os.environ, {"PYTHONPATH": ""}) |
36 | 34 | @pytest.mark.parametrize('module', list_modules(), ids=[m.name for m in list_modules()]) |
37 | | -def test_isolated_packages(cloned_env, module, tmp_path_factory, request): |
| 35 | +def test_isolated_packages(cloned_env, module, tmp_path): |
38 | 36 | env = cloned_env("isolated_packages", *PACKAGES) |
39 | 37 |
|
40 | 38 | if str(module.root) != "cirq-core": |
41 | 39 | assert f'cirq-core=={module.version}' in module.install_requires |
42 | 40 |
|
43 | | - # use filelock to ensure only one pip install process runs at a time, |
44 | | - # otherwise they conflict when building a local cirq-core wheel |
45 | | - lock_dir = tmp_path_factory.getbasetemp() |
46 | | - if xdist.is_xdist_worker(request): |
47 | | - lock_dir = lock_dir.parent |
48 | | - lock = filelock.FileLock(lock_dir / "test_isolated_packages-pip.lock") |
49 | | - with lock.acquire(timeout=30): |
50 | | - result = shell_tools.run( |
51 | | - f"{env}/bin/pip install ./{module.root} ./cirq-core".split(), |
52 | | - stderr=subprocess.PIPE, |
53 | | - check=False, |
54 | | - ) |
| 41 | + # TODO: Remove after upgrading package builds from setup.py to PEP-517 |
| 42 | + # Create per-process copy of cirq-core sources so that parallel builds |
| 43 | + # of cirq-core wheel do not conflict. |
| 44 | + tmp_cirq_core = ( |
| 45 | + [str(shutil.copytree("./cirq-core", tmp_path / "cirq-core"))] |
| 46 | + if str(module.root) != "cirq-core" |
| 47 | + else [] |
| 48 | + ) |
| 49 | + result = shell_tools.run( |
| 50 | + [f"{env}/bin/pip", "install", f"./{module.root}", *tmp_cirq_core], |
| 51 | + stderr=subprocess.PIPE, |
| 52 | + check=False, |
| 53 | + ) |
55 | 54 | assert result.returncode == 0, f"Failed to install {module.name}:\n{result.stderr}" |
56 | 55 |
|
57 | 56 | result = shell_tools.run( |
|
0 commit comments