Skip to content
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

python3Packages.pycparser: fix test failures #358147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aviallon
Copy link
Contributor

The check phase failed for pkgsStatic because "cpp" or "gcc" could not be found.
Replace "cpp" and "gcc" usage by ${gcc}/bin/{cpp,gcc} to fix the tests.

Things done

  • Built on platform(s)
    • x86_64-linux
    • x86_64-unknown-linux-musl
    • 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.

disabled = pythonOlder "3.8";

nativeCheckInputs = [
unittestCheckHook
gcc
Copy link
Member

Choose a reason for hiding this comment

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

I doubt gcc is correct on plaforms that use clang. Also providing gcc is rarely correct, it should probably be
pkgsBuildBuild.stdenv.cc which provides you with both the compiler and linker probably. This way when you cross compile pycparser to musl (pkgsStatic for example) you don't need to compile pkgsStatic.gcc, using the build platform is enough.

This way:

diff --git a/pkgs/development/python-modules/pycparser/default.nix b/pkgs/development/python-modules/pycparser/default.nix
index 33a8b12fc707..d18091667ce8 100644
--- a/pkgs/development/python-modules/pycparser/default.nix
+++ b/pkgs/development/python-modules/pycparser/default.nix
@@ -5,7 +5,7 @@
   setuptools,
   unittestCheckHook,
   pythonOlder,
-  gcc,
+  pkgsBuildBuild,
 }:
 
 buildPythonPackage rec {
@@ -20,9 +20,9 @@ buildPythonPackage rec {
 
   postPatch = ''
     substituteInPlace tests/test_util.py examples/using_cpp_libc.py pycparser/__init__.py \
-      --replace-fail "'cpp'" "'${lib.getBin gcc}/bin/cpp'"
+      --replace-fail "'cpp'" "'${pkgsBuildBuild.stdenv.cc.targetPrefix}cpp'"
     substituteInPlace tests/test_util.py examples/using_gcc_E_libc.py \
-      --replace-warn "'gcc'" "'${lib.getBin gcc}/bin/gcc'"
+      --replace-warn "'gcc'" "'${pkgsBuildBuild.stdenv.cc.targetPrefix}cc'"
   '';
 
   build-system = [ setuptools ];
@@ -31,7 +31,7 @@ buildPythonPackage rec {
 
   nativeCheckInputs = [
     unittestCheckHook
-    gcc
+    pkgsBuildBuild.stdenv.cc
   ];
 
   unittestFlagsArray = [

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, indeed.

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

Successfully merging this pull request may close these issues.

2 participants