Skip to content

Commit

Permalink
Fix misuse of pretty_constraint exposed by downstream test after fix …
Browse files Browse the repository at this point in the history
…in poetry-core
  • Loading branch information
radoering authored and neersighted committed Jan 23, 2022
1 parent 3396769 commit b70d260
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ def __walk_dependency_level(
if locked_package:
# create dependency from locked package to retain dependency metadata
# if this is not done, we can end-up with incorrect nested dependencies
constraint = requirement.constraint
pretty_constraint = requirement.pretty_constraint
marker = requirement.marker
requirement = locked_package.to_dependency()
requirement.marker = requirement.marker.intersect(marker)

key = (requirement.name, requirement.pretty_constraint)
key = (requirement.name, pretty_constraint)

if pinned_versions:
requirement.set_constraint(
locked_package.to_dependency().constraint
)
if not pinned_versions:
requirement.set_constraint(constraint)

for require in locked_package.requires:
if require.marker.is_empty():
Expand Down
19 changes: 14 additions & 5 deletions src/poetry/utils/exporter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import urllib.parse

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -69,13 +70,21 @@ def _export_requirements_txt(
content = ""
dependency_lines = set()

for dependency_package in self._poetry.locker.get_project_dependency_packages(
project_requires=self._poetry.package.all_requires, dev=dev, extras=extras
for package, groups in itertools.groupby(
self._poetry.locker.get_project_dependency_packages(
project_requires=self._poetry.package.all_requires,
dev=dev,
extras=extras,
),
lambda dependency_package: dependency_package.package,
):
line = ""

dependency = dependency_package.dependency
package = dependency_package.package
dependency_packages = list(groups)
dependency = dependency_packages[0].dependency
marker = dependency.marker
for dep_package in dependency_packages[1:]:
marker = marker.union(dep_package.dependency.marker)
dependency.marker = marker

if package.develop:
line += "-e "
Expand Down

0 comments on commit b70d260

Please sign in to comment.