Skip to content

python3Packages.tensorflow: avoid deprecated override of pybind11#479764

Merged
leona-ya merged 1 commit intoNixOS:masterfrom
mjoerg:tensorflow-pybind11-stdenv
Jan 14, 2026
Merged

python3Packages.tensorflow: avoid deprecated override of pybind11#479764
leona-ya merged 1 commit intoNixOS:masterfrom
mjoerg:tensorflow-pybind11-stdenv

Conversation

@mjoerg
Copy link
Contributor

@mjoerg mjoerg commented Jan 13, 2026

This change is necessary after #476384 to avoid the warning shown below.

$ NIXPKGS_ALLOW_BROKEN=1 nix eval --impure --experimental-features 'nix-command flakes' github:NixOS/nixpkgs/110493e24696e74e793ce4da869b44c0581197ec#libtensorflow
evaluation warning: pybind11: Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
                      buildPythonPackage.override { stdenv = customStdenv; } { }
«derivation /nix/store/fhf64r49xvf00rx30mw3sy5jnj0fg7z9-tensorflow-2.13.0.drv»
$ NIXPKGS_ALLOW_BROKEN=1 nix eval --impure --experimental-features 'nix-command flakes' github:NixOS/nixpkgs/4d8ab9da2b93d936961827440656b384689d8d80#libtensorflow
«derivation /nix/store/fhf64r49xvf00rx30mw3sy5jnj0fg7z9-tensorflow-2.13.0.drv»

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@mjoerg mjoerg closed this Jan 13, 2026
@mjoerg mjoerg reopened this Jan 13, 2026
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 6.topic: python Python is a high-level, general-purpose programming language. labels Jan 13, 2026
@mjoerg mjoerg requested a review from leona-ya January 13, 2026 18:15
@nixpkgs-ci nixpkgs-ci bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Jan 13, 2026
@leona-ya
Copy link
Member

@MattSturgeon, @ShamrockLee is this the best solution?

Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

is this the best solution?

Assuming stdenv actually needs overriding, as per the existing code, then yes: this is essentially the only way to build pybind11 with a different stdenv.

Under the hood, the deprecation/compatibility layer does the same thing; overriding buildPythonPackage with the supplied stdenv:

'' (f'.override { inherit (args) stdenv; } (removeAttrs args [ "stdenv" ]))

Comment on lines +333 to +337
(pybind11.override {
buildPythonPackage = buildPythonPackage.override {
inherit stdenv;
};
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd typically override the previous attr, rather than supplying another one from this scope:

Suggested change
(pybind11.override {
buildPythonPackage = buildPythonPackage.override {
inherit stdenv;
};
})
(pybind11.override (prev: {
buildPythonPackage = prev.buildPythonPackage.override { inherit stdenv; };
}))

In practice, they're probably the same. But it's technically possible that someone has an overlay in which pybind11 receives a different buildPythonPackage to this package.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 13, 2026
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
@mjoerg mjoerg force-pushed the tensorflow-pybind11-stdenv branch from 758f4ef to 4d8ab9d Compare January 14, 2026 15:33
@leona-ya leona-ya added this pull request to the merge queue Jan 14, 2026
Merged via the queue into NixOS:master with commit 0ee4263 Jan 14, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants