zig-zon 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {zig-zon-0.2.2 → zig-zon-0.2.3}/PKG-INFO +6 -2
- {zig-zon-0.2.2 → zig-zon-0.2.3}/build.zig +7 -7
- {zig-zon-0.2.2 → zig-zon-0.2.3}/build.zig.zon +3 -3
- {zig-zon-0.2.2 → zig-zon-0.2.3}/pkg-info.zon +4 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/setup.py +4 -2
- zig-zon-0.2.3/setup.zig.json +1 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/src/zig_zon.zig +26 -21
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/build.zig +13 -14
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/build.zig.zon +1 -1
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/CPython.zig +37 -45
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/SDistStep.zig +24 -2
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/VenvInstallTest.zig +9 -9
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/pkg_info.zig +0 -19
- zig-zon-0.2.3/zig-pkg/zig_python_sdist/src/build/python.zig +217 -0
- zig-zon-0.2.2/setup.zig.json +0 -1
- zig-zon-0.2.2/zig-pkg/zig_python_sdist/src/build/python.zig +0 -50
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/LICENSE +0 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/README.md +0 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/pkg-info.zon +0 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/LowerDashStringFormatter.zig +0 -0
- {zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/extract_link_info.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zig-zon
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: a native cpython extension to parse zig object notation strings
|
|
5
5
|
Author-email: Tobias Simetsreiter <dasimmet@gmail.com>
|
|
6
6
|
Maintainer-email: Tobias Simetsreiter <dasimmet@gmail.com>
|
|
@@ -10,6 +10,10 @@ Requires-Python: >=3.8
|
|
|
10
10
|
Project-URL: Homepage, https://codeberg.org/dasimmet/python-zig-zon
|
|
11
11
|
Project-URL: Issues, https://codeberg.org/dasimmet/python-zig-zon/issues
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Zig
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
17
|
Description-Content-Type: text/markdown
|
|
14
18
|
|
|
15
19
|
# Python Zig Zon Parser
|
|
@@ -25,7 +29,7 @@ Depending on your OS, you may need the python development headers
|
|
|
25
29
|
|
|
26
30
|
## Usage
|
|
27
31
|
|
|
28
|
-
install from source on pypi
|
|
32
|
+
install from source on <https://pypi.org/project/zig-zon>:
|
|
29
33
|
|
|
30
34
|
```bash
|
|
31
35
|
pip install zig-zon
|
|
@@ -2,14 +2,13 @@ const std = @import("std");
|
|
|
2
2
|
const Build = std.Build;
|
|
3
3
|
const zig_python_sdist = @import("zig_python_sdist");
|
|
4
4
|
const zon = @import("build.zig.zon");
|
|
5
|
-
const CPython = @import("setuptools_zig_build").CPython;
|
|
6
5
|
|
|
7
6
|
pub fn build(b: *Build) void {
|
|
8
7
|
const target = b.standardTargetOptions(.{});
|
|
9
8
|
const optimize = b.standardOptimizeOption(.{});
|
|
10
9
|
|
|
11
10
|
// this target and section of our build is used at pip install time
|
|
12
|
-
const ext_install_step = b.step("
|
|
11
|
+
const ext_install_step = b.step("bdist-wheel", "build python extension module");
|
|
13
12
|
|
|
14
13
|
// this generates a python sdist archive
|
|
15
14
|
const sdist = zig_python_sdist.create(b, .{
|
|
@@ -17,7 +16,10 @@ pub fn build(b: *Build) void {
|
|
|
17
16
|
.version = zon.version,
|
|
18
17
|
.description = b.path("README.md"),
|
|
19
18
|
.build = .{
|
|
20
|
-
.args = &.{
|
|
19
|
+
.args = &.{
|
|
20
|
+
ext_install_step.name,
|
|
21
|
+
b.fmt("-Doptimize={s}", .{@tagName(optimize)}),
|
|
22
|
+
},
|
|
21
23
|
},
|
|
22
24
|
.extra_pkg_info = @import("pkg-info.zon"),
|
|
23
25
|
.files = &.{
|
|
@@ -49,8 +51,6 @@ pub fn build(b: *Build) void {
|
|
|
49
51
|
b.step("test-pip-install", "").dependOn(test_pip_install.step);
|
|
50
52
|
|
|
51
53
|
{
|
|
52
|
-
const cpython = zig_python_sdist.CPython.find(b);
|
|
53
|
-
|
|
54
54
|
const lib = b.addLibrary(.{
|
|
55
55
|
.name = "zig_zon",
|
|
56
56
|
.root_module = b.addModule("zig_zon", .{
|
|
@@ -60,12 +60,12 @@ pub fn build(b: *Build) void {
|
|
|
60
60
|
}),
|
|
61
61
|
.linkage = .dynamic,
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
zig_python_sdist.linkCPython(b, .{
|
|
64
64
|
.lib = lib,
|
|
65
65
|
.version = zon.version,
|
|
66
66
|
.optimize = .ReleaseSmall,
|
|
67
67
|
});
|
|
68
|
-
const ext_install = zig_python_sdist.
|
|
68
|
+
const ext_install = zig_python_sdist.installExtLib(b, lib);
|
|
69
69
|
|
|
70
70
|
ext_install_step.dependOn(&ext_install.step);
|
|
71
71
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
.{
|
|
2
2
|
.name = .python_zig_zon,
|
|
3
3
|
.fingerprint = 0x3d332656a3644fc9,
|
|
4
|
-
.version = "0.2.
|
|
4
|
+
.version = "0.2.3",
|
|
5
5
|
.minimum_zig_version = "0.16.0",
|
|
6
6
|
.dependencies = .{
|
|
7
7
|
.zig_python_sdist = .{
|
|
8
|
-
.url = "git+https://codeberg.org/dasimmet/zig-python-sdist.git#
|
|
9
|
-
.hash = "zig_python_sdist-0.0.
|
|
8
|
+
.url = "git+https://codeberg.org/dasimmet/zig-python-sdist.git?ref=0.0.2#3dd2c2eaf62a7007d6c257c357ded7911537621a",
|
|
9
|
+
.hash = "zig_python_sdist-0.0.2-wjgdOpyrAADPCiUfh4LoKFNZkHstj4a1bIyEuwnNKkcc",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
.paths = .{
|
|
@@ -8,4 +8,8 @@
|
|
|
8
8
|
.{ .key = "Project-URL", .value = "Homepage, https://codeberg.org/dasimmet/python-zig-zon" },
|
|
9
9
|
.{ .key = "Project-URL", .value = "Issues, https://codeberg.org/dasimmet/python-zig-zon/issues" },
|
|
10
10
|
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
11
|
+
.{ .key = "Classifier", .value = "Programming Language :: Python :: 3" },
|
|
12
|
+
.{ .key = "Classifier", .value = "Programming Language :: Zig" },
|
|
13
|
+
.{ .key = "Classifier", .value = "Intended Audience :: Developers" },
|
|
14
|
+
.{ .key = "Classifier", .value = "Topic :: Software Development :: Libraries" },
|
|
11
15
|
}
|
|
@@ -39,10 +39,11 @@ class ZigBuildWheel(bdist_wheel):
|
|
|
39
39
|
subprocess.check_call(build_cmd)
|
|
40
40
|
|
|
41
41
|
os.makedirs(self.bdist_dir, exist_ok=True)
|
|
42
|
-
|
|
42
|
+
copy_pattern = "zig-out/{}".format(setup_json['build']['copy_pattern'])
|
|
43
|
+
artifacts = glob.glob(copy_pattern)
|
|
43
44
|
if len(artifacts) == 0:
|
|
44
45
|
raise Exception(
|
|
45
|
-
'no zig artifacts found in {}/
|
|
46
|
+
'no zig artifacts found in {}/{}'.format(cwd, copy_pattern))
|
|
46
47
|
|
|
47
48
|
for it in artifacts:
|
|
48
49
|
shutil.copyfile(it, os.path.join(
|
|
@@ -55,6 +56,7 @@ setup(
|
|
|
55
56
|
name=setup_json['name'],
|
|
56
57
|
version=mkversion(setup_json['version']),
|
|
57
58
|
cmdclass={'bdist_wheel': ZigBuildWheel},
|
|
59
|
+
install_requires=setup_json['install_requires'],
|
|
58
60
|
setup_requires=[
|
|
59
61
|
"setuptools",
|
|
60
62
|
"wheel",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"zig_zon","version":{"major":0,"minor":2,"patch":3,"pre":null,"build":null},"zig_version":{"major":0,"minor":16,"patch":0,"pre":null,"build":null},"build":{"args":["bdist-wheel","-Doptimize=Debug","--fork=zig-pkg/zig_python_sdist"],"requires":[],"copy_pattern":"lib/*"},"install_requires":[]}
|
|
@@ -26,20 +26,23 @@ pub var zigmodule = c.PyModuleDef{
|
|
|
26
26
|
pub export fn PyInit_zig_zon() [*c]c.PyObject {
|
|
27
27
|
const mod = c.PyModule_Create(&zigmodule);
|
|
28
28
|
cpython.addVersion(mod);
|
|
29
|
-
cpython.
|
|
29
|
+
cpython.addZigBuiltin(mod);
|
|
30
30
|
return mod;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
pub fn parse(self: [*]PyObject, args: [*]PyObject) callconv(.c) [*c]PyObject {
|
|
34
34
|
_ = self;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const zon_slice: [:0]u8 = zon_slice: {
|
|
36
|
+
var zon_txt: [*c]u8 = undefined;
|
|
37
|
+
if (!(c.PyArg_ParseTuple(args, "s", &zon_txt) != 0)) return null;
|
|
38
|
+
break :zon_slice std.mem.sliceTo(zon_txt, 0);
|
|
39
|
+
};
|
|
37
40
|
|
|
38
41
|
var arena_instance = std.heap.ArenaAllocator.init(std.heap.c_allocator);
|
|
39
42
|
defer arena_instance.deinit();
|
|
40
43
|
const arena = arena_instance.allocator();
|
|
41
44
|
|
|
42
|
-
const ast = Ast.parse(arena,
|
|
45
|
+
const ast = Ast.parse(arena, zon_slice, .zon) catch |err| {
|
|
43
46
|
const errstr = std.fmt.allocPrintSentinel(
|
|
44
47
|
arena,
|
|
45
48
|
"zig-zon ast error: {s}",
|
|
@@ -50,19 +53,21 @@ pub fn parse(self: [*]PyObject, args: [*]PyObject) callconv(.c) [*c]PyObject {
|
|
|
50
53
|
return null;
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
{
|
|
57
|
+
// TODO: use zoir instead of AST maybe?
|
|
58
|
+
// this is unused for now and instead i walk the AST myself, but i keep it in as a sanity check.
|
|
59
|
+
var zoir = ZonGen.generate(arena, ast, .{ .parse_str_lits = false }) catch |err| {
|
|
60
|
+
const errstr = std.fmt.allocPrintSentinel(
|
|
61
|
+
arena,
|
|
62
|
+
"zig-zon zoir error: {s}",
|
|
63
|
+
.{@errorName(err)},
|
|
64
|
+
0,
|
|
65
|
+
) catch "";
|
|
66
|
+
c.PyErr_SetString(c.PyExc_Exception, errstr.ptr);
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
defer zoir.deinit(arena);
|
|
70
|
+
}
|
|
66
71
|
|
|
67
72
|
const main_node_index = ast.nodeData(.root).node;
|
|
68
73
|
|
|
@@ -115,8 +120,8 @@ fn parseZonAst(arena: Allocator, tree: Ast, node: Ast.Node.Index) ZonError!*c.Py
|
|
|
115
120
|
const name_token = tree.firstToken(node);
|
|
116
121
|
const enum_name = tree.tokenSlice(name_token + 1);
|
|
117
122
|
if (std.mem.startsWith(u8, enum_name, "@")) {
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
assert(std.mem.startsWith(u8, enum_name, "@\""));
|
|
124
|
+
assert(std.mem.endsWith(u8, enum_name, "\""));
|
|
120
125
|
const enum_parsed_name = try std.zig.string_literal.parseAlloc(
|
|
121
126
|
arena,
|
|
122
127
|
enum_name[1..enum_name.len],
|
|
@@ -242,10 +247,10 @@ fn parseZonArray(arena: Allocator, tree: Ast, node: Ast.Node.Index) !*c.PyObject
|
|
|
242
247
|
const IdentifierError = error{OutOfMemory} || StringLiteralError;
|
|
243
248
|
|
|
244
249
|
fn identifierTokenString(arena: Allocator, ast: Ast, token: Ast.TokenIndex) IdentifierError![:0]const u8 {
|
|
245
|
-
|
|
250
|
+
assert(ast.tokenTag(token) == .identifier);
|
|
246
251
|
const ident_name = ast.tokenSlice(token);
|
|
247
252
|
if (!std.mem.startsWith(u8, ident_name, "@")) {
|
|
248
|
-
return try arena.
|
|
253
|
+
return try arena.dupeSentinel(u8, ident_name, 0);
|
|
249
254
|
}
|
|
250
255
|
|
|
251
256
|
var buf = std.ArrayListUnmanaged(u8).empty;
|
|
@@ -24,8 +24,6 @@ pub fn build(b: *Build) void {
|
|
|
24
24
|
|
|
25
25
|
b.installArtifact(exe);
|
|
26
26
|
|
|
27
|
-
const cpython = CPython.find(b);
|
|
28
|
-
|
|
29
27
|
const sdist_dummy = b.addLibrary(.{
|
|
30
28
|
.name = "sdist_dummy",
|
|
31
29
|
.root_module = b.createModule(.{
|
|
@@ -35,13 +33,14 @@ pub fn build(b: *Build) void {
|
|
|
35
33
|
}),
|
|
36
34
|
.linkage = .dynamic,
|
|
37
35
|
});
|
|
38
|
-
|
|
36
|
+
|
|
37
|
+
linkCPython(b, .{
|
|
39
38
|
.lib = sdist_dummy,
|
|
40
39
|
.version = zon.version,
|
|
41
40
|
});
|
|
42
|
-
const install_ext =
|
|
41
|
+
const install_ext = installExtLib(b, sdist_dummy);
|
|
43
42
|
|
|
44
|
-
const build_ext_step = b.step("
|
|
43
|
+
const build_ext_step = b.step("bdist-wheel", "build the sdist dummy python module");
|
|
45
44
|
build_ext_step.dependOn(&install_ext.step);
|
|
46
45
|
|
|
47
46
|
const sdist = SDistStep.createInternal(b, .{
|
|
@@ -50,7 +49,7 @@ pub fn build(b: *Build) void {
|
|
|
50
49
|
.version = zon.version,
|
|
51
50
|
.description = b.path("README.md"),
|
|
52
51
|
.build = .{
|
|
53
|
-
.args = &.{build_ext_step.name},
|
|
52
|
+
.args = &.{ build_ext_step.name, b.fmt("-Doptimize={s}", .{@tagName(optimize)}) },
|
|
54
53
|
},
|
|
55
54
|
.extra_pkg_info = @import("pkg-info.zon"),
|
|
56
55
|
.files = &.{
|
|
@@ -63,15 +62,12 @@ pub fn build(b: *Build) void {
|
|
|
63
62
|
.{ .src = b.path("src"), .dest = "src" },
|
|
64
63
|
.{ .src = b.path("src/build"), .dest = "src/build" },
|
|
65
64
|
},
|
|
65
|
+
.install_requires = &.{"ruamel.yaml.clibz"},
|
|
66
66
|
.zig_version = std.SemanticVersion.parse("0.16.0") catch unreachable,
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.{ .custom = "src" },
|
|
72
|
-
sdist.basename,
|
|
73
|
-
);
|
|
74
|
-
b.getInstallStep().dependOn(&sdistfile.step);
|
|
68
|
+
const sdist_install = sdist.install();
|
|
69
|
+
b.getInstallStep().dependOn(&sdist_install.step);
|
|
70
|
+
b.step("sdist", "only build and install sdist").dependOn(&sdist_install.step);
|
|
75
71
|
|
|
76
72
|
const test_pip_install = VenvInstallTest.create(
|
|
77
73
|
b,
|
|
@@ -85,11 +81,14 @@ pub fn build(b: *Build) void {
|
|
|
85
81
|
b.step("test-pip-install", "").dependOn(test_pip_install.step);
|
|
86
82
|
}
|
|
87
83
|
|
|
84
|
+
pub const linkCPython = CPython.link;
|
|
85
|
+
pub const installExtLib = CPython.installExtLib;
|
|
86
|
+
|
|
88
87
|
pub fn create(b: *Build, options: SDistStep.Options) *SDistStep {
|
|
89
88
|
var opt = options;
|
|
90
89
|
const sdist = b.dependencyFromBuildZig(@This(), .{
|
|
91
90
|
.target = b.graph.host,
|
|
92
|
-
.optimize = .
|
|
91
|
+
.optimize = .ReleaseFast,
|
|
93
92
|
});
|
|
94
93
|
opt.sdist_builder = opt.sdist_builder orelse sdist.artifact("sdist-builder");
|
|
95
94
|
|
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
2
|
const builtin = @import("builtin");
|
|
3
3
|
const Build = std.Build;
|
|
4
|
-
const
|
|
4
|
+
const LazyPath = Build.LazyPath;
|
|
5
5
|
const mem = std.mem;
|
|
6
6
|
|
|
7
|
+
/// a module for building cpython extension libraries,
|
|
8
|
+
/// linking them with system python headers and libs
|
|
7
9
|
pub const CPython = @This();
|
|
8
10
|
|
|
9
|
-
exe:
|
|
10
|
-
|
|
11
|
-
/// adds a `python` option to the build. if not provided, tries to find `python` in PATH
|
|
12
|
-
pub fn findAddOption(b: *Build) *CPython {
|
|
13
|
-
if (b.option(
|
|
14
|
-
Build.LazyPath,
|
|
15
|
-
"python",
|
|
16
|
-
"path to the cpython interpreter executable",
|
|
17
|
-
)) |opt| {
|
|
18
|
-
const self = b.allocator.create(CPython) catch @panic("OOM");
|
|
19
|
-
self.* = .{
|
|
20
|
-
.exe = opt,
|
|
21
|
-
};
|
|
22
|
-
return self;
|
|
23
|
-
} else return find(b);
|
|
24
|
-
}
|
|
11
|
+
exe: LazyPath,
|
|
25
12
|
|
|
26
13
|
pub fn find(b: *Build) *CPython {
|
|
27
14
|
const self = b.allocator.create(CPython) catch @panic("OOM");
|
|
28
|
-
const exe_path = findProgramCompat(b, &.{
|
|
29
|
-
"python",
|
|
30
|
-
"python3",
|
|
31
|
-
}) orelse {
|
|
32
|
-
const err_wf = b.addWriteFiles();
|
|
33
|
-
const err_step = b.addFail("finding python failed. please provide a path to the exe using -Dpython=");
|
|
34
|
-
err_wf.step.dependOn(&err_step.step);
|
|
35
|
-
self.* = .{ .exe = err_wf.getDirectory() };
|
|
36
|
-
return self;
|
|
37
|
-
};
|
|
38
15
|
self.* = .{
|
|
39
|
-
.exe =
|
|
40
|
-
|
|
16
|
+
.exe = findProgramCompat(b, &.{
|
|
17
|
+
"python",
|
|
18
|
+
"python3",
|
|
19
|
+
}) orelse {
|
|
20
|
+
const err_wf = b.addWriteFiles();
|
|
21
|
+
const err_step = b.addFail("finding python failed. please provide a path to the exe using -Dpython=");
|
|
22
|
+
err_wf.step.dependOn(&err_step.step);
|
|
23
|
+
self.* = .{ .exe = err_wf.getDirectory() };
|
|
24
|
+
return self;
|
|
41
25
|
},
|
|
42
26
|
};
|
|
43
27
|
return self;
|
|
@@ -47,6 +31,7 @@ pub const LinkOptions = struct {
|
|
|
47
31
|
/// library to link against libpython
|
|
48
32
|
lib: *std.Build.Step.Compile,
|
|
49
33
|
version: ?[]const u8 = null,
|
|
34
|
+
python_exe: ?LazyPath = null,
|
|
50
35
|
/// optimize mode for the c module. will fall back to lib's optimize mode.
|
|
51
36
|
optimize: ?std.builtin.OptimizeMode = null,
|
|
52
37
|
macros: []const [2][]const u8 = &default_macros,
|
|
@@ -55,20 +40,12 @@ pub const LinkOptions = struct {
|
|
|
55
40
|
};
|
|
56
41
|
};
|
|
57
42
|
|
|
58
|
-
pub fn
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return extract_link_info.addOutputDirectoryArg("include");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
pub fn installExtLib(b: *Build, lib: *Build.Step.Compile) *Build.Step.InstallFile {
|
|
67
|
-
const ext_lib_name = lib_ext_name(b, lib);
|
|
68
|
-
return b.addInstallLibFile(lib.getEmittedBin(), ext_lib_name);
|
|
69
|
-
}
|
|
43
|
+
pub fn link(b: *Build, options: LinkOptions) void {
|
|
44
|
+
const self: *const CPython = if (options.python_exe) |python_exe|
|
|
45
|
+
&.{ .exe = python_exe }
|
|
46
|
+
else
|
|
47
|
+
CPython.find(b);
|
|
70
48
|
|
|
71
|
-
pub fn link(self: CPython, b: *Build, options: LinkOptions) void {
|
|
72
49
|
const target = Build.ResolvedTarget{
|
|
73
50
|
.query = .{},
|
|
74
51
|
.result = options.lib.rootModuleTarget(),
|
|
@@ -116,6 +93,19 @@ pub fn link(self: CPython, b: *Build, options: LinkOptions) void {
|
|
|
116
93
|
);
|
|
117
94
|
}
|
|
118
95
|
|
|
96
|
+
pub fn generateIncludeDir(self: CPython, b: *Build) LazyPath {
|
|
97
|
+
const extract_link_info = Build.Step.Run.create(b, "python header extraction run");
|
|
98
|
+
extract_link_info.addFileArg(self.exe);
|
|
99
|
+
const wf = b.addWriteFiles();
|
|
100
|
+
extract_link_info.addFileArg(wf.add("extract_link_info.py", @embedFile("extract_link_info.py")));
|
|
101
|
+
return extract_link_info.addOutputDirectoryArg("pyinclude");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
pub fn installExtLib(b: *Build, lib: *Build.Step.Compile) *Build.Step.InstallFile {
|
|
105
|
+
const ext_lib_name = lib_ext_name(b, lib);
|
|
106
|
+
return b.addInstallLibFile(lib.getEmittedBin(), ext_lib_name);
|
|
107
|
+
}
|
|
108
|
+
|
|
119
109
|
pub fn lib_ext_name(b: *Build, lib: *Build.Step.Compile) []const u8 {
|
|
120
110
|
const target = lib.rootModuleTarget();
|
|
121
111
|
return if (target.os.tag == .windows)
|
|
@@ -125,9 +115,11 @@ pub fn lib_ext_name(b: *Build, lib: *Build.Step.Compile) []const u8 {
|
|
|
125
115
|
}
|
|
126
116
|
|
|
127
117
|
// compat for 0.16.0 and 0.17.0
|
|
128
|
-
pub fn findProgramCompat(b: *std.Build, names: []const []const u8) ?
|
|
118
|
+
pub fn findProgramCompat(b: *std.Build, names: []const []const u8) ?LazyPath {
|
|
129
119
|
if (comptime (@import("builtin").zig_version.order(std.SemanticVersion.parse("0.16.0") catch unreachable) == .gt)) {
|
|
130
|
-
return b.
|
|
120
|
+
return b.findProgramLazy(.{ .names = names });
|
|
131
121
|
}
|
|
132
|
-
return
|
|
122
|
+
return .{
|
|
123
|
+
.cwd_relative = b.findProgram(names, &.{}) catch return null,
|
|
124
|
+
};
|
|
133
125
|
}
|
|
@@ -16,15 +16,22 @@ pub const Content = struct {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
pub const Options = struct {
|
|
19
|
+
/// name of the python package
|
|
19
20
|
name: []const u8,
|
|
20
21
|
version: []const u8,
|
|
22
|
+
/// description file. will be added to PKG-INFO
|
|
21
23
|
description: ?LazyPath = null,
|
|
22
|
-
files: []const Content = &.{},
|
|
23
24
|
build: struct {
|
|
25
|
+
/// extra arguments for `zig build` at wheel build time
|
|
24
26
|
args: []const []const u8 = &.{},
|
|
27
|
+
/// additional build requirements for wheel build
|
|
25
28
|
requires: []const []const u8 = &.{},
|
|
29
|
+
copy_pattern: ?[]const u8 = null,
|
|
26
30
|
} = .{},
|
|
31
|
+
install_requires: []const []const u8 = &.{},
|
|
32
|
+
/// extra headers added to PKG-INFO
|
|
27
33
|
extra_pkg_info: []const PkgInfo.Header = &.{},
|
|
34
|
+
files: []const Content = &.{},
|
|
28
35
|
directories: []const Content = &.{},
|
|
29
36
|
sdist_builder: ?*Build.Step.Compile = null,
|
|
30
37
|
// the version of the ziglang python package to depend on.
|
|
@@ -53,7 +60,7 @@ pub fn createInternal(b: *Build, options: Options) *SDistStep {
|
|
|
53
60
|
if (zig_version.build != null or zig_version.pre != null) {
|
|
54
61
|
std.log.warn("the python ziglang package is only published for releases.", .{});
|
|
55
62
|
std.log.warn("the resulting sdist might not be installable!", .{});
|
|
56
|
-
std.log.warn("set .zig_version for your sdist to a release explicitly", .{});
|
|
63
|
+
std.log.warn("you can set .zig_version for your sdist to a release explicitly and test the pip build against it.", .{});
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
run.addArg(b.fmt("--zig-version={f}", .{zig_version}));
|
|
@@ -73,6 +80,12 @@ pub fn createInternal(b: *Build, options: Options) *SDistStep {
|
|
|
73
80
|
for (options.build.requires) |br| {
|
|
74
81
|
run.addArg(b.fmt("--build-requires={s}", .{br}));
|
|
75
82
|
}
|
|
83
|
+
for (options.install_requires) |br| {
|
|
84
|
+
run.addArg(b.fmt("--install-requires={s}", .{br}));
|
|
85
|
+
}
|
|
86
|
+
if (options.build.copy_pattern) |copy_pattern| {
|
|
87
|
+
run.addArg(b.fmt("--copy-pattern={s}", .{copy_pattern}));
|
|
88
|
+
}
|
|
76
89
|
if (options.extra_pkg_info.len > 0) {
|
|
77
90
|
const extra_info = std.fmt.allocPrint(b.allocator, "--extra-pkg-info={f}", .{
|
|
78
91
|
std.json.fmt(options.extra_pkg_info, .{ .whitespace = .minified }),
|
|
@@ -91,3 +104,12 @@ pub fn createInternal(b: *Build, options: Options) *SDistStep {
|
|
|
91
104
|
pub fn getEmittedArchive(self: *SDistStep) LazyPath {
|
|
92
105
|
return self.archive;
|
|
93
106
|
}
|
|
107
|
+
|
|
108
|
+
pub fn install(self: *SDistStep) *Build.Step.InstallFile {
|
|
109
|
+
const b = self.builder.step.owner;
|
|
110
|
+
return b.addInstallFileWithDir(
|
|
111
|
+
self.getEmittedArchive(),
|
|
112
|
+
.{ .custom = "src" },
|
|
113
|
+
self.basename,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -31,11 +31,12 @@ pub fn create(b: *Build, options: Options) *VenvInstallTest {
|
|
|
31
31
|
venv_run.addFileArg(python);
|
|
32
32
|
} else {
|
|
33
33
|
if (CPython.findProgramCompat(b, &.{ "python", "python3" })) |python| {
|
|
34
|
-
venv_run.
|
|
34
|
+
venv_run.addFileArg(python);
|
|
35
35
|
} else {
|
|
36
36
|
venv_run.step.dependOn(&b.addFail("system python not found").step);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
venv_run.addArgs(&.{ "-m", "venv" });
|
|
40
41
|
venv_run.addDirectoryArg(wf.getDirectory());
|
|
41
42
|
const venv_python = if (builtin.target.os.tag == .windows)
|
|
@@ -47,22 +48,21 @@ pub fn create(b: *Build, options: Options) *VenvInstallTest {
|
|
|
47
48
|
deps_run.addFileArg(venv_python);
|
|
48
49
|
deps_run.step.dependOn(&wf.step);
|
|
49
50
|
|
|
51
|
+
deps_run.addArgs(&.{
|
|
52
|
+
"-m",
|
|
53
|
+
"pip",
|
|
54
|
+
"install",
|
|
55
|
+
"-U",
|
|
56
|
+
});
|
|
57
|
+
|
|
50
58
|
if (options.twine_check) {
|
|
51
59
|
deps_run.addArgs(&.{
|
|
52
|
-
"-m",
|
|
53
|
-
"pip",
|
|
54
|
-
"install",
|
|
55
|
-
"-U",
|
|
56
60
|
"pip",
|
|
57
61
|
"wheel",
|
|
58
62
|
"twine",
|
|
59
63
|
});
|
|
60
64
|
} else {
|
|
61
65
|
deps_run.addArgs(&.{
|
|
62
|
-
"-m",
|
|
63
|
-
"pip",
|
|
64
|
-
"install",
|
|
65
|
-
"-U",
|
|
66
66
|
"pip",
|
|
67
67
|
"wheel",
|
|
68
68
|
});
|
|
@@ -30,22 +30,3 @@ pub fn format(self: @This(), w: *std.Io.Writer) !void {
|
|
|
30
30
|
try w.writeAll("\n");
|
|
31
31
|
try w.writeAll(self.description.items);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
// Metadata-Version: 2.4
|
|
35
|
-
// Name: zig-zon
|
|
36
|
-
// Version: 0.1.3
|
|
37
|
-
// Summary: a native cpython extension to parse zig object notation strings
|
|
38
|
-
// Author-email: Tobias Simetsreiter <dasimmet@gmail.com>
|
|
39
|
-
// Maintainer-email: Tobias Simetsreiter <dasimmet@gmail.com>
|
|
40
|
-
// License-Expression: MIT
|
|
41
|
-
// Project-URL: Homepage, https://codeberg.org/dasimmet/python-zig-zon
|
|
42
|
-
// Project-URL: Issues, https://codeberg.org/dasimmet/python-zig-zon/issues
|
|
43
|
-
// Keywords: zig,ziglang,zon,cpython
|
|
44
|
-
// Classifier: Development Status :: 4 - Beta
|
|
45
|
-
// Classifier: Intended Audience :: Developers
|
|
46
|
-
// Classifier: Programming Language :: Python :: 3
|
|
47
|
-
// Classifier: Programming Language :: Python :: 3.9
|
|
48
|
-
// Requires-Python: >=3.9
|
|
49
|
-
// Description-Content-Type: text/markdown
|
|
50
|
-
// License-File: LICENSE
|
|
51
|
-
// Dynamic: license-file
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const builtin = @import("builtin");
|
|
3
|
+
const assert = std.debug.assert;
|
|
4
|
+
pub const c = @import("c");
|
|
5
|
+
pub const version = @embedFile("version");
|
|
6
|
+
|
|
7
|
+
pub fn addVersion(mod: [*c]c.PyObject) void {
|
|
8
|
+
const semver = comptime std.SemanticVersion.parse(version) catch {
|
|
9
|
+
@compileLog("could not parse version:");
|
|
10
|
+
@compileError(version);
|
|
11
|
+
};
|
|
12
|
+
const version_dict = c.PyDict_New();
|
|
13
|
+
const None = c.Py_BuildValue("");
|
|
14
|
+
|
|
15
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "major", c.Py_BuildValue("n", semver.major)));
|
|
16
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "minor", c.Py_BuildValue("n", semver.minor)));
|
|
17
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "patch", c.Py_BuildValue("n", semver.patch)));
|
|
18
|
+
|
|
19
|
+
if (semver.pre) |pre| {
|
|
20
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "pre", c.Py_BuildValue("s#", pre.ptr, pre.len)));
|
|
21
|
+
} else {
|
|
22
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "pre", None));
|
|
23
|
+
}
|
|
24
|
+
if (semver.build) |build| {
|
|
25
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "build", c.Py_BuildValue("s#", build.ptr, build.len)));
|
|
26
|
+
} else {
|
|
27
|
+
assert(0 <= c.PyDict_SetItemString(version_dict, "build", None));
|
|
28
|
+
}
|
|
29
|
+
assert(0 <= c.PyObject_SetAttrString(
|
|
30
|
+
mod,
|
|
31
|
+
"__version__",
|
|
32
|
+
version_dict,
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
const version_str = c.Py_BuildValue("s#", version.ptr, version.len);
|
|
36
|
+
assert(0 <= c.PyObject_SetAttrString(
|
|
37
|
+
mod,
|
|
38
|
+
"__version_str__",
|
|
39
|
+
version_str,
|
|
40
|
+
));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn addZigBuiltin(mod: [*c]c.PyObject) void {
|
|
44
|
+
var arena_instance = std.heap.ArenaAllocator.init(std.heap.c_allocator);
|
|
45
|
+
defer arena_instance.deinit();
|
|
46
|
+
const arena = arena_instance.allocator();
|
|
47
|
+
|
|
48
|
+
const None = c.Py_BuildValue("");
|
|
49
|
+
|
|
50
|
+
const zig_dict = c.PyDict_New();
|
|
51
|
+
assert(0 <= c.PyObject_SetAttrString(
|
|
52
|
+
mod,
|
|
53
|
+
"__zig_builtin__",
|
|
54
|
+
zig_dict,
|
|
55
|
+
));
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
const version_str = c.Py_BuildValue("s#", builtin.zig_version_string.ptr, builtin.zig_version_string.len);
|
|
59
|
+
assert(0 <= c.PyDict_SetItemString(
|
|
60
|
+
zig_dict,
|
|
61
|
+
"zig_version",
|
|
62
|
+
version_str,
|
|
63
|
+
));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
const optmode = std.fmt.allocPrint(
|
|
68
|
+
arena,
|
|
69
|
+
"{s}",
|
|
70
|
+
.{@tagName(builtin.mode)},
|
|
71
|
+
) catch @panic("OOM");
|
|
72
|
+
const optmode_str = c.Py_BuildValue("s#", optmode.ptr, optmode.len);
|
|
73
|
+
assert(0 <= c.PyDict_SetItemString(
|
|
74
|
+
zig_dict,
|
|
75
|
+
"optimize",
|
|
76
|
+
optmode_str,
|
|
77
|
+
));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
const backend = std.fmt.allocPrint(
|
|
82
|
+
arena,
|
|
83
|
+
"{s}",
|
|
84
|
+
.{@tagName(builtin.zig_backend)},
|
|
85
|
+
) catch @panic("OOM");
|
|
86
|
+
const backend_str = c.Py_BuildValue("s#", backend.ptr, backend.len);
|
|
87
|
+
assert(0 <= c.PyDict_SetItemString(
|
|
88
|
+
zig_dict,
|
|
89
|
+
"backend",
|
|
90
|
+
backend_str,
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
{
|
|
95
|
+
const target_dict = c.PyDict_New();
|
|
96
|
+
assert(0 <= c.PyDict_SetItemString(
|
|
97
|
+
zig_dict,
|
|
98
|
+
"target",
|
|
99
|
+
target_dict,
|
|
100
|
+
));
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
const target_triple = builtin.target.zigTriple(arena) catch @panic("OOM");
|
|
104
|
+
const target_triple_str = c.Py_BuildValue("s#", target_triple.ptr, target_triple.len);
|
|
105
|
+
assert(0 <= c.PyDict_SetItemString(
|
|
106
|
+
target_dict,
|
|
107
|
+
"triple",
|
|
108
|
+
target_triple_str,
|
|
109
|
+
));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
{
|
|
113
|
+
const cpu_dict = c.PyDict_New();
|
|
114
|
+
assert(0 <= c.PyDict_SetItemString(target_dict, "cpu", cpu_dict));
|
|
115
|
+
const arch_tag = @tagName(builtin.cpu.arch);
|
|
116
|
+
const arch_str = c.Py_BuildValue("s#", arch_tag.ptr, arch_tag.len);
|
|
117
|
+
assert(0 <= c.PyDict_SetItemString(cpu_dict, "arch", arch_str));
|
|
118
|
+
const model_str = c.Py_BuildValue("s#", builtin.cpu.model.name.ptr, builtin.cpu.model.name.len);
|
|
119
|
+
assert(0 <= c.PyDict_SetItemString(cpu_dict, "model", model_str));
|
|
120
|
+
const features = c.PyList_New(0);
|
|
121
|
+
assert(0 <= c.PyDict_SetItemString(cpu_dict, "features", features));
|
|
122
|
+
|
|
123
|
+
inline for (comptime builtin.target.cpu.arch.allFeaturesList()) |feature| {
|
|
124
|
+
if (builtin.target.cpu.has(builtin.target.cpu.arch.family(), @enumFromInt(feature.index))) {
|
|
125
|
+
const feature_str = c.Py_BuildValue("s#", feature.name.ptr, feature.name.len);
|
|
126
|
+
assert(c.PyList_Append(features, feature_str) >= 0);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
{
|
|
131
|
+
const os_dict = c.PyDict_New();
|
|
132
|
+
assert(0 <= c.PyDict_SetItemString(target_dict, "os", os_dict));
|
|
133
|
+
const os_tag = @tagName(builtin.os.tag);
|
|
134
|
+
const os_str = c.Py_BuildValue("s#", os_tag.ptr, os_tag.len);
|
|
135
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "tag", os_str));
|
|
136
|
+
switch (builtin.target.os.versionRange()) {
|
|
137
|
+
.linux => |vrange| {
|
|
138
|
+
const android = c.Py_BuildValue("d", vrange.android);
|
|
139
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "android", android));
|
|
140
|
+
|
|
141
|
+
const glibc = std.fmt.allocPrint(
|
|
142
|
+
arena,
|
|
143
|
+
"{f}",
|
|
144
|
+
.{vrange.glibc},
|
|
145
|
+
) catch @panic("OOM");
|
|
146
|
+
const glibc_str = c.Py_BuildValue("s#", glibc.ptr, glibc.len);
|
|
147
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "glibc_version", glibc_str));
|
|
148
|
+
|
|
149
|
+
const min = std.fmt.allocPrint(
|
|
150
|
+
arena,
|
|
151
|
+
"{f}",
|
|
152
|
+
.{vrange.range.min},
|
|
153
|
+
) catch @panic("OOM");
|
|
154
|
+
const min_str = c.Py_BuildValue("s#", min.ptr, min.len);
|
|
155
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "min_version", min_str));
|
|
156
|
+
|
|
157
|
+
const max = std.fmt.allocPrint(
|
|
158
|
+
arena,
|
|
159
|
+
"{f}",
|
|
160
|
+
.{vrange.range.max},
|
|
161
|
+
) catch @panic("OOM");
|
|
162
|
+
const max_str = c.Py_BuildValue("s#", max.ptr, max.len);
|
|
163
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "max_version", max_str));
|
|
164
|
+
},
|
|
165
|
+
.windows => |vrange| {
|
|
166
|
+
const min = std.fmt.allocPrint(
|
|
167
|
+
arena,
|
|
168
|
+
"{f}",
|
|
169
|
+
.{vrange.min},
|
|
170
|
+
) catch @panic("OOM");
|
|
171
|
+
const min_str = c.Py_BuildValue("s#", min.ptr, min.len);
|
|
172
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "min_version", min_str));
|
|
173
|
+
|
|
174
|
+
const max = std.fmt.allocPrint(
|
|
175
|
+
arena,
|
|
176
|
+
"{f}",
|
|
177
|
+
.{vrange.max},
|
|
178
|
+
) catch @panic("OOM");
|
|
179
|
+
const max_str = c.Py_BuildValue("s#", max.ptr, max.len);
|
|
180
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "max_version", max_str));
|
|
181
|
+
},
|
|
182
|
+
.semver => |vrange| {
|
|
183
|
+
const min = std.fmt.allocPrint(
|
|
184
|
+
arena,
|
|
185
|
+
"{f}",
|
|
186
|
+
.{vrange.min},
|
|
187
|
+
) catch @panic("OOM");
|
|
188
|
+
const min_str = c.Py_BuildValue("s#", min.ptr, min.len);
|
|
189
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "min_version", min_str));
|
|
190
|
+
|
|
191
|
+
const max = std.fmt.allocPrint(
|
|
192
|
+
arena,
|
|
193
|
+
"{f}",
|
|
194
|
+
.{vrange.max},
|
|
195
|
+
) catch @panic("OOM");
|
|
196
|
+
const max_str = c.Py_BuildValue("s#", max.ptr, max.len);
|
|
197
|
+
assert(0 <= c.PyDict_SetItemString(os_dict, "max_version", max_str));
|
|
198
|
+
},
|
|
199
|
+
.hurd => {},
|
|
200
|
+
.none => {},
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
const abi_tag = @tagName(builtin.target.abi);
|
|
206
|
+
const abi_str = c.Py_BuildValue("s#", abi_tag.ptr, abi_tag.len);
|
|
207
|
+
assert(0 <= c.PyDict_SetItemString(target_dict, "abi", abi_str));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (builtin.target.dynamic_linker.get()) |linker| {
|
|
211
|
+
const dynamic_linker = c.Py_BuildValue("s#", linker.ptr, linker.len);
|
|
212
|
+
assert(0 <= c.PyDict_SetItemString(target_dict, "dynamic_linker", dynamic_linker));
|
|
213
|
+
} else {
|
|
214
|
+
assert(0 <= c.PyDict_SetItemString(target_dict, "dynamic_linker", None));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
zig-zon-0.2.2/setup.zig.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"zig_zon","version":{"major":0,"minor":2,"patch":2,"pre":null,"build":null},"zig_version":{"major":0,"minor":16,"patch":0,"pre":null,"build":null},"build":{"args":["pyext","-Doptimize=ReleaseSafe","--fork=zig-pkg/zig_python_sdist"],"requires":[]}}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const builtin = @import("builtin");
|
|
3
|
-
pub const c = @import("c");
|
|
4
|
-
pub const version = @embedFile("version");
|
|
5
|
-
|
|
6
|
-
pub fn addVersion(mod: [*c]c.PyObject) void {
|
|
7
|
-
const semver = comptime std.SemanticVersion.parse(version) catch {
|
|
8
|
-
@compileLog("could not parse version:");
|
|
9
|
-
@compileError(version);
|
|
10
|
-
};
|
|
11
|
-
const version_dict = c.PyDict_New();
|
|
12
|
-
|
|
13
|
-
_ = c.PyDict_SetItemString(version_dict, "major", c.Py_BuildValue("n", semver.major));
|
|
14
|
-
_ = c.PyDict_SetItemString(version_dict, "minor", c.Py_BuildValue("n", semver.minor));
|
|
15
|
-
_ = c.PyDict_SetItemString(version_dict, "patch", c.Py_BuildValue("n", semver.patch));
|
|
16
|
-
if (semver.pre) |pre| {
|
|
17
|
-
_ = c.PyDict_SetItemString(version_dict, "pre", c.Py_BuildValue("s#", pre.ptr, pre.len));
|
|
18
|
-
} else {
|
|
19
|
-
_ = c.PyDict_SetItemString(version_dict, "pre", c.Py_BuildValue(""));
|
|
20
|
-
}
|
|
21
|
-
if (semver.build) |build| {
|
|
22
|
-
_ = c.PyDict_SetItemString(version_dict, "build", c.Py_BuildValue("s#", build.ptr, build.len));
|
|
23
|
-
} else {
|
|
24
|
-
_ = c.PyDict_SetItemString(version_dict, "build", c.Py_BuildValue(""));
|
|
25
|
-
}
|
|
26
|
-
_ = c.PyObject_SetAttrString(
|
|
27
|
-
mod,
|
|
28
|
-
"__version__",
|
|
29
|
-
version_dict,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const version_str = c.Py_BuildValue("s#", version.ptr, version.len);
|
|
33
|
-
_ = c.PyObject_SetAttrString(
|
|
34
|
-
mod,
|
|
35
|
-
"__version_str__",
|
|
36
|
-
version_str,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pub fn addZigTargetTriple(mod: [*c]c.PyObject) void {
|
|
41
|
-
var arena_instance = std.heap.ArenaAllocator.init(std.heap.c_allocator);
|
|
42
|
-
defer arena_instance.deinit();
|
|
43
|
-
const target_triple = builtin.target.zigTriple(arena_instance.allocator()) catch @panic("OOM");
|
|
44
|
-
const target_triple_str = c.Py_BuildValue("s#", target_triple.ptr, target_triple.len);
|
|
45
|
-
_ = c.PyObject_SetAttrString(
|
|
46
|
-
mod,
|
|
47
|
-
"__zig_target_triple__",
|
|
48
|
-
target_triple_str,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{zig-zon-0.2.2 → zig-zon-0.2.3}/zig-pkg/zig_python_sdist/src/build/LowerDashStringFormatter.zig
RENAMED
|
File without changes
|
|
File without changes
|