zig-zon 0.3.2__tar.gz → 0.4.0__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.3.2 → zig-zon-0.4.0}/PKG-INFO +7 -10
- {zig-zon-0.3.2 → zig-zon-0.4.0}/build.zig +7 -3
- {zig-zon-0.3.2 → zig-zon-0.4.0}/build.zig.zon +4 -4
- {zig-zon-0.3.2 → zig-zon-0.4.0}/pkg-info.zon +1 -0
- zig-zon-0.4.0/setup.zig.json +1 -0
- {zig-zon-0.3.2 → zig-zon-0.4.0}/src/zig_zon.zig +31 -21
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/README.md +3 -1
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/build.zig +0 -2
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/build.zig.zon +2 -2
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/CPython.zig +1 -1
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/python.zig +2 -4
- zig-zon-0.3.2/setup.zig.json +0 -1
- {zig-zon-0.3.2 → zig-zon-0.4.0}/LICENSE +0 -0
- {zig-zon-0.3.2 → zig-zon-0.4.0}/setup.py +0 -0
- {zig-zon-0.3.2 → zig-zon-0.4.0}/src/zig_zon.pyi +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/LICENSE +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/pkg-info.zon +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/Compression.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/LowerDashString.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/SDistStep.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/VenvInstallTest.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/extract_link_info.py +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/pip_runner.py +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/pkg_info.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/python-translatec.h +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/python_allocator.zig +0 -0
- {zig-zon-0.3.2/zig-pkg/zig_python_sdist-0.0.8 → zig-zon-0.4.0/zig-pkg/zig_python_sdist-0.1.0}/src/build/setup_json.zig +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zig-zon
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
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>
|
|
@@ -9,6 +9,7 @@ Keywords: zig,ziglang,cpython,native,sdist,zon
|
|
|
9
9
|
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
|
+
Project-URL: Source, https://codeberg.org/dasimmet/python-zig-zon
|
|
12
13
|
Classifier: Development Status :: 4 - Beta
|
|
13
14
|
Classifier: Programming Language :: Python :: 3
|
|
14
15
|
Classifier: Programming Language :: Zig
|
|
@@ -27,12 +28,12 @@ It therefore needs to download the `ziglang` python package.
|
|
|
27
28
|
Depending on your OS, you may need the python development headers
|
|
28
29
|
(e.g. `python3-dev`) installed.
|
|
29
30
|
|
|
30
|
-
## Installation
|
|
31
|
+
## Installation from [PyPi](https://pypi.org/project/zig-zon) or [Release](https://codeberg.org/dasimmet/python-zig-zon/releases)
|
|
31
32
|
|
|
32
33
|
```bash
|
|
33
34
|
# from PyPi: https://pypi.org/project/zig-zon
|
|
34
35
|
pip install zig-zon
|
|
35
|
-
# directly from the Codeberg Release:
|
|
36
|
+
# directly from the Codeberg Release (check for the latest version):
|
|
36
37
|
pip install https://codeberg.org/dasimmet/python-zig-zon/releases/download/0.3.2/zig_zon-0.3.2.tar.gz
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -123,7 +124,7 @@ with open("build.zig.zon", "w", encoding="utf-8") as f:
|
|
|
123
124
|
- `zig_zon.BareEnum`: Serialized as bare enums `.identifier`.
|
|
124
125
|
- `zig_zon.QuotedEnum`: Serialized as quoted enums `.@"identifier"`.
|
|
125
126
|
- `zig_zon.Enum`: Serialized as enum literals (bare or quoted as necessary).
|
|
126
|
-
- `int`, `zig_zon.Integer`, `zig_zon.Hex`: Formatted according to `integer_mode
|
|
127
|
+
- `int`, `zig_zon.Integer`, `zig_zon.Hex`: Formatted according to `integer_mode` (supports arbitrary precision).
|
|
127
128
|
- `float`, `zig_zon.Float`: Serialized as float literals.
|
|
128
129
|
- `bool`: Serialized as `true` or `false`.
|
|
129
130
|
- `None`: Serialized as `null`.
|
|
@@ -134,8 +135,8 @@ The parser returns custom classes for each Zig type that wrap and subclass stand
|
|
|
134
135
|
|
|
135
136
|
- `structs` -> `zig_zon.Struct` (subclasses `dict`)
|
|
136
137
|
- `tuples` -> `zig_zon.Tuple` (subclasses `list`)
|
|
137
|
-
- `integer literals` -> `zig_zon.Integer` (subclasses `int
|
|
138
|
-
- `hex literals` -> `zig_zon.Hex` (wraps / subclasses `int
|
|
138
|
+
- `integer literals` -> `zig_zon.Integer` (subclasses `int`, arbitrary precision)
|
|
139
|
+
- `hex literals` -> `zig_zon.Hex` (wraps / subclasses `int`, arbitrary precision)
|
|
139
140
|
- `float literals` -> `zig_zon.Float` (subclasses `float`)
|
|
140
141
|
- `booleans` -> `bool` (Python built-in `bool` is final and cannot be subclassed)
|
|
141
142
|
- `null` -> `None` (Python `NoneType` is final and cannot be subclassed)
|
|
@@ -146,10 +147,6 @@ The parser returns custom classes for each Zig type that wrap and subclass stand
|
|
|
146
147
|
|
|
147
148
|
Because the custom classes wrap and subclass their respective Python base types, both `isinstance(val, BaseType)` and `isinstance(val, zig_zon.CustomClass)` evaluate to `True`.
|
|
148
149
|
|
|
149
|
-
## Not supported values
|
|
150
|
-
|
|
151
|
-
- `bigint`
|
|
152
|
-
|
|
153
150
|
## How it works
|
|
154
151
|
|
|
155
152
|
The `zig build` commands produces a python source distribution archive ready
|
|
@@ -6,7 +6,11 @@ const zon = @import("build.zig.zon");
|
|
|
6
6
|
pub fn build(b: *Build) void {
|
|
7
7
|
const target = b.standardTargetOptions(.{});
|
|
8
8
|
const optimize = b.standardOptimizeOption(.{});
|
|
9
|
-
const limited_api_opt = b.option(
|
|
9
|
+
const limited_api_opt = b.option(
|
|
10
|
+
[]const u8,
|
|
11
|
+
"py-limited-api",
|
|
12
|
+
"the python limited api to target. defaults to python3.8. set to empty string to disable",
|
|
13
|
+
) orelse "cp38";
|
|
10
14
|
const limited_api = if (limited_api_opt.len == 0) null else limited_api_opt;
|
|
11
15
|
|
|
12
16
|
// this target and section of our build is used at pip install time
|
|
@@ -126,11 +130,11 @@ pub fn build(b: *Build) void {
|
|
|
126
130
|
const check_fmt = opt_check_fmt or opt_fmt_check;
|
|
127
131
|
const fmt_step = b.step("fmt", "Run zig fmt");
|
|
128
132
|
const fmt = b.addFmt(.{
|
|
129
|
-
.paths = &.{
|
|
133
|
+
.paths = b.pathList(&.{
|
|
130
134
|
"src",
|
|
131
135
|
"build.zig",
|
|
132
136
|
"build.zig.zon",
|
|
133
|
-
},
|
|
137
|
+
}),
|
|
134
138
|
.check = check_fmt,
|
|
135
139
|
});
|
|
136
140
|
fmt_step.dependOn(&fmt.step);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
.{
|
|
2
2
|
.name = .python_zig_zon,
|
|
3
3
|
.fingerprint = 0x3d332656a3644fc9,
|
|
4
|
-
.version = "0.
|
|
5
|
-
.minimum_zig_version = "0.
|
|
4
|
+
.version = "0.4.0",
|
|
5
|
+
.minimum_zig_version = "0.17.1",
|
|
6
6
|
.dependencies = .{
|
|
7
7
|
.zig_python_sdist = .{
|
|
8
|
-
.url = "git+https://codeberg.org/dasimmet/zig-python-sdist.git?ref=0.0
|
|
9
|
-
.hash = "zig_python_sdist-0.0
|
|
8
|
+
.url = "git+https://codeberg.org/dasimmet/zig-python-sdist.git?ref=0.1.0#61ba060941eed25d48e3fbd7bc5347b036049e6b",
|
|
9
|
+
.hash = "zig_python_sdist-0.1.0-wjgdOtSFAQDLy6b2unaGk3F6S9vT8Nu-_3PeLMPnI-cU",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
.paths = .{
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
.{ .key = "Requires-Python", .value = ">=3.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
|
+
.{ .key = "Project-URL", .value = "Source, https://codeberg.org/dasimmet/python-zig-zon" },
|
|
10
11
|
.{ .key = "Classifier", .value = "Development Status :: 4 - Beta" },
|
|
11
12
|
.{ .key = "Classifier", .value = "Programming Language :: Python :: 3" },
|
|
12
13
|
.{ .key = "Classifier", .value = "Programming Language :: Zig" },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"zig_zon","version":{"major":0,"minor":4,"patch":0},"zig_version":{"major":0,"minor":17,"patch":1},"build":{"args":["--fork=zig-pkg/zig_python_sdist-0.1.0","bdist-wheel","-Doptimize=small"],"requires":[],"packages":[],"copy_patterns":[{"pattern":"zig-out/lib/*","package_dir":false}]},"py_limited_api":"cp38","has_ext_modules":true}
|
|
@@ -282,7 +282,7 @@ pub fn parse(self: [*]PyObject, args: [*]PyObject, kwargs: ?[*]PyObject) callcon
|
|
|
282
282
|
defer arena_instance.deinit();
|
|
283
283
|
const arena = arena_instance.allocator();
|
|
284
284
|
|
|
285
|
-
const ast = Ast.parse(arena, zon_slice, .zon) catch |err| {
|
|
285
|
+
const ast = Ast.parse(arena, zon_slice, .{ .mode = .zon }) catch |err| {
|
|
286
286
|
const errstr = std.fmt.allocPrintSentinel(
|
|
287
287
|
arena,
|
|
288
288
|
"zig-zon ast error: {s}",
|
|
@@ -311,7 +311,7 @@ pub fn parse(self: [*]PyObject, args: [*]PyObject, kwargs: ?[*]PyObject) callcon
|
|
|
311
311
|
|
|
312
312
|
const main_node_index = ast.nodeData(.root).node;
|
|
313
313
|
|
|
314
|
-
return parseZonAst(arena, ast, main_node_index, options) catch |err| {
|
|
314
|
+
return parseZonAst(arena, &ast, main_node_index, options) catch |err| {
|
|
315
315
|
if (c.PyErr_Occurred() == null) {
|
|
316
316
|
const errstr = std.fmt.allocPrintSentinel(
|
|
317
317
|
arena,
|
|
@@ -339,7 +339,7 @@ const ZonError = error{
|
|
|
339
339
|
WriteFailed,
|
|
340
340
|
} || IdentifierError || NumberLiteralError;
|
|
341
341
|
|
|
342
|
-
fn parseZonAst(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: ParseOptions) ZonError!*PyObject {
|
|
342
|
+
fn parseZonAst(arena: Allocator, tree: *const Ast, node: Ast.Node.Index, options: ParseOptions) ZonError!*PyObject {
|
|
343
343
|
const node_tag = tree.nodeTag(node);
|
|
344
344
|
switch (node_tag) {
|
|
345
345
|
.struct_init_comma,
|
|
@@ -445,34 +445,44 @@ fn parseZonAst(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: Parse
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
const NumberLiteralError = error{
|
|
448
|
-
BigIntNotImplemented,
|
|
449
448
|
InvalidCharacter,
|
|
450
449
|
HexFloatNotImplemented,
|
|
451
450
|
NumberLiteralFail,
|
|
451
|
+
OutOfMemory,
|
|
452
452
|
};
|
|
453
453
|
|
|
454
|
-
fn parseNumberLiteral(arena: Allocator, tree: Ast, node: Ast.Node.Index, negated: bool) NumberLiteralError!*PyObject {
|
|
455
|
-
_ = arena;
|
|
454
|
+
fn parseNumberLiteral(arena: Allocator, tree: *const Ast, node: Ast.Node.Index, negated: bool) NumberLiteralError!*PyObject {
|
|
456
455
|
const num_token = tree.lastToken(node);
|
|
457
456
|
const token_bytes = tree.tokenSlice(num_token);
|
|
457
|
+
const is_hex = std.mem.startsWith(u8, token_bytes, "0x") or std.mem.startsWith(u8, token_bytes, "0X");
|
|
458
|
+
const cls = if (is_hex) Hex_Type else Integer_Type;
|
|
458
459
|
const parsed = std.zig.parseNumberLiteral(token_bytes);
|
|
459
460
|
switch (parsed) {
|
|
460
461
|
.int => |n| {
|
|
462
|
+
if (negated and n > 9223372036854775808) {
|
|
463
|
+
const s = try std.fmt.allocPrintSentinel(arena, "-{s}", .{token_bytes}, 0);
|
|
464
|
+
const base_int = c.PyLong_FromString(s.ptr, null, 0) orelse return error.NumberLiteralFail;
|
|
465
|
+
defer c.Py_DecRef(base_int);
|
|
466
|
+
return PyObject_CallOneArg(cls, base_int) orelse error.NumberLiteralFail;
|
|
467
|
+
}
|
|
461
468
|
const factor: i64 = if (negated) -1 else 1;
|
|
462
469
|
const neglim = 9223372036854775807; // 2**63 - 1
|
|
463
470
|
const base_int: *PyObject = if (n <= neglim)
|
|
464
471
|
c.PyLong_FromSsize_t(factor * @as(i64, @intCast(n))) orelse return error.NumberLiteralFail
|
|
465
|
-
else
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
472
|
+
else if (negated and n == 9223372036854775808)
|
|
473
|
+
c.PyLong_FromLongLong(std.math.minInt(i64)) orelse return error.NumberLiteralFail
|
|
474
|
+
else
|
|
475
|
+
c.PyLong_FromSize_t(n) orelse return error.NumberLiteralFail;
|
|
469
476
|
defer c.Py_DecRef(base_int);
|
|
470
477
|
|
|
471
|
-
const is_hex = std.mem.startsWith(u8, token_bytes, "0x") or std.mem.startsWith(u8, token_bytes, "0X");
|
|
472
|
-
const cls = if (is_hex) Hex_Type else Integer_Type;
|
|
473
478
|
return PyObject_CallOneArg(cls, base_int) orelse error.NumberLiteralFail;
|
|
474
479
|
},
|
|
475
|
-
.big_int =>
|
|
480
|
+
.big_int => {
|
|
481
|
+
const s = try std.fmt.allocPrintSentinel(arena, "{s}{s}", .{ if (negated) "-" else "", token_bytes }, 0);
|
|
482
|
+
const base_int = c.PyLong_FromString(s.ptr, null, 0) orelse return error.NumberLiteralFail;
|
|
483
|
+
defer c.Py_DecRef(base_int);
|
|
484
|
+
return PyObject_CallOneArg(cls, base_int) orelse error.NumberLiteralFail;
|
|
485
|
+
},
|
|
476
486
|
.float => |n| {
|
|
477
487
|
const float_payload = switch (n) {
|
|
478
488
|
.decimal => token_bytes,
|
|
@@ -492,7 +502,7 @@ fn parseNumberLiteral(arena: Allocator, tree: Ast, node: Ast.Node.Index, negated
|
|
|
492
502
|
}
|
|
493
503
|
}
|
|
494
504
|
|
|
495
|
-
fn parseZonStruct(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: ParseOptions) ZonError!*PyObject {
|
|
505
|
+
fn parseZonStruct(arena: Allocator, tree: *const Ast, node: Ast.Node.Index, options: ParseOptions) ZonError!*PyObject {
|
|
496
506
|
var buf: [2]Ast.Node.Index = undefined;
|
|
497
507
|
const struct_init = tree.fullStructInit(&buf, node) orelse return error.StructExpected;
|
|
498
508
|
|
|
@@ -510,7 +520,7 @@ fn parseZonStruct(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: Pa
|
|
|
510
520
|
return ret;
|
|
511
521
|
}
|
|
512
522
|
|
|
513
|
-
fn parseZonArray(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: ParseOptions) !*PyObject {
|
|
523
|
+
fn parseZonArray(arena: Allocator, tree: *const Ast, node: Ast.Node.Index, options: ParseOptions) !*PyObject {
|
|
514
524
|
// ret.* = c.Py_BuildValue("l", @as(u64, 1));
|
|
515
525
|
var buf: [2]Ast.Node.Index = undefined;
|
|
516
526
|
const array_init = tree.fullArrayInit(&buf, node) orelse {
|
|
@@ -532,7 +542,7 @@ fn parseZonArray(arena: Allocator, tree: Ast, node: Ast.Node.Index, options: Par
|
|
|
532
542
|
|
|
533
543
|
const IdentifierError = error{OutOfMemory} || StringLiteralError;
|
|
534
544
|
|
|
535
|
-
fn identifierTokenString(arena: Allocator, ast: Ast, token: Ast.TokenIndex) IdentifierError![:0]const u8 {
|
|
545
|
+
fn identifierTokenString(arena: Allocator, ast: *const Ast, token: Ast.TokenIndex) IdentifierError![:0]const u8 {
|
|
536
546
|
assert(ast.tokenTag(token) == .identifier);
|
|
537
547
|
const ident_name = ast.tokenSlice(token);
|
|
538
548
|
if (!std.mem.startsWith(u8, ident_name, "@")) {
|
|
@@ -587,7 +597,7 @@ const StringifyOptions = struct {
|
|
|
587
597
|
whitespace: bool = true,
|
|
588
598
|
|
|
589
599
|
fn initEncoding(comptime default: []const u8) [64:0]u8 {
|
|
590
|
-
var buf: [64:0]u8 =
|
|
600
|
+
var buf: [64:0]u8 = @splat(0);
|
|
591
601
|
@memcpy(buf[0..default.len], default);
|
|
592
602
|
return buf;
|
|
593
603
|
}
|
|
@@ -712,7 +722,7 @@ fn serializeObject(
|
|
|
712
722
|
if (is_utf8) {
|
|
713
723
|
const s = PyStr.init(obj) orelse return error.PyErr;
|
|
714
724
|
defer s.deinit();
|
|
715
|
-
try serializer.string(s.slice);
|
|
725
|
+
try serializer.string(s.slice, .{});
|
|
716
726
|
} else {
|
|
717
727
|
const encoded = c.PyUnicode_AsEncodedString(obj, &options.encoding, "strict") orelse return error.PyErr;
|
|
718
728
|
defer c.Py_DecRef(encoded);
|
|
@@ -720,7 +730,7 @@ fn serializeObject(
|
|
|
720
730
|
defer c.Py_DecRef(decoded);
|
|
721
731
|
const s = PyStr.init(decoded) orelse return error.PyErr;
|
|
722
732
|
defer s.deinit();
|
|
723
|
-
try serializer.string(s.slice);
|
|
733
|
+
try serializer.string(s.slice, .{});
|
|
724
734
|
}
|
|
725
735
|
return;
|
|
726
736
|
}
|
|
@@ -730,7 +740,7 @@ fn serializeObject(
|
|
|
730
740
|
var ptr: [*c]u8 = undefined;
|
|
731
741
|
if (c.PyBytes_AsStringAndSize(obj, &ptr, &len) < 0) return error.PyErr;
|
|
732
742
|
const s: []const u8 = @as([*]const u8, @ptrCast(ptr))[0..@intCast(len)];
|
|
733
|
-
try serializer.string(s);
|
|
743
|
+
try serializer.string(s, .{});
|
|
734
744
|
return;
|
|
735
745
|
}
|
|
736
746
|
|
|
@@ -739,7 +749,7 @@ fn serializeObject(
|
|
|
739
749
|
defer c.Py_DecRef(text);
|
|
740
750
|
const s = PyStr.init(text) orelse return error.PyErr;
|
|
741
751
|
defer s.deinit();
|
|
742
|
-
try serializer.string(s.slice);
|
|
752
|
+
try serializer.string(s.slice, .{});
|
|
743
753
|
return;
|
|
744
754
|
}
|
|
745
755
|
|
|
@@ -10,7 +10,7 @@ A complete runnable example is available in the [`example/`](example/) directory
|
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
Add `zig-python-sdist` to your project's `build.zig.zon` (requires Zig >= 0.
|
|
13
|
+
Add `zig-python-sdist` to your project's `build.zig.zon` (requires Zig >= 0.17.1):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
zig fetch --save git+https://codeberg.org/dasimmet/zig-python-sdist
|
|
@@ -273,3 +273,5 @@ zig build test-pip-install
|
|
|
273
273
|
- [Deinventing the Wheel - Loris Cro](https://www.youtube.com/watch?v=HPmefnqirHk)
|
|
274
274
|
- [Python C API - Limited API](https://docs.python.org/3/c-api/stable.html)
|
|
275
275
|
- [PEP 384 – Defining a Stable ABI](https://peps.python.org/pep-0384/)
|
|
276
|
+
- [Zig Zon Parser library](https://codeberg.org/dasimmet/python-zig-zon)
|
|
277
|
+
- [Minisign Python bindings](https://codeberg.org/dasimmet/minizign)
|
|
@@ -123,7 +123,6 @@ pub fn build(b: *Build) void {
|
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
125
|
.install_requires = &.{"ruamel.yaml.clibz"},
|
|
126
|
-
.zig_version = std.SemanticVersion.parse("0.16.0") catch unreachable,
|
|
127
126
|
.compression = .best,
|
|
128
127
|
});
|
|
129
128
|
const example_cpython_install = example_cpython_sdist.install();
|
|
@@ -210,7 +209,6 @@ pub fn build(b: *Build) void {
|
|
|
210
209
|
.directories = &.{
|
|
211
210
|
.{ .src = b.path("src/build"), .dest = "src/build" },
|
|
212
211
|
},
|
|
213
|
-
.zig_version = std.SemanticVersion.parse("0.16.0") catch unreachable,
|
|
214
212
|
.compression = .best,
|
|
215
213
|
});
|
|
216
214
|
const example_ctypes_install = example_ctypes_sdist.install();
|
|
@@ -11,7 +11,7 @@ pub const CPython = @This();
|
|
|
11
11
|
|
|
12
12
|
pub const LinkOptions = struct {
|
|
13
13
|
target: Build.ResolvedTarget,
|
|
14
|
-
optimize: std.
|
|
14
|
+
optimize: std.lang.Optimize,
|
|
15
15
|
version: ?[]const u8 = null,
|
|
16
16
|
header_file: ?LazyPath = null,
|
|
17
17
|
// pass in the python executable for finding headers. use "python" from PATH if omitted.
|
|
@@ -76,9 +76,7 @@ pub fn wrapMain(wrap_main: anytype, comptime options: WrapMainOptions) fn ([*]c.
|
|
|
76
76
|
defer arena_impl.deinit();
|
|
77
77
|
const arena = arena_impl.allocator();
|
|
78
78
|
|
|
79
|
-
var gpa_impl: std.heap.
|
|
80
|
-
.backing_allocator = py_allocator,
|
|
81
|
-
};
|
|
79
|
+
var gpa_impl: std.heap.SafeAllocator = .init(py_allocator, .{});
|
|
82
80
|
defer _ = gpa_impl.deinit();
|
|
83
81
|
const gpa = gpa_impl.allocator();
|
|
84
82
|
|
|
@@ -322,7 +320,7 @@ pub fn getZigBuitin() *c.PyObject {
|
|
|
322
320
|
assert(0 <= c.PyDict_SetItemString(cpu_dict, "features", features));
|
|
323
321
|
|
|
324
322
|
inline for (comptime builtin.target.cpu.arch.allFeaturesList()) |feature| {
|
|
325
|
-
if (builtin.target.cpu.has(builtin.target.cpu.arch.family(), @
|
|
323
|
+
if (builtin.target.cpu.has(builtin.target.cpu.arch.family(), @fromBackingInt(@intCast(feature.index)))) {
|
|
326
324
|
const feature_str = c.Py_BuildValue("s#", feature.name.ptr, feature.name.len);
|
|
327
325
|
defer c.Py_DecRef(feature_str);
|
|
328
326
|
assert(c.PyList_Append(features, feature_str) >= 0);
|
zig-zon-0.3.2/setup.zig.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"zig_zon","version":{"major":0,"minor":3,"patch":2},"zig_version":{"major":0,"minor":16,"patch":0},"build":{"args":["--fork=zig-pkg/zig_python_sdist-0.0.8","bdist-wheel","-Doptimize=ReleaseSmall"],"requires":[],"packages":[],"copy_patterns":[{"pattern":"zig-out/lib/*","package_dir":false}]},"py_limited_api":"cp38","has_ext_modules":true}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|