From 828339e9b1e6647eaa482a1e0c58efd564ce56b6 Mon Sep 17 00:00:00 2001 From: Greg Curtis Date: Mon, 9 Sep 2024 18:05:01 -0400 Subject: [PATCH 1/2] patchpkg: patch missing Python refs on darwin This enables the part of Python patching that restores some build dependencies on macOS. This fixes some `pip install` build errors for packages without needing to manually add dev dependencies on packages like openssl. --- internal/devpkg/package.go | 2 +- internal/patchpkg/builder.go | 2 +- internal/shellgen/tmpl/glibc-patch.nix.tmpl | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/devpkg/package.go b/internal/devpkg/package.go index 35e7b17a494..39ab3d5dbbf 100644 --- a/internal/devpkg/package.go +++ b/internal/devpkg/package.go @@ -189,7 +189,7 @@ func patchGlibcFunc(canonicalName string, mode configfile.PatchMode) func() bool } // Check nix.SystemIsLinux() last because it's slow. - return patch && nix.SystemIsLinux() + return patch }) } diff --git a/internal/patchpkg/builder.go b/internal/patchpkg/builder.go index a42522579ce..5be3f771bd3 100644 --- a/internal/patchpkg/builder.go +++ b/internal/patchpkg/builder.go @@ -232,7 +232,7 @@ func (d *DerivationBuilder) needsGlibcPatch(file *bufio.Reader, filePath string) func (d *DerivationBuilder) findRemovedRefs(ctx context.Context, pkg *packageFS) ([]fileSlice, error) { var refs []fileSlice - matches, err := fs.Glob(pkg, "lib/python*/_sysconfigdata__linux*.py") + matches, err := fs.Glob(pkg, "lib/python*/_sysconfigdata_*.py") if err != nil { return nil, err } diff --git a/internal/shellgen/tmpl/glibc-patch.nix.tmpl b/internal/shellgen/tmpl/glibc-patch.nix.tmpl index d07d1b042c3..ea90a044710 100644 --- a/internal/shellgen/tmpl/glibc-patch.nix.tmpl +++ b/internal/shellgen/tmpl/glibc-patch.nix.tmpl @@ -73,7 +73,10 @@ builtins.map (drv: drv.outPath) mkTree; # Programs needed by glibc-patch.bash. - inherit (nixpkgs-glibc.legacyPackages."${system}") bash coreutils glibc gnused patchelf ripgrep; + inherit (nixpkgs-glibc.legacyPackages."${system}") bash coreutils gnused patchelf ripgrep; + + isLinux = (builtins.match ".*linux.*" system) != null; + glibc = if isLinux then nixpkgs-glibc.legacyPackages."${system}".glibc else null; # Create a package that puts the local devbox binary in the conventional # bin subdirectory. This also ensures that the executable is named @@ -92,7 +95,9 @@ DEVBOX_DEBUG = 1; builder = "${devbox}/bin/devbox"; - args = [ "patch" "--restore-refs" "--glibc" glibc pkg ]; + args = [ "patch" "--restore-refs" ] ++ + (if glibc != null then [ "--glibc" "${glibc}" ] else [ ]) ++ + [ pkg ]; }; in { From 73a524ea7b372d4d7a4d141e6a4c442ce9631778 Mon Sep 17 00:00:00 2001 From: Greg Curtis Date: Tue, 10 Sep 2024 12:21:31 -0400 Subject: [PATCH 2/2] Remove outdated comment --- internal/devpkg/package.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/devpkg/package.go b/internal/devpkg/package.go index 39ab3d5dbbf..892569e8dc1 100644 --- a/internal/devpkg/package.go +++ b/internal/devpkg/package.go @@ -187,8 +187,6 @@ func patchGlibcFunc(canonicalName string, mode configfile.PatchMode) func() bool case configfile.PatchNever: patch = false } - - // Check nix.SystemIsLinux() last because it's slow. return patch }) }