Skip to content

Commit d10b02f

Browse files
committed
Use temporary copy of cirq-core instead of filelock
Do not block parallel builds.
1 parent 3d391ff commit d10b02f

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

dev_tools/packaging/isolated_packages_test.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import subprocess
1818
from unittest import mock
1919

20-
import filelock
2120
import pytest
22-
import xdist
2321

2422
from dev_tools import shell_tools
2523
from dev_tools.modules import list_modules
@@ -34,24 +32,25 @@
3432
# the "isolation" fails and for example cirq-core would be on the PATH
3533
@mock.patch.dict(os.environ, {"PYTHONPATH": ""})
3634
@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):
3836
env = cloned_env("isolated_packages", *PACKAGES)
3937

4038
if str(module.root) != "cirq-core":
4139
assert f'cirq-core=={module.version}' in module.install_requires
4240

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+
)
5554
assert result.returncode == 0, f"Failed to install {module.name}:\n{result.stderr}"
5655

5756
result = shell_tools.run(

0 commit comments

Comments
 (0)