Skip to content

Commit aaf5670

Browse files
authored
patchpkg: patch missing Python refs on darwin (#2258)
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.
1 parent afa6187 commit aaf5670

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

internal/devpkg/package.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ func patchGlibcFunc(canonicalName string, mode configfile.PatchMode) func() bool
187187
case configfile.PatchNever:
188188
patch = false
189189
}
190-
191-
// Check nix.SystemIsLinux() last because it's slow.
192-
return patch && nix.SystemIsLinux()
190+
return patch
193191
})
194192
}
195193

internal/patchpkg/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (d *DerivationBuilder) needsGlibcPatch(file *bufio.Reader, filePath string)
232232

233233
func (d *DerivationBuilder) findRemovedRefs(ctx context.Context, pkg *packageFS) ([]fileSlice, error) {
234234
var refs []fileSlice
235-
matches, err := fs.Glob(pkg, "lib/python*/_sysconfigdata__linux*.py")
235+
matches, err := fs.Glob(pkg, "lib/python*/_sysconfigdata_*.py")
236236
if err != nil {
237237
return nil, err
238238
}

internal/shellgen/tmpl/glibc-patch.nix.tmpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
builtins.map (drv: drv.outPath) mkTree;
7474

7575
# Programs needed by glibc-patch.bash.
76-
inherit (nixpkgs-glibc.legacyPackages."${system}") bash coreutils glibc gnused patchelf ripgrep;
76+
inherit (nixpkgs-glibc.legacyPackages."${system}") bash coreutils gnused patchelf ripgrep;
77+
78+
isLinux = (builtins.match ".*linux.*" system) != null;
79+
glibc = if isLinux then nixpkgs-glibc.legacyPackages."${system}".glibc else null;
7780

7881
# Create a package that puts the local devbox binary in the conventional
7982
# bin subdirectory. This also ensures that the executable is named
@@ -92,7 +95,9 @@
9295

9396
DEVBOX_DEBUG = 1;
9497
builder = "${devbox}/bin/devbox";
95-
args = [ "patch" "--restore-refs" "--glibc" glibc pkg ];
98+
args = [ "patch" "--restore-refs" ] ++
99+
(if glibc != null then [ "--glibc" "${glibc}" ] else [ ]) ++
100+
[ pkg ];
96101
};
97102
in
98103
{

0 commit comments

Comments
 (0)