const c = @import("c"); const zpy = @import("root.zig"); const Self = @This(); globals: *zpy.Dict, pub fn init() !Self { c.Py_Initialize(); const self: Self = .{ .globals = try .new(), }; return self; } pub const RunOptions = struct { locals: ?*zpy.Dict = null, }; pub fn run(self: *Self, str: [*c]const u8, options: RunOptions) !*zpy.Object { if (c.PyRun_String( str, c.Py_file_input, @ptrCast(self.globals), @ptrCast(options.locals), )) |object| { return @ptrCast(object); } return error.Exception; } pub fn deinit(self: *Self) void { c.Py_Finalize(); self.* = undefined; }