Skip to content

Commit 948486f

Browse files
authored
Support Zig master (#231)
1 parent 1ae977b commit 948486f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

build.zig

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// See the License for the specific language governing permissions and
1111
// limitations under the License.
1212

13+
const builtin = @import("builtin");
1314
const std = @import("std");
1415

1516
pub fn build(b: *std.Build) void {
@@ -91,7 +92,7 @@ fn getPythonIncludePath(
9192
python_exe: []const u8,
9293
allocator: std.mem.Allocator,
9394
) ![]const u8 {
94-
const includeResult = try std.process.Child.exec(.{
95+
const includeResult = try runProcess(.{
9596
.allocator = allocator,
9697
.argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_path('include'), end='')" },
9798
});
@@ -100,7 +101,7 @@ fn getPythonIncludePath(
100101
}
101102

102103
fn getPythonLibraryPath(python_exe: []const u8, allocator: std.mem.Allocator) ![]const u8 {
103-
const includeResult = try std.process.Child.exec(.{
104+
const includeResult = try runProcess(.{
104105
.allocator = allocator,
105106
.argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_config_var('LIBDIR'), end='')" },
106107
});
@@ -109,10 +110,12 @@ fn getPythonLibraryPath(python_exe: []const u8, allocator: std.mem.Allocator) ![
109110
}
110111

111112
fn getPythonLDVersion(python_exe: []const u8, allocator: std.mem.Allocator) ![]const u8 {
112-
const includeResult = try std.process.Child.exec(.{
113+
const includeResult = try runProcess(.{
113114
.allocator = allocator,
114115
.argv = &.{ python_exe, "-c", "import sysconfig; print(sysconfig.get_config_var('LDVERSION'), end='')" },
115116
});
116117
defer allocator.free(includeResult.stderr);
117118
return includeResult.stdout;
118119
}
120+
121+
const runProcess = if (builtin.zig_version.minor >= 12) std.process.Child.run else std.process.Child.exec;

pydust/src/pydust.build.zig

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
// See the License for the specific language governing permissions and
1111
// limitations under the License.
12+
const builtin = @import("builtin");
1213
const std = @import("std");
1314
const Step = std.Build.Step;
1415
const LazyPath = std.Build.LazyPath;
@@ -295,7 +296,7 @@ fn getLibpython(allocator: std.mem.Allocator, python_exe: []const u8) ![]const u
295296
}
296297

297298
fn getPythonOutput(allocator: std.mem.Allocator, python_exe: []const u8, code: []const u8) ![]const u8 {
298-
const result = try std.process.Child.exec(.{
299+
const result = try runProcess(.{
299300
.allocator = allocator,
300301
.argv = &.{ python_exe, "-c", code },
301302
});
@@ -308,11 +309,13 @@ fn getPythonOutput(allocator: std.mem.Allocator, python_exe: []const u8, code: [
308309
}
309310

310311
fn getStdOutput(allocator: std.mem.Allocator, argv: []const []const u8) ![]const u8 {
311-
const result = try std.process.Child.exec(.{ .allocator = allocator, .argv = argv });
312+
const result = try runProcess(.{ .allocator = allocator, .argv = argv });
312313
if (result.term.Exited != 0) {
313314
std.debug.print("Failed to execute {any}:\n{s}\n", .{ argv, result.stderr });
314315
std.process.exit(1);
315316
}
316317
allocator.free(result.stderr);
317318
return result.stdout;
318319
}
320+
321+
const runProcess = if (builtin.zig_version.minor >= 12) std.process.Child.run else std.process.Child.exec;

0 commit comments

Comments
 (0)