zig-zon 0.2.1__tar.gz → 0.2.2__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.1 → zig-zon-0.2.2}/PKG-INFO +18 -1
- {zig-zon-0.2.1 → zig-zon-0.2.2}/build.zig +25 -33
- {zig-zon-0.2.1 → zig-zon-0.2.2}/build.zig.zon +4 -3
- zig-zon-0.2.2/pkg-info.zon +11 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/setup.zig.json +1 -1
- {zig-zon-0.2.1 → zig-zon-0.2.2}/src/zig_zon.zig +14 -8
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/build.zig +4 -12
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/build.zig.zon +1 -0
- zig-zon-0.2.2/zig-pkg/zig_python_sdist/pkg-info.zon +11 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/CPython.zig +1 -66
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/SDistStep.zig +2 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/VenvInstallTest.zig +34 -9
- zig-zon-0.2.2/zig-pkg/zig_python_sdist/src/build/extract_link_info.py +84 -0
- zig-zon-0.2.1/zig-pkg/zig_python_sdist/src/build/extract_link_info.py +0 -72
- {zig-zon-0.2.1 → zig-zon-0.2.2}/setup.py +0 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/LICENSE +0 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/README.md +0 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/LowerDashStringFormatter.zig +0 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/pkg_info.zig +0 -0
- {zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/python.zig +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.2
|
|
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>
|
|
@@ -41,6 +41,23 @@ print(parsed)
|
|
|
41
41
|
|
|
42
42
|
or, look at the [test file](https://codeberg.org/dasimmet/python-zig-zon/src/branch/main/src/test_zig_zon.py)
|
|
43
43
|
|
|
44
|
+
## Supported values and their python type
|
|
45
|
+
|
|
46
|
+
- `structs` -> `dict`
|
|
47
|
+
- `tuples` -> `list`
|
|
48
|
+
- `integer literals` -> `int`
|
|
49
|
+
- `hex literals` -> `int`
|
|
50
|
+
- `float literals` -> `float`
|
|
51
|
+
- `booleans` -> `bool`
|
|
52
|
+
- `null` -> `None`
|
|
53
|
+
- `string literals` -> `str`
|
|
54
|
+
- `bare enum literals` -> `str`
|
|
55
|
+
- `quoted enum literals` -> `str`
|
|
56
|
+
|
|
57
|
+
## Not supported values
|
|
58
|
+
|
|
59
|
+
- `bigint`
|
|
60
|
+
|
|
44
61
|
## How it works
|
|
45
62
|
|
|
46
63
|
The `zig build` commands produces a python source distribution archive ready
|
|
@@ -10,27 +10,6 @@ pub fn build(b: *Build) void {
|
|
|
10
10
|
|
|
11
11
|
// this target and section of our build is used at pip install time
|
|
12
12
|
const ext_install_step = b.step("pyext", "build python extension module");
|
|
13
|
-
{
|
|
14
|
-
const cpython = zig_python_sdist.CPython.find(b);
|
|
15
|
-
|
|
16
|
-
const lib = b.addLibrary(.{
|
|
17
|
-
.name = "zig_zon",
|
|
18
|
-
.root_module = b.addModule("zig_zon", .{
|
|
19
|
-
.root_source_file = b.path("src/zig_zon.zig"),
|
|
20
|
-
.target = target,
|
|
21
|
-
.optimize = optimize,
|
|
22
|
-
}),
|
|
23
|
-
.linkage = .dynamic,
|
|
24
|
-
});
|
|
25
|
-
cpython.link(b, .{
|
|
26
|
-
.lib = lib,
|
|
27
|
-
.version = zon.version,
|
|
28
|
-
.optimize = .ReleaseSmall,
|
|
29
|
-
});
|
|
30
|
-
const ext_install = zig_python_sdist.CPython.installExtLib(b, lib);
|
|
31
|
-
|
|
32
|
-
ext_install_step.dependOn(&ext_install.step);
|
|
33
|
-
}
|
|
34
13
|
|
|
35
14
|
// this generates a python sdist archive
|
|
36
15
|
const sdist = zig_python_sdist.create(b, .{
|
|
@@ -40,19 +19,9 @@ pub fn build(b: *Build) void {
|
|
|
40
19
|
.build = .{
|
|
41
20
|
.args = &.{ ext_install_step.name, b.fmt("-Doptimize={s}", .{@tagName(optimize)}) },
|
|
42
21
|
},
|
|
43
|
-
.extra_pkg_info =
|
|
44
|
-
.{ .key = "Summary", .value = "a native cpython extension to parse zig object notation strings" },
|
|
45
|
-
.{ .key = "Author-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
46
|
-
.{ .key = "Maintainer-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
47
|
-
.{ .key = "License-Expression", .value = "MIT" },
|
|
48
|
-
.{ .key = "Keywords", .value = "zig,ziglang,cpython,native,sdist,zon" },
|
|
49
|
-
.{ .key = "Requires-Python", .value = ">=3.8" },
|
|
50
|
-
.{ .key = "Project-URL", .value = "Homepage, https://codeberg.org/dasimmet/python-zig-zon" },
|
|
51
|
-
.{ .key = "Project-URL", .value = "Issues, https://codeberg.org/dasimmet/python-zig-zon/issues" },
|
|
52
|
-
// .{ .key = "Requires-Python", .value = ">=3.8" },
|
|
53
|
-
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
54
|
-
},
|
|
22
|
+
.extra_pkg_info = @import("pkg-info.zon"),
|
|
55
23
|
.files = &.{
|
|
24
|
+
.{ .src = b.path("pkg-info.zon"), .dest = "pkg-info.zon" },
|
|
56
25
|
.{ .src = b.path("build.zig.zon"), .dest = "build.zig.zon" },
|
|
57
26
|
.{ .src = b.path("build.zig"), .dest = "build.zig" },
|
|
58
27
|
.{ .src = b.path("src/zig_zon.zig"), .dest = "src/zig_zon.zig" },
|
|
@@ -73,8 +42,31 @@ pub fn build(b: *Build) void {
|
|
|
73
42
|
.{
|
|
74
43
|
.sdist = sdist.getEmittedArchive(),
|
|
75
44
|
.test_py = b.path("src/test_zig_zon.py"),
|
|
45
|
+
.twine_check = true,
|
|
76
46
|
.no_clean = b.option(bool, "pip-no-clean", "dont cleanup pip temp dirs") orelse false,
|
|
77
47
|
},
|
|
78
48
|
);
|
|
79
49
|
b.step("test-pip-install", "").dependOn(test_pip_install.step);
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
const cpython = zig_python_sdist.CPython.find(b);
|
|
53
|
+
|
|
54
|
+
const lib = b.addLibrary(.{
|
|
55
|
+
.name = "zig_zon",
|
|
56
|
+
.root_module = b.addModule("zig_zon", .{
|
|
57
|
+
.root_source_file = b.path("src/zig_zon.zig"),
|
|
58
|
+
.target = target,
|
|
59
|
+
.optimize = optimize,
|
|
60
|
+
}),
|
|
61
|
+
.linkage = .dynamic,
|
|
62
|
+
});
|
|
63
|
+
cpython.link(b, .{
|
|
64
|
+
.lib = lib,
|
|
65
|
+
.version = zon.version,
|
|
66
|
+
.optimize = .ReleaseSmall,
|
|
67
|
+
});
|
|
68
|
+
const ext_install = zig_python_sdist.CPython.installExtLib(b, lib);
|
|
69
|
+
|
|
70
|
+
ext_install_step.dependOn(&ext_install.step);
|
|
71
|
+
}
|
|
80
72
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
.{
|
|
2
2
|
.name = .python_zig_zon,
|
|
3
3
|
.fingerprint = 0x3d332656a3644fc9,
|
|
4
|
-
.version = "0.2.
|
|
4
|
+
.version = "0.2.2",
|
|
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.1-
|
|
8
|
+
.url = "git+https://codeberg.org/dasimmet/zig-python-sdist.git#d5bd94633cf5923342108c824f61b377a2a8c492",
|
|
9
|
+
.hash = "zig_python_sdist-0.0.1-wjgdOsiNAAC2GtJiAx3dGIloYzgt1_sojmm62pPPalAS",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
.paths = .{
|
|
13
13
|
"src",
|
|
14
14
|
"build.zig",
|
|
15
15
|
"build.zig.zon",
|
|
16
|
+
"pkg-info.zon",
|
|
16
17
|
"LICENSE",
|
|
17
18
|
"README.md",
|
|
18
19
|
"setup.py",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.{
|
|
2
|
+
.{ .key = "Summary", .value = "a native cpython extension to parse zig object notation strings" },
|
|
3
|
+
.{ .key = "Author-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
4
|
+
.{ .key = "Maintainer-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
5
|
+
.{ .key = "License-Expression", .value = "MIT" },
|
|
6
|
+
.{ .key = "Keywords", .value = "zig,ziglang,cpython,native,sdist,zon" },
|
|
7
|
+
.{ .key = "Requires-Python", .value = ">=3.8" },
|
|
8
|
+
.{ .key = "Project-URL", .value = "Homepage, https://codeberg.org/dasimmet/python-zig-zon" },
|
|
9
|
+
.{ .key = "Project-URL", .value = "Issues, https://codeberg.org/dasimmet/python-zig-zon/issues" },
|
|
10
|
+
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"zig_zon","version":{"major":0,"minor":2,"patch":
|
|
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":[]}}
|
|
@@ -66,7 +66,7 @@ pub fn parse(self: [*]PyObject, args: [*]PyObject) callconv(.c) [*c]PyObject {
|
|
|
66
66
|
|
|
67
67
|
const main_node_index = ast.nodeData(.root).node;
|
|
68
68
|
|
|
69
|
-
return
|
|
69
|
+
return parseZonAst(arena, ast, main_node_index) catch |err| {
|
|
70
70
|
const errstr = std.fmt.allocPrintSentinel(
|
|
71
71
|
arena,
|
|
72
72
|
"zig-zon parse error: {s}",
|
|
@@ -86,10 +86,11 @@ const ZonError = error{
|
|
|
86
86
|
StructExpected,
|
|
87
87
|
StructIdentifierExpected,
|
|
88
88
|
NotImplemented,
|
|
89
|
-
|
|
89
|
+
ZonArrayInitFailed,
|
|
90
|
+
InvalidLiteral, // from quoted enum literal parse function
|
|
90
91
|
} || IdentifierError || NumberLiteralError;
|
|
91
92
|
|
|
92
|
-
fn
|
|
93
|
+
fn parseZonAst(arena: Allocator, tree: Ast, node: Ast.Node.Index) ZonError!*c.PyObject {
|
|
93
94
|
const node_tag = tree.nodeTag(node);
|
|
94
95
|
switch (node_tag) {
|
|
95
96
|
.struct_init_comma,
|
|
@@ -114,8 +115,13 @@ fn parseZon(arena: Allocator, tree: Ast, node: Ast.Node.Index) ZonError!*c.PyObj
|
|
|
114
115
|
const name_token = tree.firstToken(node);
|
|
115
116
|
const enum_name = tree.tokenSlice(name_token + 1);
|
|
116
117
|
if (std.mem.startsWith(u8, enum_name, "@")) {
|
|
117
|
-
std.
|
|
118
|
-
|
|
118
|
+
std.debug.assert(std.mem.startsWith(u8, enum_name, "@\""));
|
|
119
|
+
std.debug.assert(std.mem.endsWith(u8, enum_name, "\""));
|
|
120
|
+
const enum_parsed_name = try std.zig.string_literal.parseAlloc(
|
|
121
|
+
arena,
|
|
122
|
+
enum_name[1..enum_name.len],
|
|
123
|
+
);
|
|
124
|
+
return c.Py_BuildValue("s#", enum_parsed_name.ptr, enum_parsed_name.len);
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
return c.Py_BuildValue("s#", enum_name.ptr, enum_name.len);
|
|
@@ -208,7 +214,7 @@ fn parseZonStruct(arena: Allocator, tree: Ast, node: Ast.Node.Index) ZonError!*c
|
|
|
208
214
|
for (struct_init.ast.fields) |field_init| {
|
|
209
215
|
const name_token = tree.firstToken(field_init) - 2;
|
|
210
216
|
const field_name = try identifierTokenString(arena, tree, name_token);
|
|
211
|
-
const field_obj = try
|
|
217
|
+
const field_obj = try parseZonAst(arena, tree, field_init);
|
|
212
218
|
const set_result = c.PyDict_SetItemString(ret, field_name, field_obj);
|
|
213
219
|
assert(set_result >= 0);
|
|
214
220
|
}
|
|
@@ -221,13 +227,13 @@ fn parseZonArray(arena: Allocator, tree: Ast, node: Ast.Node.Index) !*c.PyObject
|
|
|
221
227
|
const array_init = tree.fullArrayInit(&buf, node) orelse {
|
|
222
228
|
const tok = tree.nodeMainToken(node);
|
|
223
229
|
std.log.err("expected paths expression to be a list of strings, got: {d}", .{tok});
|
|
224
|
-
return error.
|
|
230
|
+
return error.ZonArrayInitFailed;
|
|
225
231
|
};
|
|
226
232
|
|
|
227
233
|
const ret = c.PyList_New(0);
|
|
228
234
|
|
|
229
235
|
for (array_init.ast.elements) |elem_node| {
|
|
230
|
-
const field_ret = try
|
|
236
|
+
const field_ret = try parseZonAst(arena, tree, elem_node);
|
|
231
237
|
assert(c.PyList_Append(ret, field_ret) >= 0);
|
|
232
238
|
}
|
|
233
239
|
return ret;
|
|
@@ -52,20 +52,11 @@ pub fn build(b: *Build) void {
|
|
|
52
52
|
.build = .{
|
|
53
53
|
.args = &.{build_ext_step.name},
|
|
54
54
|
},
|
|
55
|
-
.extra_pkg_info =
|
|
56
|
-
.{ .key = "Summary", .value = "Just a Test" },
|
|
57
|
-
.{ .key = "Author-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
58
|
-
.{ .key = "Maintainer-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
59
|
-
.{ .key = "License-Expression", .value = "MIT" },
|
|
60
|
-
.{ .key = "Keywords", .value = "zig,ziglang,cpython,native,sdist" },
|
|
61
|
-
.{ .key = "Requires-Python", .value = ">=3.8" },
|
|
62
|
-
.{ .key = "Project-URL", .value = "Homepage, https://codeberg.org/dasimmet/zig-python-sdist" },
|
|
63
|
-
.{ .key = "Project-URL", .value = "Issues, https://codeberg.org/dasimmet/zig-python-sdist/issues" },
|
|
64
|
-
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
65
|
-
},
|
|
55
|
+
.extra_pkg_info = @import("pkg-info.zon"),
|
|
66
56
|
.files = &.{
|
|
67
57
|
.{ .src = b.path("build.zig.zon"), .dest = "build.zig.zon" },
|
|
68
58
|
.{ .src = b.path("build.zig"), .dest = "build.zig" },
|
|
59
|
+
.{ .src = b.path("pkg-info.zon"), .dest = "pkg-info.zon" },
|
|
69
60
|
.{ .src = b.path("example/sdist_dummy.zig"), .dest = "example/sdist_dummy.zig" },
|
|
70
61
|
},
|
|
71
62
|
.directories = &.{
|
|
@@ -87,6 +78,7 @@ pub fn build(b: *Build) void {
|
|
|
87
78
|
.{
|
|
88
79
|
.sdist = sdist.getEmittedArchive(),
|
|
89
80
|
.test_py = b.path("example/test_ext.py"),
|
|
81
|
+
.twine_check = true,
|
|
90
82
|
.no_clean = b.option(bool, "pip-no-clean", "cleanup pip temp dirs") orelse false,
|
|
91
83
|
},
|
|
92
84
|
);
|
|
@@ -106,6 +98,7 @@ pub fn create(b: *Build, options: SDistStep.Options) *SDistStep {
|
|
|
106
98
|
const extra_files: []const SDistStep.Content = &.{
|
|
107
99
|
.{ .src = sdist.path("build.zig.zon"), .dest = "zig-pkg/zig_python_sdist/build.zig.zon" },
|
|
108
100
|
.{ .src = sdist.path("build.zig"), .dest = "zig-pkg/zig_python_sdist/build.zig" },
|
|
101
|
+
.{ .src = sdist.path("pkg-info.zon"), .dest = "zig-pkg/zig_python_sdist/pkg-info.zon" },
|
|
109
102
|
.{ .src = sdist.path("README.md"), .dest = "zig-pkg/zig_python_sdist/README.md" },
|
|
110
103
|
.{ .src = sdist.path("LICENSE"), .dest = "zig-pkg/zig_python_sdist/LICENSE" },
|
|
111
104
|
};
|
|
@@ -121,7 +114,6 @@ pub fn create(b: *Build, options: SDistStep.Options) *SDistStep {
|
|
|
121
114
|
{
|
|
122
115
|
var dirs: std.ArrayList(SDistStep.Content) = .empty;
|
|
123
116
|
const extra_dirs: []const SDistStep.Content = &.{
|
|
124
|
-
// .{ .src = sdist.path("src"), .dest = "zig-pkg/zig_python_sdist/src" },
|
|
125
117
|
.{ .src = sdist.path("src/build"), .dest = "zig-pkg/zig_python_sdist/src/build" },
|
|
126
118
|
};
|
|
127
119
|
dirs.ensureTotalCapacity(
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.{
|
|
2
|
+
.{ .key = "Summary", .value = "Just a Test" },
|
|
3
|
+
.{ .key = "Author-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
4
|
+
.{ .key = "Maintainer-email", .value = "Tobias Simetsreiter <dasimmet@gmail.com>" },
|
|
5
|
+
.{ .key = "License-Expression", .value = "MIT" },
|
|
6
|
+
.{ .key = "Keywords", .value = "zig,ziglang,cpython,native,sdist" },
|
|
7
|
+
.{ .key = "Requires-Python", .value = ">=3.8" },
|
|
8
|
+
.{ .key = "Project-URL", .value = "Homepage, https://codeberg.org/dasimmet/zig-python-sdist" },
|
|
9
|
+
.{ .key = "Project-URL", .value = "Issues, https://codeberg.org/dasimmet/zig-python-sdist/issues" },
|
|
10
|
+
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
11
|
+
}
|
|
@@ -77,7 +77,7 @@ pub fn link(self: CPython, b: *Build, options: LinkOptions) void {
|
|
|
77
77
|
const python_inc = self.generateIncludeDir(b);
|
|
78
78
|
|
|
79
79
|
const cpython = b.addTranslateC(.{
|
|
80
|
-
.root_source_file = python_inc.path(b, "
|
|
80
|
+
.root_source_file = python_inc.path(b, "zig_python_include.h"),
|
|
81
81
|
.optimize = options.optimize orelse options.lib.root_module.optimize orelse .ReleaseSafe,
|
|
82
82
|
.target = target,
|
|
83
83
|
});
|
|
@@ -124,71 +124,6 @@ pub fn lib_ext_name(b: *Build, lib: *Build.Step.Compile) []const u8 {
|
|
|
124
124
|
b.fmt("{s}.so", .{lib.name});
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
pub fn run_test(
|
|
128
|
-
self: CPython,
|
|
129
|
-
b: *Build,
|
|
130
|
-
lib: *Build.Step.Compile,
|
|
131
|
-
test_py_file: Build.LazyPath,
|
|
132
|
-
) *Build.Step.Run {
|
|
133
|
-
const wf = b.addWriteFiles();
|
|
134
|
-
const python_runner = wf.add("python-runner.zig", @embedFile("python-runner.zig"));
|
|
135
|
-
|
|
136
|
-
const runner = b.addExecutable(.{
|
|
137
|
-
.name = "python-runner",
|
|
138
|
-
.root_module = b.createModule(.{
|
|
139
|
-
.root_source_file = python_runner,
|
|
140
|
-
.target = b.graph.host,
|
|
141
|
-
.optimize = .ReleaseSmall,
|
|
142
|
-
}),
|
|
143
|
-
});
|
|
144
|
-
const run_step = b.addRunArtifact(runner);
|
|
145
|
-
const python_ext = writeExtensionFile(b, lib);
|
|
146
|
-
run_step.addFileArg(self.exe);
|
|
147
|
-
run_step.addDirectoryArg(python_ext.dirname());
|
|
148
|
-
run_step.addFileArg(test_py_file);
|
|
149
|
-
run_step.has_side_effects = true;
|
|
150
|
-
return run_step;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
pub fn writeExtensionFile(b: *Build, lib: *Build.Step.Compile) Build.LazyPath {
|
|
154
|
-
const ext_lib_name = lib_ext_name(b, lib);
|
|
155
|
-
const wf = b.addWriteFiles();
|
|
156
|
-
return wf.addCopyFile(lib.getEmittedBin(), ext_lib_name);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
pub fn addSdistList(b: *Build) void {
|
|
160
|
-
const wf = b.addWriteFiles();
|
|
161
|
-
var wr: std.Io.Writer.Allocating = .init(b.allocator);
|
|
162
|
-
var jw: std.json.Stringify = .{ .writer = &wr.writer };
|
|
163
|
-
jw.beginObject() catch @panic("OOM");
|
|
164
|
-
if (b.graph.global_cache_root.path) |global_cache| {
|
|
165
|
-
jw.objectField("global_cache_dir") catch @panic("OOM");
|
|
166
|
-
jw.write(global_cache) catch @panic("OOM");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
jw.objectField("dependencies") catch @panic("OOM");
|
|
170
|
-
jw.beginArray() catch @panic("OOM");
|
|
171
|
-
writeDeps(b, &jw) catch @panic("OOM");
|
|
172
|
-
jw.endArray() catch @panic("OOM");
|
|
173
|
-
jw.endObject() catch @panic("OOM");
|
|
174
|
-
|
|
175
|
-
const out = wf.add("sdistlist.json", wr.written());
|
|
176
|
-
const sdist_step = b.step("sdistlist", "generate a list of files for python sdist");
|
|
177
|
-
sdist_step.dependOn(&b.addInstallFile(out, "sdistlist.json").step);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
fn writeDeps(b: *std.Build, w: *std.json.Stringify) !void {
|
|
181
|
-
for (b.available_deps) |dep| {
|
|
182
|
-
try w.beginArray();
|
|
183
|
-
try w.write(dep[0]);
|
|
184
|
-
try w.write(dep[1]);
|
|
185
|
-
try w.endArray();
|
|
186
|
-
if (b.lazyDependency(dep[0], .{})) |lazy_dep| {
|
|
187
|
-
try writeDeps(lazy_dep.builder, w);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
127
|
// compat for 0.16.0 and 0.17.0
|
|
193
128
|
pub fn findProgramCompat(b: *std.Build, names: []const []const u8) ?[]const u8 {
|
|
194
129
|
if (comptime (@import("builtin").zig_version.order(std.SemanticVersion.parse("0.16.0") catch unreachable) == .gt)) {
|
|
@@ -9,10 +9,12 @@ const SDistStep = @This();
|
|
|
9
9
|
basename: []const u8,
|
|
10
10
|
builder: *Build.Step.Compile,
|
|
11
11
|
archive: LazyPath,
|
|
12
|
+
|
|
12
13
|
pub const Content = struct {
|
|
13
14
|
src: LazyPath,
|
|
14
15
|
dest: []const u8,
|
|
15
16
|
};
|
|
17
|
+
|
|
16
18
|
pub const Options = struct {
|
|
17
19
|
name: []const u8,
|
|
18
20
|
version: []const u8,
|
|
@@ -16,6 +16,7 @@ pub const Options = struct {
|
|
|
16
16
|
no_clean: bool,
|
|
17
17
|
// pass in python interpreter. uses system python if null
|
|
18
18
|
python: ?LazyPath = null,
|
|
19
|
+
twine_check: bool = false,
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
pub fn create(b: *Build, options: Options) *VenvInstallTest {
|
|
@@ -44,19 +45,43 @@ pub fn create(b: *Build, options: Options) *VenvInstallTest {
|
|
|
44
45
|
|
|
45
46
|
const deps_run = std.Build.Step.Run.create(b, "venv");
|
|
46
47
|
deps_run.addFileArg(venv_python);
|
|
47
|
-
deps_run.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
deps_run.step.dependOn(&wf.step);
|
|
49
|
+
|
|
50
|
+
if (options.twine_check) {
|
|
51
|
+
deps_run.addArgs(&.{
|
|
52
|
+
"-m",
|
|
53
|
+
"pip",
|
|
54
|
+
"install",
|
|
55
|
+
"-U",
|
|
56
|
+
"pip",
|
|
57
|
+
"wheel",
|
|
58
|
+
"twine",
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
deps_run.addArgs(&.{
|
|
62
|
+
"-m",
|
|
63
|
+
"pip",
|
|
64
|
+
"install",
|
|
65
|
+
"-U",
|
|
66
|
+
"pip",
|
|
67
|
+
"wheel",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
deps_run.step.dependOn(&venv_run.step);
|
|
56
72
|
|
|
57
|
-
self.install_run = std.Build.Step.Run.create(b, "
|
|
73
|
+
self.install_run = std.Build.Step.Run.create(b, "pip install");
|
|
58
74
|
self.step = &self.install_run.step;
|
|
59
75
|
|
|
76
|
+
if (options.twine_check) {
|
|
77
|
+
const twine_check = std.Build.Step.Run.create(b, "twine check");
|
|
78
|
+
twine_check.step.dependOn(&deps_run.step);
|
|
79
|
+
twine_check.addFileArg(venv_python);
|
|
80
|
+
twine_check.addArgs(&.{ "-m", "twine", "check", "--strict" });
|
|
81
|
+
twine_check.addFileArg(options.sdist);
|
|
82
|
+
self.step.dependOn(&twine_check.step);
|
|
83
|
+
}
|
|
84
|
+
|
|
60
85
|
self.install_run.addFileArg(venv_python);
|
|
61
86
|
self.install_run.addArgs(&.{ "-m", "pip", "install", "--force-reinstall", "--verbose" });
|
|
62
87
|
if (options.no_clean) self.install_run.addArg("--no-clean");
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import sysconfig
|
|
4
|
+
import sys
|
|
5
|
+
import shutil
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
output_dir = sys.argv[1]
|
|
11
|
+
syspath = sysconfig.get_paths()
|
|
12
|
+
|
|
13
|
+
python_h = os.path.join(output_dir, 'Python.h')
|
|
14
|
+
output_header = os.path.join(output_dir, 'zig_python_include.h')
|
|
15
|
+
|
|
16
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
17
|
+
shutil.copytree(syspath['include'], output_dir, dirs_exist_ok=True)
|
|
18
|
+
|
|
19
|
+
sources = [syspath['include']]
|
|
20
|
+
|
|
21
|
+
if sys.platform in ['windows', 'win32', 'cygwin']:
|
|
22
|
+
find_lib(output_dir, sources)
|
|
23
|
+
|
|
24
|
+
if not os.path.isfile(python_h):
|
|
25
|
+
raise Exception("Python.h missing! syspath include: {}\n output: {}".format(
|
|
26
|
+
syspath['include'], output_dir))
|
|
27
|
+
|
|
28
|
+
output_h_str = '''
|
|
29
|
+
// zig_python_include.h generated by extract_link_info.py
|
|
30
|
+
// sources: {}
|
|
31
|
+
#ifndef PY_SSIZE_T_CLEAN
|
|
32
|
+
#define PY_SSIZE_T_CLEAN
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
#ifndef PYHEXVER
|
|
36
|
+
#define PYHEXVER {}
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#include "Python.h"
|
|
40
|
+
'''.format(sources, sys.hexversion)
|
|
41
|
+
|
|
42
|
+
with open(output_header, 'w') as fd:
|
|
43
|
+
fd.write(output_h_str)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def find_lib(output_dir, sources=[]):
|
|
47
|
+
lib_filename = 'python{}{}.lib'.format(
|
|
48
|
+
sys.version_info.major, sys.version_info.minor)
|
|
49
|
+
found_lib = False
|
|
50
|
+
for k, v in sysconfig.get_config_vars().items():
|
|
51
|
+
if not isinstance(v, str):
|
|
52
|
+
continue
|
|
53
|
+
vf = os.path.join(v, lib_filename)
|
|
54
|
+
if os.path.exists(vf):
|
|
55
|
+
try:
|
|
56
|
+
shutil.copyfile(vf, os.path.join(output_dir, 'python.lib'))
|
|
57
|
+
found_lib = True
|
|
58
|
+
sources.append(vf)
|
|
59
|
+
break
|
|
60
|
+
except:
|
|
61
|
+
pass
|
|
62
|
+
else:
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
vfl = os.path.join(v, 'libs', lib_filename)
|
|
66
|
+
if os.path.exists(vfl):
|
|
67
|
+
try:
|
|
68
|
+
shutil.copyfile(vfl, os.path.join(
|
|
69
|
+
output_dir, 'python.lib'))
|
|
70
|
+
found_lib = True
|
|
71
|
+
sources.append(vfl)
|
|
72
|
+
break
|
|
73
|
+
except:
|
|
74
|
+
pass
|
|
75
|
+
else:
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
if not found_lib:
|
|
79
|
+
raise Exception(
|
|
80
|
+
" ".join(["Warning: Did not find", str(lib_filename)]))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == '__main__':
|
|
84
|
+
main()
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
import sysconfig
|
|
4
|
-
import sys
|
|
5
|
-
import shutil
|
|
6
|
-
import os
|
|
7
|
-
|
|
8
|
-
output_dir = sys.argv[1]
|
|
9
|
-
syspath = sysconfig.get_paths()
|
|
10
|
-
|
|
11
|
-
lib_filename = 'python{}{}.lib'.format(
|
|
12
|
-
sys.version_info.major, sys.version_info.minor)
|
|
13
|
-
|
|
14
|
-
os.makedirs(output_dir, exist_ok=True)
|
|
15
|
-
shutil.copytree(syspath['include'], output_dir, dirs_exist_ok=True)
|
|
16
|
-
|
|
17
|
-
found_lib = False
|
|
18
|
-
sources = [syspath['include']]
|
|
19
|
-
|
|
20
|
-
for k, v in sysconfig.get_config_vars().items():
|
|
21
|
-
if not isinstance(v, str):
|
|
22
|
-
continue
|
|
23
|
-
vf = os.path.join(v, lib_filename)
|
|
24
|
-
if os.path.exists(vf):
|
|
25
|
-
try:
|
|
26
|
-
shutil.copyfile(vf, os.path.join(output_dir, 'python.lib'))
|
|
27
|
-
found_lib = True
|
|
28
|
-
sources.append(vf)
|
|
29
|
-
break
|
|
30
|
-
except:
|
|
31
|
-
pass
|
|
32
|
-
else:
|
|
33
|
-
pass
|
|
34
|
-
|
|
35
|
-
vfl = os.path.join(v, 'libs', lib_filename)
|
|
36
|
-
if os.path.exists(vfl):
|
|
37
|
-
try:
|
|
38
|
-
shutil.copyfile(vfl, os.path.join(output_dir, 'python.lib'))
|
|
39
|
-
found_lib = True
|
|
40
|
-
sources.append(vfl)
|
|
41
|
-
break
|
|
42
|
-
except:
|
|
43
|
-
pass
|
|
44
|
-
else:
|
|
45
|
-
pass
|
|
46
|
-
|
|
47
|
-
if sys.platform == 'windows' and not found_lib:
|
|
48
|
-
print("Warning: Did not find", lib_filename, "in:", file=sys.stderr)
|
|
49
|
-
print(lib_paths, file=sys.stderr)
|
|
50
|
-
|
|
51
|
-
python_h = os.path.join(output_dir, 'Python.h')
|
|
52
|
-
if not os.path.isfile(python_h):
|
|
53
|
-
raise Exception("Python.h missing! syspath include: {}\n output: {}".format(
|
|
54
|
-
syspath['include'], output_dir))
|
|
55
|
-
|
|
56
|
-
output_header = os.path.join(output_dir, 'Zig_Python_With_Hexver.h')
|
|
57
|
-
|
|
58
|
-
with open(output_header, 'w') as fd:
|
|
59
|
-
fd.write('''
|
|
60
|
-
// Zig_Python_With_Hexver.h generated by extract_link_info.py
|
|
61
|
-
// sources: {}
|
|
62
|
-
#ifndef PY_SSIZE_T_CLEAN
|
|
63
|
-
#define PY_SSIZE_T_CLEAN
|
|
64
|
-
#endif
|
|
65
|
-
|
|
66
|
-
#ifndef PYHEXVER
|
|
67
|
-
#define PYHEXVER {}
|
|
68
|
-
#endif
|
|
69
|
-
|
|
70
|
-
#include "Python.h"
|
|
71
|
-
'''.format(sources, sys.hexversion))
|
|
72
|
-
print('OK:', output_header)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{zig-zon-0.2.1 → zig-zon-0.2.2}/zig-pkg/zig_python_sdist/src/build/LowerDashStringFormatter.zig
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|