From d12214b712197d50186d86b3d19c4edd7842373e Mon Sep 17 00:00:00 2001
From: Harry Mander
Date: Wed, 1 Mar 2023 23:09:31 +1300
Subject: [PATCH 1/3] tests/installation/executor: test Git subdirectory path
---
tests/installation/test_executor.py | 31 +++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py
index 1f2a6c37dd1..34f397e6bd4 100644
--- a/tests/installation/test_executor.py
+++ b/tests/installation/test_executor.py
@@ -776,6 +776,37 @@ def test_executor_should_write_pep610_url_references_for_git(
)
+def test_executor_should_append_subdirectory_for_git(
+ mocker: MockerFixture,
+ tmp_venv: VirtualEnv,
+ pool: RepositoryPool,
+ config: Config,
+ io: BufferedIO,
+ mock_file_downloads: None,
+ wheel: Path,
+) -> None:
+ package = Package(
+ "demo",
+ "0.1.2",
+ source_type="git",
+ source_reference="master",
+ source_resolved_reference="123456",
+ source_url="https://github.com/demo/subdirectories.git",
+ source_subdirectory="two",
+ )
+
+ chef = Chef(config, tmp_venv, Factory.create_pool(config))
+ chef.set_directory_wheel(wheel)
+ spy = mocker.spy(chef, "prepare")
+
+ executor = Executor(tmp_venv, pool, config, io)
+ executor._chef = chef
+ executor.execute([Install(package)])
+
+ archive_arg = spy.call_args[0][0]
+ assert archive_arg == tmp_venv.path / "src/demo/subdirectories/two"
+
+
def test_executor_should_write_pep610_url_references_for_git_with_subdirectories(
tmp_venv: VirtualEnv,
pool: RepositoryPool,
From 5d1edfa1952fa9e439379531c48e52487732cf36 Mon Sep 17 00:00:00 2001
From: Harry Mander
Date: Wed, 1 Mar 2023 22:14:55 +1300
Subject: [PATCH 2/3] fix: append subdirectory to archive path (#7575)
---
src/poetry/installation/executor.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py
index eb7302aa63d..e0adcde994f 100644
--- a/src/poetry/installation/executor.py
+++ b/src/poetry/installation/executor.py
@@ -569,6 +569,8 @@ def _prepare_archive(self, operation: Install | Update) -> Path:
assert package.source_url is not None
archive = Path(package.source_url)
+ if package.source_subdirectory:
+ archive = archive / package.source_subdirectory
if not Path(package.source_url).is_absolute() and package.root_dir:
archive = package.root_dir / archive
From 89d77cb7a57c642faf1363ff6ff9811d04f92023 Mon Sep 17 00:00:00 2001
From: Harry Mander
Date: Sat, 4 Mar 2023 10:49:04 +1300
Subject: [PATCH 3/3] executor: remove redundant _prepare_directory_archive
method
---
src/poetry/installation/executor.py | 25 ++-----------------------
1 file changed, 2 insertions(+), 23 deletions(-)
diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py
index e0adcde994f..22972882fcb 100644
--- a/src/poetry/installation/executor.py
+++ b/src/poetry/installation/executor.py
@@ -506,7 +506,7 @@ def _install(self, operation: Install | Update) -> int:
elif package.source_type == "file":
archive = self._prepare_archive(operation)
elif package.source_type == "directory":
- archive = self._prepare_directory_archive(operation)
+ archive = self._prepare_archive(operation)
cleanup_archive = True
elif package.source_type == "url":
assert package.source_url is not None
@@ -578,27 +578,6 @@ def _prepare_archive(self, operation: Install | Update) -> Path:
return self._chef.prepare(archive, editable=package.develop)
- def _prepare_directory_archive(self, operation: Install | Update) -> Path:
- package = operation.package
- operation_message = self.get_operation_message(operation)
-
- message = (
- f" • {operation_message}:"
- " Building..."
- )
- self._write(operation, message)
-
- assert package.source_url is not None
- if package.root_dir:
- req = package.root_dir / package.source_url
- else:
- req = Path(package.source_url).resolve(strict=False)
-
- if package.source_subdirectory:
- req /= package.source_subdirectory
-
- return self._prepare_archive(operation)
-
def _prepare_git_archive(self, operation: Install | Update) -> Path:
from poetry.vcs.git import Git
@@ -621,7 +600,7 @@ def _prepare_git_archive(self, operation: Install | Update) -> Path:
original_url = package.source_url
package._source_url = str(source.path)
- archive = self._prepare_directory_archive(operation)
+ archive = self._prepare_archive(operation)
package._source_url = original_url