Skip to content

fix(pdm): support lock-spec >=4.5#122

Draft
betaboon wants to merge 1 commit intojvolkman:mainfrom
betaboon:fix-pdm-lock-spec-4.5
Draft

fix(pdm): support lock-spec >=4.5#122
betaboon wants to merge 1 commit intojvolkman:mainfrom
betaboon:fix-pdm-lock-spec-4.5

Conversation

@betaboon
Copy link
Collaborator

@betaboon betaboon commented Oct 2, 2024

We're now running into similar issues as #115.

I know this change is most likely insufficient, but unblocks us for now.

let's take this as a starting point for discussion :)



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?

@rparme
Copy link

rparme commented Jan 22, 2025

I have the same issue. This workaround let me move forward but I can't migrate to Bazel 8.

@jvolkman
Copy link
Owner

but I can't migrate to Bazel 8.

Because of these rules? There have been some recent Bazel 8 fixes, although they haven't been released to BCR yet.

@rparme
Copy link

rparme commented Jan 23, 2025

When I ran into this issue at first, I started to use this workaround with git_override. To migrate to Bazel 8, I needed #133 and until this one (#122) is fixed, I won't be able to have both, am I? I could still apply a patch locally but I'm not that desperate =)

@betaboon
Copy link
Collaborator Author

i think this workaround is far from correct.
I'm not using pdm anymore, so i don't really have the motivation to finish this right now.
so anyone that uses pdm: feel free to pick this up.

@rparme
Copy link

rparme commented Jan 23, 2025

Agreed and I'm starting to doubt this is actually the source of my issue. I tried uv instead ofpdm but as soon as I upgrade to pycross 0.7.1 I get the same error:

ERROR: error loading package 'alma/stamp_api': at /home/alma/almaio/tools/build_rules/prelude_bazel:5:6: Encountered error while reading extension file 'requirements.bzl': no such package '@@rules_pycross~~lock_repos~pdm_deps//': no such package '@@rules_pycross~~lock_import~pdm_deps//': Internal command failed: ["/home/alma/.cache/bazel/_bazel_alma/9f48f5f58a3505b48420e308b148cf88/external/rules_pycross~~pycross~rules_pycross_internal/exec_venv/bin/python", "/home/alma/.cache/bazel/_bazel_alma/9f48f5f58a3505b48420e308b148cf88/external/rules_pycross~/pycross/private/tools/pdm_translator.py", "--project-file", "/home/alma/almaio/pyproject.toml", "--lock-file", "/home/alma/almaio/pdm.lock", "--output", "raw_lock.json", "--default", "--require-static-urls"]
Traceback (most recent call last):
  File "/home/alma/.cache/bazel/_bazel_alma/9f48f5f58a3505b48420e308b148cf88/external/rules_pycross~/pycross/private/tools/pdm_translator.py", line 395, in <module>
    main(parse_flags())
  File "/home/alma/.cache/bazel/_bazel_alma/9f48f5f58a3505b48420e308b148cf88/external/rules_pycross~/pycross/private/tools/pdm_translator.py", line 307, in main
    lock_set = translate(
               ^^^^^^^^^^
  File "/home/alma/.cache/bazel/_bazel_alma/9f48f5f58a3505b48420e308b148cf88/external/rules_pycross~/pycross/private/tools/pdm_translator.py", line 264, in translate
    raise MismatchedVersionException(
MismatchedVersionException: Found no packages to satisfy dependency (name=importlib-resources, spec=)

@rparme
Copy link

rparme commented Feb 14, 2025

To whoever comes here, I managed to migrate to uv following example from e2e/. No more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants