From fb2e01c93f20f41fae8f03ce3489aeb0ae2a93b7 Mon Sep 17 00:00:00 2001 From: Dan Belknap Date: Wed, 6 Mar 2024 20:52:38 -0600 Subject: [PATCH 1/3] Avoid recursing when installing a project to a subproject via copytree --- core/dbt/deps/local.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/dbt/deps/local.py b/core/dbt/deps/local.py index 9dd76b80161..12ab91bfc47 100644 --- a/core/dbt/deps/local.py +++ b/core/dbt/deps/local.py @@ -67,7 +67,13 @@ def install(self, project, renderer): system.make_symlink(src_path, dest_path) except OSError: fire_event(DepsSymlinkNotAvailable()) - shutil.copytree(src_path, dest_path) + shutil.copytree( + src_path, + dest_path, + ignore=lambda directory, contents: project.packages_install_path + if directory == project.project_root + else [], + ) class LocalUnpinnedPackage(LocalPackageMixin, UnpinnedPackage[LocalPinnedPackage]): From 118beedbaf7a4e90645d235c644b190eeea26a5e Mon Sep 17 00:00:00 2001 From: Dan Belknap Date: Thu, 7 Mar 2024 09:02:44 -0600 Subject: [PATCH 2/3] Add changelog entry --- .changes/unreleased/Fixes-20240307-090156.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20240307-090156.yaml diff --git a/.changes/unreleased/Fixes-20240307-090156.yaml b/.changes/unreleased/Fixes-20240307-090156.yaml new file mode 100644 index 00000000000..1e8bc91abf0 --- /dev/null +++ b/.changes/unreleased/Fixes-20240307-090156.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Avoid recursing when installing a project to a subproject via copytree +time: 2024-03-07T09:01:56.9007199-06:00 +custom: + Author: djbelknap + Issue: "9719" From e10b698af9ddbe2135846b301210948002a0c130 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 18 Jul 2024 07:48:08 -0600 Subject: [PATCH 3/3] Incorporate `ignore` parameter --- tests/unit/deps/test_deps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/deps/test_deps.py b/tests/unit/deps/test_deps.py index 339bbbc5d23..6d12938e986 100644 --- a/tests/unit/deps/test_deps.py +++ b/tests/unit/deps/test_deps.py @@ -226,7 +226,7 @@ def test_deps_install( LocalPinnedPackage("local").install("dummy", "dummy") self.assertEqual(mock_shutil.call_count, 1) - mock_shutil.assert_called_once_with("/tmp/source", "/tmp/dest") + mock_shutil.assert_called_once_with("/tmp/source", "/tmp/dest", ignore=mock.ANY) def test_invalid(self): with self.assertRaises(ValidationError):