Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: git subdirectory dependencies fail to resolve with a TypeError on name #5479

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def search_for_vcs(self, dependency: VCSDependency) -> list[Package]:
tag=dependency.tag,
rev=dependency.rev,
name=dependency.name,
directory=dependency.directory,
)
package.develop = dependency.develop

Expand All @@ -179,6 +180,7 @@ def get_package_from_vcs(
tag: str | None = None,
rev: str | None = None,
name: str | None = None,
directory: str | None = None,
) -> Package:
if vcs != "git":
raise ValueError(f"Unsupported VCS dependency {vcs}")
Expand All @@ -197,7 +199,9 @@ def get_package_from_vcs(

revision = git.rev_parse(reference, tmp_dir).strip()

package = cls.get_package_from_directory(tmp_dir, name=name)
package = cls.get_package_from_directory(
tmp_dir / directory if directory else tmp_dir, name=name
)
package._source_type = "git"
package._source_url = url
package._source_reference = reference
Expand Down
17 changes: 17 additions & 0 deletions tests/fixtures/git/github.com/demo/subdir/example/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations

from setuptools import setup


kwargs = dict(
name="example",
license="MIT",
version="0.1.2",
description="Demo project.",
author="Sébastien Eustace",
author_email="sebastien@eustace.io",
url="https://github.com/demo/subdir",
)


setup(**kwargs)
27 changes: 27 additions & 0 deletions tests/fixtures/project_with_git_subdir_dependency/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tool.poetry]
name = "project-with-git-subdir-dependency"
version = "1.2.3"
description = "Some description."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
]
license = "MIT"

homepage = "https://python-poetry.org"
repository = "https://github.com/python-poetry/poetry"
documentation = "https://python-poetry.org/docs"

keywords = ["packaging", "dependency", "poetry"]

classifiers = [
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules"
]

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
example = { git = "https://github.com/demo/subdir.git", rev = "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24", subdirectory = "example" }

[tool.poetry.dev-dependencies]
pytest = "~3.4"
12 changes: 12 additions & 0 deletions tests/puzzle/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,15 @@ def test_search_for_file_wheel_with_extras(provider: Provider):
"foo": [get_dependency("cleo")],
"bar": [get_dependency("tomlkit")],
}


def test_search_for_vcs_hyphenated_name(provider: Provider):
dependency = DirectoryDependency(
"project-with-git-subdir-dependency",
Path(__file__).parent.parent
/ "fixtures"
/ "project_with_git_subdir_dependency",
)

package = provider.search_for_directory(dependency)[0]
provider.search_for_vcs(package.requires[0])