-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
feat: make lockfile contain urls instead of filenames #1203
Conversation
Hello @betaboon, is there an open issue that discusses this change? If so, could you link to it in the PR description? I'd like to understand the reasoning behind it 🙂 I think NPM puts the resolved URL in the lock file as well, maybe you got inspired by other package managers? |
@pawamoy i added some context-explanation to the description. hope that clears it up a little :) |
I am sorry, it seems we should bump the major version, let's make it |
Which one do you prefer? I can do either. I think minor (aka adding URL instead of replacing filename) might prevent some migration problems for ppl. On the other hand since you're aiming for a 2.0 release might be the perfect time to introduce a "breaking" change |
At this point it is okay to make a major bump, the PDM can regenerate the lock file automatically if it sees an incompatible lock file version when doing installation. |
@betaboon Thanks! |
bumped |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1203 +/- ##
==========================================
+ Coverage 81.08% 81.20% +0.12%
==========================================
Files 93 93
Lines 7596 7597 +1
Branches 1792 1792
==========================================
+ Hits 6159 6169 +10
+ Misses 1082 1076 -6
+ Partials 355 352 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
tests/fixtures/projects/demo-package-has-dep-with-extras/pdm.lock
Outdated
Show resolved
Hide resolved
@@ -1,14 +1,22 @@ | |||
click==7.1.2 \ | |||
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc \ | |||
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash seems duplicating, maybe some bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i noticed that yesterday to.
this is actually due to: https://github.com/pdm-project/pdm/blob/main/pdm/project/config.py#L36-L39
since there are two default-repositories, there are two hashes for each file (one for each repository).
the way to prevent duplicate hashes would be using a set
here. but that would change the order of hashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually due to: https://github.com/pdm-project/pdm/blob/main/pdm/project/config.py#L36-L39
I doubt that, though a bit confusing, the default repositories are for uploading packages, and have nothing to do with downloading and fetching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you take a look at the generated pdm.lock
it also contains files from both repositories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so it is because of the source settings:
[[tool.pdm.source]]
url = "https://test.pypi.org/simple"
verify_ssl = true
name = "testpypi"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah you're right. it's due to pyproject.toml
in the example projects.
i think we should only do deduplication of hashes in the requirements.txt
i see value in having multiple urls for the same package in the pdm.lock
as it allows fallback. imagine the case where the first source is available at lock-time, not not available at install time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imagine the case where the first source is available at lock-time, not not available at install time.
Sounds sensible, then we will implement the behavior I mentioned in the gist:
When installing from the lock file, take the links stored with the lock file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two questions:
- should i add hash-deduplication in
requirements.txt
-export as mentioned above? - can you take care of the "take links from lock file during install" (in a seperate PR)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, of course
Second, of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can you please add a release note under I've added one.news
folder?
In pdm-project#1203 pdm.lock was changed to store a list of URLs rather than wheel names. That change caused a regression because we were sorting the output based on filename only, not the full URL. This caused unnecessary lockfile changes in our CI environment. Fixes pdm-project#1256
In pdm-project#1203 pdm.lock was changed to store a list of URLs rather than wheel names. That change caused a regression because we were sorting the output based on filename only, not the full URL. This caused unnecessary lockfile changes in our CI environment. Fixes pdm-project#1256
* Fix doc * Make pdm.lock metadata.files sorting idempotent In #1203 pdm.lock was changed to store a list of URLs rather than wheel names. That change caused a regression because we were sorting the output based on filename only, not the full URL. This caused unnecessary lockfile changes in our CI environment. Fixes #1256 Co-authored-by: Hashem Nasarat <hnasarat@beta.team>
Pull Request Check List
news/
describing what is new.Describe what you have changed in this PR.
This PR changes the lockfile to contain full urls instead of just the filenames.
Context
I'm coming from efforts in the bazel world to properly integrate cross-platform python-lockfiles. (the effort in question is here )
There we stumbled upon the problem that it is hard to resolve filenames in lockfiles to urls and it would be alot easier if the lockfiles would already include the urls, as the tool creating the lockfile should already have the knowledge about the urls.
I hacked together a little patch the does that with pdm and talked to @frostming on discord, who signaled interest in this change.
so here we are ;)