diff --git a/dev_tools/notebooks/isolated_notebook_test.py b/dev_tools/notebooks/isolated_notebook_test.py index ee006d4ffba..66b8d276cc9 100644 --- a/dev_tools/notebooks/isolated_notebook_test.py +++ b/dev_tools/notebooks/isolated_notebook_test.py @@ -96,7 +96,7 @@ "papermill", "jupyter", # assumed to be part of colab - "seaborn~=0.11.1", + "seaborn~=0.12", ] diff --git a/dev_tools/notebooks/notebook_test.py b/dev_tools/notebooks/notebook_test.py index 8c588fc1c5d..bcef1b0f991 100644 --- a/dev_tools/notebooks/notebook_test.py +++ b/dev_tools/notebooks/notebook_test.py @@ -26,6 +26,7 @@ import pytest from dev_tools import shell_tools +from dev_tools.modules import list_modules from dev_tools.notebooks import filter_notebooks, list_all_notebooks, rewrite_notebook from dev_tools.test_utils import only_on_posix @@ -63,9 +64,18 @@ def require_packages_not_changed(): Raise AssertionError if the pre-existing set of Python packages changes in any way. """ - packages_before = set((d.name, d.version) for d in importlib.metadata.distributions()) + cirq_packages = set(m.name for m in list_modules()).union(["cirq"]) + packages_before = set( + (d.name, d.version) + for d in importlib.metadata.distributions() + if d.name not in cirq_packages + ) yield - packages_after = set((d.name, d.version) for d in importlib.metadata.distributions()) + packages_after = set( + (d.name, d.version) + for d in importlib.metadata.distributions() + if d.name not in cirq_packages + ) assert packages_after == packages_before diff --git a/dev_tools/packaging/isolated_packages_test.py b/dev_tools/packaging/isolated_packages_test.py index 8c2d2865c4a..e30f4abc932 100644 --- a/dev_tools/packaging/isolated_packages_test.py +++ b/dev_tools/packaging/isolated_packages_test.py @@ -32,14 +32,22 @@ # the "isolation" fails and for example cirq-core would be on the PATH @mock.patch.dict(os.environ, {"PYTHONPATH": ""}) @pytest.mark.parametrize('module', list_modules(), ids=[m.name for m in list_modules()]) -def test_isolated_packages(cloned_env, module): +def test_isolated_packages(cloned_env, module, tmp_path): env = cloned_env("isolated_packages", *PACKAGES) if str(module.root) != "cirq-core": assert f'cirq-core=={module.version}' in module.install_requires + # TODO: Remove after upgrading package builds from setup.py to PEP-517 + # Create per-worker copy of cirq-core sources so that parallel builds + # of cirq-core wheel do not conflict. + opt_cirq_core = ( + [str(shutil.copytree("./cirq-core", tmp_path / "cirq-core"))] + if str(module.root) != "cirq-core" + else [] + ) result = shell_tools.run( - f"{env}/bin/pip install --no-clean ./{module.root} ./cirq-core".split(), + [f"{env}/bin/pip", "install", f"./{module.root}", *opt_cirq_core], stderr=subprocess.PIPE, check=False, ) diff --git a/dev_tools/requirements/deps/notebook.txt b/dev_tools/requirements/deps/notebook.txt index 12815f39353..84ec065de0e 100644 --- a/dev_tools/requirements/deps/notebook.txt +++ b/dev_tools/requirements/deps/notebook.txt @@ -13,4 +13,4 @@ papermill~=2.3.2 -r ../../../cirq-core/cirq/contrib/requirements.txt # assumed to be part of colab -seaborn~=0.11.1 +seaborn~=0.12