Skip to content

Conversation

@3pleX-dev
Copy link
Contributor

Things done

Should resolve #384709
@raboof please help review

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Apr 9, 2025
@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 5c8f788 to 3e16215 Compare April 9, 2025 06:02
@github-actions github-actions bot added 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Apr 9, 2025
@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch 2 times, most recently from e89674b to 8e8365c Compare April 9, 2025 06:17
Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

As you say in #384708 (comment) it's a dilemma whether we should apply this fix 'surgically' to packages that are known to be affected, or to the 'global' setuptools package.

I think applying it 'surgically' in nixpkgs while discussing it for 'global' inclusion upstream might be a reasonable start.

@3pleX-dev
Copy link
Contributor Author

As you say in #384708 (comment) it's a dilemma whether we should apply this fix 'surgically' to packages that are known to be affected, or to the 'global' setuptools package.

I think applying it 'surgically' in nixpkgs while discussing it for 'global' inclusion upstream might be a reasonable start.

Thanks! That sounds like a good approach to me—Would you like me open an upstream issue or PR to start the conversation?

@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch 2 times, most recently from c803168 to 4f42425 Compare April 9, 2025 10:32
@raboof
Copy link
Member

raboof commented Apr 9, 2025

I think applying it 'surgically' in nixpkgs while discussing it for 'global' inclusion upstream might be a reasonable start.

Thanks! That sounds like a good approach to me—Would you like me open an upstream issue or PR to start the conversation?

Yeah go for it!

@mweinelt
Copy link
Member

mweinelt commented Apr 9, 2025

The wheel builder in this case would be https://github.com/PyO3/maturin.

@raboof
Copy link
Member

raboof commented Apr 9, 2025

The wheel builder in this case would be https://github.com/PyO3/maturin.

Really? But then that patch shouldn't have had any effect, right? As that seems to patch https://github.com/pypa/wheel/blob/main/src/wheel/wheelfile.py#L232 ?

@raboof raboof self-requested a review April 9, 2025 12:28
@mweinelt
Copy link
Member

mweinelt commented Apr 9, 2025

Not sure what modifying the build system like that will do, but the build does in fact use maturin.

error: derivation '1kz0sb3y7fm8sm0b1kbyad0r2w8gzl4b-python3.12-pydantic-core-2.27.2.drv' may not be deterministic: outputs differ
         output '/nix/store/7jj8r27i84c2fmkmmpy36dqq3hb2h9r8-python3.12-pydantic-core-2.27.2-dist' differs
         output '/nix/store/vl8yhs7qr9w4h0hqr4g35q303l7jvczn-python3.12-pydantic-core-2.27.2' differs

No visible effect.

@mweinelt mweinelt marked this pull request as draft April 9, 2025 12:51
@3pleX-dev
Copy link
Contributor Author

Not sure what modifying the build system like that will do, but the build does in fact use maturin.

error: derivation '1kz0sb3y7fm8sm0b1kbyad0r2w8gzl4b-python3.12-pydantic-core-2.27.2.drv' may not be deterministic: outputs differ
         output '/nix/store/7jj8r27i84c2fmkmmpy36dqq3hb2h9r8-python3.12-pydantic-core-2.27.2-dist' differs
         output '/nix/store/vl8yhs7qr9w4h0hqr4g35q303l7jvczn-python3.12-pydantic-core-2.27.2' differs

No visible effect.

Thank you for the feedback @mweinelt, I'll look again into the source and maturin to see what actually causes the ordering differences.

@3pleX-dev
Copy link
Contributor Author

So I checked the source and didn’t find anything suspicious there. Then I decided to look into other Nix packages that use the maturin hook to see if they had the same ordering issue—and I confirmed that at least four other packages show the same problem. I didn’t keep going after that since it was clear the issue likely originates from maturin.

