Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions progress/binding.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const std = @import("std");
const py = @cImport({
@cDefine("PY_SSIZE_T_CLEAN", {});
@cInclude("Python.h");
});
const py = @import("python");

const ProgressObject = extern struct {
ob_base: py.PyObject = .{},
Expand Down
21 changes: 14 additions & 7 deletions progress/build.zig
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

if (b.option([]const u8, "include", "sysconfig.get_path('include')")) |include| {
if (b.option(std.Build.LazyPath, "include", "sysconfig.get_path('include')")) |include| {
const lib_mod = b.createModule(.{
.root_source_file = b.path("binding.zig"),
.target = target,
.optimize = optimize,
});
lib_mod.addIncludePath(.{ .cwd_relative = include });
lib_mod.addIncludePath(include);

if (b.option([]const u8, "stdlib", "sysconfig.get_path('stdlib')")) |stdlib| {
var it = std.mem.splitBackwardsScalar(u8, stdlib, '/');
const py = b.addTranslateC(.{
.root_source_file = try include.join(b.allocator, "Python.h"),
.target = target,
.optimize = optimize,
});
py.addIncludePath(include);
const py_mod = py.createModule();

if (b.option(std.Build.LazyPath, "stdlib", "sysconfig.get_path('stdlib')")) |stdlib| {
py_mod.addLibraryPath(stdlib);
lib_mod.addImport("python", py_mod);

const lib = b.addLibrary(.{
.name = "binding",
.root_module = lib_mod,
});
lib.linkSystemLibrary(it.first());
lib.addLibraryPath(.{ .cwd_relative = it.rest() });
b.getInstallStep().dependOn(&b.addInstallFileWithDir(
lib.getEmittedBin(),
.prefix,
Expand Down
7 changes: 7 additions & 0 deletions progress/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.{
.name = .progress,
.version = "0.15.2",
.dependencies = .{},
.paths = .{""},
.fingerprint = 0x2201f246e6fb8646,
}