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(pdm): support lock-spec >=4.5 #122

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
21 changes: 20 additions & 1 deletion pycross/private/tools/pdm_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def get_development_dependencies(lock: Dict[str, Any]) -> Dict[str, List[Require
return {group: [Requirement(EDITABLE_PATTERN.sub("", dep)) for dep in deps] for group, deps in dep_groups.items()}


def get_excluded_packages(lock: Dict[str, Any]) -> List[str]:
packages = lock.get("tool", {}).get("pdm", {}).get("resolution", {}).get("excludes", [])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this section? Do you have an example lock file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we make use of tool.pdm.resolution.excludes.
packages listed there will also not be contained in the lockfile, that's why i explicitly filter them out here.
I'm not completely sure if this is required or not.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So this seems orthogonal to the multi-platform issue from #115, right? If that's the case, I don't have a problem with this change. It seems like we'll need to handle both cases.

Do you know why the tests are failing?

return packages


def _print_warn(msg):
print("WARNING:", msg)

Expand Down Expand Up @@ -203,7 +208,10 @@ def translate(
pin = package_canonical_name(req.name)
pinned_package_specs[pin] = req

excluded_packages = get_excluded_packages(project_dict)

distinct_packages: Dict[PackageKey, PDMPackage] = {}

# Pull out all Package entries in a pdm-specific model.
for lock_pkg in lock_dict.get("package", []):
package_listed_name = lock_pkg["name"]
Expand All @@ -216,7 +224,18 @@ def translate(
# Special case for all python versions
package_requires_python = ""

dependencies = {Requirement(dep) for dep in lock_pkg.get("dependencies", [])}
dependencies = set()
for dep in lock_pkg.get("dependencies", []):
req = Requirement(dep)

if req.name in excluded_packages:
continue

if req.marker and not req.marker.evaluate():
continue

dependencies.add(req)

files = {parse_file_info(f) for f in lock_pkg.get("files", [])}
is_local = "path" in lock_pkg and "files" not in lock_pkg

Expand Down
Loading