I took a look at the maturin source code (I'm not very familiar with Rust), but I tried patching #L156 and #L392 to sort the self.record before writing to the RECORD file, and the patch seems to work fine.

I'll push my update shortly and also propose this in a pr upstream

@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 4f42425 to 132ae2a Compare April 10, 2025 12:10
@3pleX-dev
Copy link
Contributor Author

3pleX-dev commented Apr 10, 2025

@raboof since this issue affects other packages, I don't this change should be in this pr right? it should be on the maturin package itself.

Also I don't think I'm applying this patch the right way and it looks like the build system is deceiving me just like when I patched the python setuptools wheel. If you notice I commented out the sort commands in the patch but somehow this ends up building with no differences.

Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

since you verified other modules that use maturin are also affected, it might indeed make more sense to create a PR against the maturin package.

@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 132ae2a to 47b0ed9 Compare April 10, 2025 13:14
@github-actions github-actions bot removed the 6.topic: python Python is a high-level, general-purpose programming language. label Apr 10, 2025
@3pleX-dev 3pleX-dev changed the title pydantic-core: Sorts RECORD file in wheel archives to make them deterministic maturin: Sorts RECORD file in wheel archives to make them deterministic Apr 10, 2025
@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 47b0ed9 to 405e953 Compare April 10, 2025 13:15
@raboof raboof self-requested a review April 10, 2025 13:15
@raboof raboof added the 6.topic: python Python is a high-level, general-purpose programming language. label Apr 10, 2025
@3pleX-dev 3pleX-dev marked this pull request as ready for review April 10, 2025 13:17
@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. and removed 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. labels Apr 10, 2025
@nix-owners nix-owners bot requested a review from getchoo April 10, 2025 13:26
@raboof
Copy link
Member

raboof commented Apr 10, 2025

Since this PR now causes many rebuilds, you'll likely want it to target staging. For more information, see https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#changes-causing-mass-rebuilds

@mweinelt
Copy link
Member

mweinelt commented Apr 10, 2025

Thanks for submitting this upstream. I think we're not in a hurry to land this in 25.05, so we can wait for some review upstream.

@3pleX-dev 3pleX-dev changed the base branch from master to staging April 11, 2025 13:48
@github-actions github-actions bot removed the 6.topic: python Python is a high-level, general-purpose programming language. label Apr 11, 2025
@3pleX-dev
Copy link
Contributor Author

Hi @raboof, the upstream pr has been merged :)

@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 405e953 to 2f9995f Compare April 11, 2025 14:12
@raboof
Copy link
Member

raboof commented Apr 11, 2025

Hi @raboof, the upstream pr has been merged :)

that is awesome, congratulations!

since AFAIK none of the packages in our milestones (ISO runtime closures) are affected by this issue, I agree with @mweinelt that we're not in a particular rush to get this in. Upstream seems to be making regular releases, so we could consider just waiting for that release. Up to the maintainer (@getchoo) I'd say.

@3pleX-dev
Copy link
Contributor Author

Hi @raboof, the upstream pr has been merged :)

that is awesome, congratulations!

Thank you ❤️

since AFAIK none of the packages in our milestones (ISO runtime closures) are affected by this issue, I agree with @mweinelt that we're not in a particular rush to get this in. Upstream seems to be making regular releases, so we could consider just waiting for that release. Up to the maintainer (@getchoo) I'd say.

Okay no problem at all. I've include a comment that the patch should be removed on the next version bump

Copy link
Member

@getchoo getchoo left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM. Thanks for getting this upstreamed!

@3pleX-dev 3pleX-dev force-pushed the update-pydantic-core branch from 2f9995f to 7b88be4 Compare April 17, 2025 21:55
Copy link
Member

@getchoo getchoo left a comment

Choose a reason for hiding this comment

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

Thanks again!

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 397290 --package python312Packages.cryptography --package maturin


x86_64-linux

✅ 3 packages built:
  • maturin
  • python312Packages.cryptography
  • python312Packages.cryptography.dist (python312Packages.cryptography.dist.dist)

@getchoo getchoo added backport staging-24.11 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. 6.topic: reproducible builds Run nix-build twice and get the same result. labels Apr 18, 2025
@getchoo getchoo merged commit a4db081 into NixOS:staging Apr 18, 2025
27 of 31 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Apr 18, 2025

@3pleX-dev
Copy link
Contributor Author

Thank you all for your help with this. I'm excited to see this get merged! 🥹🙏

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

Labels

6.topic: reproducible builds Run nix-build twice and get the same result. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unreproducible Package: python3Packages.pydantic-core

4 participants