-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Prevent Pants from inserting lock file header with local machine binary path #18202
Comments
@rafrafek I'm going to transfer this over to the Pants repo - this will need to be solved in the Pants codebase unless I'm mistaken. |
The lock file generation helper code here: pants/src/python/pants/backend/python/goals/lockfile.py Lines 213 to 218 in d12d1b9
Uses this utility: pants/src/python/pants/util/docutil.py Lines 28 to 39 in d12d1b9
@rafrafek you can, of course, work around by noting the |
I think the If Finally, if |
This affects both Python and JVM lock file generation since both add headers and both use the |
I've renamed
Result:
|
Checking the PATH seems more trouble than it's worth. I think we can always take the basename (and add I'll work up a PR. PS I noticed this issue in |
Thanks for the report @rafrafek |
Actually, does this need to be fixed in Pants? Looks like scie-pants sets And probably should set it to just |
Unfortunately, as @rafrafek has discovered, you can't override this by setting |
Well, pants should be defensive and not care how its called. PANTS_BIN_NAME can be set by anybody to anything as this shows. Let me look at scie-pants though. The obvious aside here is Pants should simply not be adding headers to lock files! An issue tracks that though. |
True on both counts, but in this case scie-pants shouldn't be setting that option to the full path, since the intent of the option is "display this to end users in help messages and so on". Apparently at some point along the way this ended up in lockfile headers (which, I agree, should not be a thing) and that is where we should have gotten defensive. I suggest both changing scie-pants to set |
I'll do better and do the right thing in scie-pants and set the bin-name to the basename if PATH / abs path otherwise. If the basename is actually |
Also #18204 |
@rafrafek if you upgrade scie-pants to 0.5.0 ( |
I've ran Result:
It is still different than the one from example project:
|
I think it is duplicate of #15740 I don't understand why we need this header at all. Having metadata like "generated_with_requirements", instructions and other stuff in a lock file which is supposed to be handled by tools does not make sense to me. I don't understand Pants lock file because it is not lock file when you cannot validate it against pinned dependencies nor update it without bumping every dependency versions. There should be two files in a project repository, one containing pinned dependencies (.txt/.toml file etc.) and one containing locked versions of dependencies and sub-dependencies (lock file). Poetry is one example of how lock files can be handled. See #15723 (comment) |
@rafrafek if I understand correctly, being different from the example is OK. What you care about is consistency across machines. The scie-pants 0.5.0 fix only gets you this if all your users install pants in the recommended way. So the ultimate fix will need to come from Pants indeed. @benjyw's work in #18204 won't get you that assurance either IIUC. You can have that assurance today with the workaround I described above, check in the following to your [generate-lockfiles]
custom_command = "whatever fixed string you'd like to have" Clearly Pants needs to fix this to provide guaranteed uniformity though in the longer run. |
This does already exist, I think the issue is in how the |
Thanks! The toml config is much better for providing consistency across machines than the |
Thanks! Now I see how it helps with multiple requirements.txt files. Coming from Poetry it wasn't clear for me. |
How can I prevent Pants from inserting this into the lock file?
I want the lock file to be the same no matter which machine created it. And I don't want to store my local machine paths in git repo.
I've tried with:
But it will create instruction that is not valid:
Trying to fix it using
--generate-lockfiles-custom-command
would lead to something like--generate-lockfiles-custom-command="./pants generate-lockfiles --generate-lockfiles-custom-command='recursion here?'"
The text was updated successfully, but these errors were encountered: