Skip to content

Commit

Permalink
Support Zig master
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn committed Oct 30, 2023
1 parent a72e3ee commit 8beb530
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pydust/src/pydust.build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const builtin = @import("builtin");
const std = @import("std");
const Step = std.Build.Step;
const LazyPath = std.Build.LazyPath;
Expand Down Expand Up @@ -295,7 +296,7 @@ fn getLibpython(allocator: std.mem.Allocator, python_exe: []const u8) ![]const u
}

fn getPythonOutput(allocator: std.mem.Allocator, python_exe: []const u8, code: []const u8) ![]const u8 {
const result = try std.process.Child.exec(.{
const result = try runProcess(.{
.allocator = allocator,
.argv = &.{ python_exe, "-c", code },
});
Expand All @@ -308,11 +309,13 @@ fn getPythonOutput(allocator: std.mem.Allocator, python_exe: []const u8, code: [
}

fn getStdOutput(allocator: std.mem.Allocator, argv: []const []const u8) ![]const u8 {
const result = try std.process.Child.exec(.{ .allocator = allocator, .argv = argv });
const result = try runProcess(.{ .allocator = allocator, .argv = argv });
if (result.term.Exited != 0) {
std.debug.print("Failed to execute {any}:\n{s}\n", .{ argv, result.stderr });
std.process.exit(1);
}
allocator.free(result.stderr);
return result.stdout;
}

const runProcess = if (builtin.zig_version.minor >= 12) std.process.Child.run else std.process.Child.exec;
1 change: 0 additions & 1 deletion pydust/src/trampoline.zig
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ pub fn Trampoline(comptime T: type) type {
}

const args = try py.allocator.alloc(py.PyObject, if (pyargs) |a| a.length() else 0);
defer py.allocator.free(args);
if (pyargs) |a| {
for (0..a.length()) |i| {
args[i] = try a.getItem(py.PyObject, i);
Expand Down

0 comments on commit 8beb530

Please sign in to comment.