From eeb9fc7766c943c59cc316b277353101a4447a17 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Mon, 30 Oct 2023 09:29:44 +0000 Subject: [PATCH] Apply same to build.zig| --- build.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 1a59c706..8aaf7022 100644 --- a/build.zig +++ b/build.zig @@ -10,6 +10,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +const builtin = @import("builtin"); const std = @import("std"); pub fn build(b: *std.Build) void { @@ -91,7 +92,7 @@ fn getPythonIncludePath( python_exe: []const u8, allocator: std.mem.Allocator, ) ![]const u8 { - const includeResult = try std.process.Child.exec(.{ + const includeResult = try runProcess(.{ .allocator = allocator, .argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_path('include'), end='')" }, }); @@ -100,7 +101,7 @@ fn getPythonIncludePath( } fn getPythonLibraryPath(python_exe: []const u8, allocator: std.mem.Allocator) ![]const u8 { - const includeResult = try std.process.Child.exec(.{ + const includeResult = try runProcess(.{ .allocator = allocator, .argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_config_var('LIBDIR'), end='')" }, }); @@ -109,10 +110,12 @@ fn getPythonLibraryPath(python_exe: []const u8, allocator: std.mem.Allocator) ![ } fn getPythonLDVersion(python_exe: []const u8, allocator: std.mem.Allocator) ![]const u8 { - const includeResult = try std.process.Child.exec(.{ + const includeResult = try runProcess(.{ .allocator = allocator, .argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_config_var('LDVERSION'), end='')" }, }); defer allocator.free(includeResult.stderr); return includeResult.stdout; } + +const runProcess = if (builtin.zig_version.minor >= 12) std.process.Child.run else std.process.Child.exec;