Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 committed Apr 5, 2022
1 parent 9df4582 commit 0f464f9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def handle(self) -> int:
if "version" in _constraint:
# Validate version constraint
parse_constraint(_constraint["version"])
if "subdirectory" in _constraint and _constraint["subdirectory"] is None:
del _constraint["subdirectory"]

constraint = inline_table()
for name, value in _constraint.items():
Expand Down
7 changes: 6 additions & 1 deletion src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _parse_requirements(self, requirements: list[str]) -> list[dict[str, Any]]:
if parsed.rev:
pair["rev"] = url.revision

if hasattr(parsed, "subdirectory"):
if parsed.subdirectory:
pair["subdirectory"] = url.subdirectory

if extras:
Expand Down Expand Up @@ -545,6 +545,11 @@ def _format_requirements(
if "version" in requirement and len(requirement) == 1:
constraint = requirement["version"]
else:
if (
"subdirectory" in requirement
and requirement["subdirectory"] is None
):
del requirement["subdirectory"]
constraint = inline_table()
constraint.trivia.trail = "\n"
constraint.update(requirement)
Expand Down
2 changes: 2 additions & 0 deletions src/poetry/console/commands/plugin/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def handle(self) -> int:
if "version" in plugin:
# Validate version constraint
parse_constraint(plugin["version"])
if "subdirectory" in plugin and plugin["subdirectory"] is None:
del plugin["subdirectory"]

constraint = tomlkit.inline_table()
for name, value in plugin.items():
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _install_git(self, operation: Install | Update) -> int:

# Now we just need to install from the source directory
original_url = package.source_url
if hasattr(package, "source_subdirectory"):
if package.source_subdirectory:
package._source_url = str(src_dir / Path(package.source_subdirectory))
else:
package._source_url = str(src_dir)
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def _dump_package(self, package: Package) -> dict:
if package.source_resolved_reference:
data["source"]["resolved_reference"] = package.source_resolved_reference

if hasattr(package, "source_subdirectory"):
if package.source_subdirectory:
data["source"]["source_subdirectory"] = package.source_subdirectory

if package.source_type in ["directory", "git"]:
Expand Down
4 changes: 1 addition & 3 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,13 @@ def search_for_vcs(self, dependency: VCSDependency) -> list[Package]:
if dependency in self._deferred_cache:
return [self._deferred_cache[dependency]]

directory = dependency.directory if hasattr(dependency, "directory") else None

package = self.get_package_from_vcs(
dependency.vcs,
dependency.source,
branch=dependency.branch,
tag=dependency.tag,
rev=dependency.rev,
directory=directory,
directory=dependency.directory,
name=dependency.name,
)
package.develop = dependency.develop
Expand Down

0 comments on commit 0f464f9

Please sign in to comment.