diff --git a/build.zig b/build.zig index b81bcc6..48bb52b 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,10 @@ pub const Version = enum { + @"3.6", @"3.11.13", @"3.12.11", pub fn libName(self: Version) []const u8 { return switch (self) { + .@"3.6" => "3.6", .@"3.11.13" => "3.11", .@"3.12.11" => "3.12", }; @@ -59,6 +61,7 @@ pub fn build(b: *std.Build) !void { }); const upstream: *std.Build.Dependency = switch (version) { + .@"3.6" => if (b.lazyDependency("upstream_3.6", .{})) |d| d else noUpstream(b), .@"3.11.13" => if (b.lazyDependency("upstream_3.11.13", .{})) |d| d else noUpstream(b), .@"3.12.11" => if (b.lazyDependency("upstream_3.12.11", .{})) |d| d else noUpstream(b), }; @@ -366,6 +369,7 @@ fn addMakesetup( replace.addArg("MODULE_BUILDTYPE=static"); addReplaceModuleArgs(b, replace, @TypeOf(stdlib_modules_common), stdlib_modules_common); switch (version) { + .@"3.6" => {}, .@"3.11.13" => addReplaceModuleArgs(b, replace, @TypeOf(@"stdlib_modules_3.11.13"), @"stdlib_modules_3.11.13"), .@"3.12.11" => { replace.addArg("MODULE__CTYPES_MALLOC_CLOSURE="); @@ -436,6 +440,7 @@ fn addPythonExe( }); switch (args.pyconfig.version) { + .@"3.6" => {}, .@"3.11.13" => { // workaround dictobject.c memcpy alignment issue exe.root_module.sanitize_c = false; @@ -449,6 +454,7 @@ fn addPythonExe( .Debug => {}, .ReleaseSafe, .ReleaseSmall, .ReleaseFast => { const release_date = switch (args.pyconfig.version) { + .@"3.6" => "December 28, 2021", .@"3.11.13" => "June 3, 2025", .@"3.12.11" => "June 3, 2025", }; @@ -566,6 +572,7 @@ fn addPythonExe( "Modules/getpath_noop.c", }, switch (args.pyconfig.version) { + .@"3.6" => &library_src_omit_frozen.@"3.6", .@"3.11.13" => &library_src_omit_frozen.@"3.11.13", .@"3.12.11" => &library_src_omit_frozen.@"3.12.11", }, @@ -576,6 +583,7 @@ fn addPythonExe( "Modules/getbuildinfo.c", }, switch (args.pyconfig.version) { + .@"3.6" => &library_src_omit_frozen.@"3.6", .@"3.11.13" => &library_src_omit_frozen.@"3.11.13", .@"3.12.11" => &library_src_omit_frozen.@"3.12.11", }, @@ -587,6 +595,7 @@ fn addPythonExe( "Python/frozen.c", }, switch (args.pyconfig.version) { + .@"3.6" => &library_src_omit_frozen.@"3.6", .@"3.11.13" => &library_src_omit_frozen.@"3.11.13", .@"3.12.11" => &library_src_omit_frozen.@"3.12.11", }, @@ -768,6 +777,7 @@ const header_config_set = struct { .{ .HAVE_UUID_UUID_H, "uuid/uuid.h" }, .{ .HAVE_ZLIB_H, "zlib.h" }, }; + pub const @"3.6" = concatConfigs(common, .{}); pub const @"3.11.13" = concatConfigs(common, .{ .{ .HAVE_MEMORY_H, "memory.h" }, }); @@ -1202,6 +1212,7 @@ const exe_config_set = struct { .{ .HAVE_WORKING_TZSET, "#include \nint main(){tzset(); return 0;}" }, .{ .HAVE_ZLIB_COPY, "#include \nint main(){z_stream strm; inflateCopy(&strm, &strm); return 0;}" }, }; + pub const @"3.6" = concatConfigs(common, .{}); pub const @"3.11.13" = concatConfigs(common, .{ .{ .HAVE_TTYNAME, "#include \nint main(){ttyname(0);}" }, .{ .HAVE_LIBGDBM_COMPAT, "#include \nint main(){GDBM_FILE gf; return 0;}" }, @@ -1369,6 +1380,7 @@ fn addPyconfig( .HAVE_RL_COMPDISP_FUNC_T = null, }); switch (version) { + .@"3.6" => {}, .@"3.11.13" => config_header.addValues(.{ .PY_FORMAT_SIZE_T = "z", .TIME_WITH_SYS_TIME = 1, @@ -1402,10 +1414,12 @@ fn addPyconfig( } const header_configs: []const Config = switch (version) { + .@"3.6" => &header_config_set.@"3.6", .@"3.11.13" => &header_config_set.@"3.11.13", .@"3.12.11" => &header_config_set.@"3.12.11", }; const exe_configs: []const Config = switch (version) { + .@"3.6" => &exe_config_set.@"3.6", .@"3.11.13" => &exe_config_set.@"3.11.13", .@"3.12.11" => &exe_config_set.@"3.12.11", }; @@ -1546,6 +1560,7 @@ const python_src = struct { "Python/fileutils.c", "Python/suggestions.c", }; + pub const @"3.6" = common; pub const @"3.11.13" = common; pub const @"3.12.11" = common ++ .{ "Python/assemble.c", @@ -1605,6 +1620,7 @@ const object_src = struct { "Objects/unionobject.c", "Objects/weakrefobject.c", }; + pub const @"3.6" = common ++ .{}; pub const @"3.11.13" = common ++ .{ "Objects/accu.c", }; @@ -1636,6 +1652,7 @@ const module_src = [_][]const u8{ }; const library_src_omit_frozen = struct { + pub const @"3.6" = parser_src ++ object_src.@"3.6" ++ python_src.@"3.6" ++ module_src; pub const @"3.11.13" = parser_src ++ object_src.@"3.11.13" ++ python_src.@"3.11.13" ++ module_src; pub const @"3.12.11" = parser_src ++ object_src.@"3.12.11" ++ python_src.@"3.12.11" ++ module_src; }; diff --git a/build.zig.zon b/build.zig.zon index 2e8e99b..4b2353d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,6 +4,11 @@ .version = "0.0.0", .minimum_zig_version = "0.14.1", .dependencies = .{ + .@"upstream_3.6" = .{ + .url = "git+https://github.com/python/cpython#8d999cbf4adea053be6dbb612b9844635c4dfb8e", + .hash = "N-V-__8AAMED3ARJaCyFG2S5U8Dz84IoEKHP_ZLjRG-3Qe3O", + .lazy = true, + }, .@"upstream_3.11.13" = .{ .url = "git+https://github.com/python/cpython#498b971ea3673012a1d4b21860b229d55fc6e575", .hash = "N-V-__8AACr32QWySXRzLeDQuZNoyM6FlWz3U4smc4qJ0EXe",