johnnybt-dsl 0.1.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.
- johnnybt_dsl-0.1.0/.github/workflows/release.yml +158 -0
- johnnybt_dsl-0.1.0/.gitignore +4 -0
- johnnybt_dsl-0.1.0/Cargo.lock +155 -0
- johnnybt_dsl-0.1.0/Cargo.toml +20 -0
- johnnybt_dsl-0.1.0/LICENSE +21 -0
- johnnybt_dsl-0.1.0/LICENSE-mruby +19 -0
- johnnybt_dsl-0.1.0/PKG-INFO +100 -0
- johnnybt_dsl-0.1.0/README.md +80 -0
- johnnybt_dsl-0.1.0/build.rs +305 -0
- johnnybt_dsl-0.1.0/build_config.rb +76 -0
- johnnybt_dsl-0.1.0/build_config.rb.lock +5 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-dsl/mrbgem.rake +6 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-dsl/mrblib/dsl.rb +322 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-dsl/test/dsl.rb +108 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-json/README.md +10 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-json/mrbgem.rake +5 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-json/mrblib/json.rb +24 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-json/src/json.c +358 -0
- johnnybt_dsl-0.1.0/mrbgems/mruby-json/test/json.rb +86 -0
- johnnybt_dsl-0.1.0/mrbgems/run_tests.rb +44 -0
- johnnybt_dsl-0.1.0/pyproject.toml +31 -0
- johnnybt_dsl-0.1.0/python/johnnybt_dsl/__init__.py +109 -0
- johnnybt_dsl-0.1.0/python/johnnybt_dsl/_lib.pyi +10 -0
- johnnybt_dsl-0.1.0/python/johnnybt_dsl/py.typed +0 -0
- johnnybt_dsl-0.1.0/src/engine.rs +310 -0
- johnnybt_dsl-0.1.0/src/lib.rs +101 -0
- johnnybt_dsl-0.1.0/src/shim.c +79 -0
- johnnybt_dsl-0.1.0/src/sys.rs +83 -0
- johnnybt_dsl-0.1.0/tests/dsl.rs +166 -0
- johnnybt_dsl-0.1.0/uv.lock +8 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Build the wheels people install, then publish them.
|
|
2
|
+
#
|
|
3
|
+
# Six cells: linux / macOS / Windows × x86_64 / arm64. This crate compiles C
|
|
4
|
+
# — mruby's whole source, plus our macro trampolines — so every cell builds
|
|
5
|
+
# on a machine of its own architecture and nothing is cross-compiled. That is
|
|
6
|
+
# not fastidiousness: mruby's build runs `mrbc`, a tool it just built, to turn
|
|
7
|
+
# our gems' Ruby into C, and a cross-compiled `mrbc` does not run on the
|
|
8
|
+
# builder. Native means one build instead of two, on every platform.
|
|
9
|
+
#
|
|
10
|
+
# The extension is abi3 for Python 3.11, so one wheel per platform covers
|
|
11
|
+
# 3.11 through 3.14 — the matrix is about machines, not interpreters. What
|
|
12
|
+
# ships is one static archive inside the module: **installing needs neither
|
|
13
|
+
# Ruby nor a C compiler**, which is the whole point of publishing wheels.
|
|
14
|
+
#
|
|
15
|
+
# Publishing uses PyPI's trusted publishing (OIDC) — no token lives here.
|
|
16
|
+
name: release
|
|
17
|
+
|
|
18
|
+
on:
|
|
19
|
+
push:
|
|
20
|
+
tags: ["v*"]
|
|
21
|
+
workflow_dispatch:
|
|
22
|
+
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
wheels:
|
|
28
|
+
name: ${{ matrix.os }} ${{ matrix.arch }}
|
|
29
|
+
runs-on: ${{ matrix.runner }}
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
include:
|
|
34
|
+
# The manylinux images this action picks for aarch64 by default are
|
|
35
|
+
# *cross* images (x86_64 hosts carrying a cross gcc), which is the
|
|
36
|
+
# one thing mruby cannot use. Naming pypa's own native images
|
|
37
|
+
# instead keeps both linux cells native — and gives the wheels a
|
|
38
|
+
# real manylinux tag, which a build on the runner's own glibc
|
|
39
|
+
# would not have.
|
|
40
|
+
- os: linux
|
|
41
|
+
arch: x86_64
|
|
42
|
+
runner: ubuntu-24.04
|
|
43
|
+
target: x86_64
|
|
44
|
+
container: quay.io/pypa/manylinux_2_28_x86_64
|
|
45
|
+
- os: linux
|
|
46
|
+
arch: arm64
|
|
47
|
+
runner: ubuntu-24.04-arm
|
|
48
|
+
target: aarch64
|
|
49
|
+
container: quay.io/pypa/manylinux_2_28_aarch64
|
|
50
|
+
- { os: macos, arch: x86_64, runner: macos-15-intel, target: x86_64 }
|
|
51
|
+
- { os: macos, arch: arm64, runner: macos-latest, target: aarch64 }
|
|
52
|
+
- { os: windows, arch: x86_64, runner: windows-latest, target: x64 }
|
|
53
|
+
- { os: windows, arch: arm64, runner: windows-11-arm, target: aarch64 }
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v6
|
|
56
|
+
|
|
57
|
+
# mruby's build is driven by its own rake, so a Ruby has to be here.
|
|
58
|
+
# It is build-time only — nothing about it ends up in the wheel.
|
|
59
|
+
# 3.4 rather than 3.3 because that is the oldest one built for every
|
|
60
|
+
# runner here — Windows on arm has 3.4 upwards and nothing before it.
|
|
61
|
+
- uses: ruby/setup-ruby@v1
|
|
62
|
+
if: matrix.os != 'linux'
|
|
63
|
+
with:
|
|
64
|
+
ruby-version: "3.4"
|
|
65
|
+
|
|
66
|
+
- uses: PyO3/maturin-action@v1
|
|
67
|
+
with:
|
|
68
|
+
target: ${{ matrix.target }}
|
|
69
|
+
container: ${{ matrix.container || 'off' }}
|
|
70
|
+
args: --release --out dist
|
|
71
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
72
|
+
# Inside the container: a Ruby new enough to run mruby's rake, and
|
|
73
|
+
# rake itself — mruby's bundled `minirake` is now two lines that
|
|
74
|
+
# exec the real one. AlmaLinux's default stream is Ruby 2.5, old
|
|
75
|
+
# enough that mruby's own build scripts use syntax it lacks.
|
|
76
|
+
before-script-linux: |
|
|
77
|
+
dnf module -y reset ruby || true
|
|
78
|
+
dnf module -y enable ruby:3.3 || dnf module -y enable ruby:3.1 || true
|
|
79
|
+
dnf install -y ruby rubygem-rake git || yum install -y ruby rubygem-rake git
|
|
80
|
+
command -v rake || gem install --no-document rake
|
|
81
|
+
ruby --version && rake --version
|
|
82
|
+
|
|
83
|
+
- uses: actions/upload-artifact@v6
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
|
|
86
|
+
path: dist/*.whl
|
|
87
|
+
if-no-files-found: error
|
|
88
|
+
|
|
89
|
+
# One source distribution as well: someone on a platform the matrix does not
|
|
90
|
+
# cover, or who wants to read what they are installing, can build it. maturin
|
|
91
|
+
# carries the account walk into the tarball and rewrites the path, so a
|
|
92
|
+
# source build needs no sibling checkout — verified by building it in
|
|
93
|
+
# isolation.
|
|
94
|
+
sdist:
|
|
95
|
+
name: sdist
|
|
96
|
+
runs-on: ubuntu-24.04
|
|
97
|
+
steps:
|
|
98
|
+
- uses: actions/checkout@v6
|
|
99
|
+
|
|
100
|
+
- uses: PyO3/maturin-action@v1
|
|
101
|
+
with:
|
|
102
|
+
command: sdist
|
|
103
|
+
args: --out dist
|
|
104
|
+
|
|
105
|
+
- uses: actions/upload-artifact@v6
|
|
106
|
+
with:
|
|
107
|
+
name: wheels-sdist
|
|
108
|
+
path: dist/*.tar.gz
|
|
109
|
+
if-no-files-found: error
|
|
110
|
+
|
|
111
|
+
smoke:
|
|
112
|
+
name: install a wheel and run some Ruby
|
|
113
|
+
needs: wheels
|
|
114
|
+
strategy:
|
|
115
|
+
fail-fast: false
|
|
116
|
+
matrix:
|
|
117
|
+
include:
|
|
118
|
+
- { runner: ubuntu-24.04, artifact: wheels-linux-x86_64 }
|
|
119
|
+
- { runner: macos-latest, artifact: wheels-macos-arm64 }
|
|
120
|
+
- { runner: windows-latest, artifact: wheels-windows-x86_64 }
|
|
121
|
+
runs-on: ${{ matrix.runner }}
|
|
122
|
+
steps:
|
|
123
|
+
- uses: actions/download-artifact@v7
|
|
124
|
+
with: { name: "${{ matrix.artifact }}", path: dist }
|
|
125
|
+
- uses: actions/setup-python@v6
|
|
126
|
+
with: { python-version: "3.13" }
|
|
127
|
+
- name: install
|
|
128
|
+
shell: bash
|
|
129
|
+
run: python -m pip install --find-links dist johnnybt-dsl
|
|
130
|
+
# Not just "does it import": the machine has to have the language in
|
|
131
|
+
# it. A wheel once shipped an mruby whose core had no `Regexp`, and
|
|
132
|
+
# importing it was perfectly happy — the words only failed later, in
|
|
133
|
+
# somebody's strategy file.
|
|
134
|
+
- name: run
|
|
135
|
+
shell: bash
|
|
136
|
+
run: |
|
|
137
|
+
python - <<'PY'
|
|
138
|
+
from johnnybt_dsl import run
|
|
139
|
+
source = "CHECK = [Regexp, Struct, Time, Math, Enumerable].map(&:to_s).join(' ')"
|
|
140
|
+
print(run([(source, "smoke.rb")], answer="CHECK"))
|
|
141
|
+
PY
|
|
142
|
+
|
|
143
|
+
publish:
|
|
144
|
+
name: publish to PyPI
|
|
145
|
+
needs: [wheels, sdist, smoke]
|
|
146
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
147
|
+
runs-on: ubuntu-24.04
|
|
148
|
+
environment: pypi
|
|
149
|
+
permissions:
|
|
150
|
+
id-token: write
|
|
151
|
+
steps:
|
|
152
|
+
- uses: actions/download-artifact@v7
|
|
153
|
+
with:
|
|
154
|
+
pattern: wheels-*
|
|
155
|
+
merge-multiple: true
|
|
156
|
+
path: dist
|
|
157
|
+
- run: ls -l dist
|
|
158
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "cc"
|
|
7
|
+
version = "1.4.5"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"find-msvc-tools",
|
|
12
|
+
"shlex",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[[package]]
|
|
16
|
+
name = "find-msvc-tools"
|
|
17
|
+
version = "0.1.12"
|
|
18
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
19
|
+
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
|
|
20
|
+
|
|
21
|
+
[[package]]
|
|
22
|
+
name = "heck"
|
|
23
|
+
version = "0.5.0"
|
|
24
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
25
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
26
|
+
|
|
27
|
+
[[package]]
|
|
28
|
+
name = "johnnybt_dsl"
|
|
29
|
+
version = "0.1.0"
|
|
30
|
+
dependencies = [
|
|
31
|
+
"cc",
|
|
32
|
+
"pyo3",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "libc"
|
|
37
|
+
version = "0.2.189"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "once_cell"
|
|
43
|
+
version = "1.21.4"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "portable-atomic"
|
|
49
|
+
version = "1.15.0"
|
|
50
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
51
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
52
|
+
|
|
53
|
+
[[package]]
|
|
54
|
+
name = "proc-macro2"
|
|
55
|
+
version = "1.0.107"
|
|
56
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
58
|
+
dependencies = [
|
|
59
|
+
"unicode-ident",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[[package]]
|
|
63
|
+
name = "pyo3"
|
|
64
|
+
version = "0.29.2"
|
|
65
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
66
|
+
checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
|
|
67
|
+
dependencies = [
|
|
68
|
+
"libc",
|
|
69
|
+
"once_cell",
|
|
70
|
+
"portable-atomic",
|
|
71
|
+
"pyo3-build-config",
|
|
72
|
+
"pyo3-ffi",
|
|
73
|
+
"pyo3-macros",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "pyo3-build-config"
|
|
78
|
+
version = "0.29.2"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "f41027e41b4bd03f6e60f9f417fe24a6341a6bb744edd62b6f709f2a52ea30e9"
|
|
81
|
+
dependencies = [
|
|
82
|
+
"target-lexicon",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "pyo3-ffi"
|
|
87
|
+
version = "0.29.2"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "e591a95526fead067432c3b3a33fc74770b87b1e04e73671090d9c2055a2b327"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"libc",
|
|
92
|
+
"pyo3-build-config",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "pyo3-macros"
|
|
97
|
+
version = "0.29.2"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "73225868fc1cd84eef2c3c230ddb91273bf1de46aeb8a4248da76d32a0924a1c"
|
|
100
|
+
dependencies = [
|
|
101
|
+
"proc-macro2",
|
|
102
|
+
"pyo3-macros-backend",
|
|
103
|
+
"quote",
|
|
104
|
+
"syn",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[[package]]
|
|
108
|
+
name = "pyo3-macros-backend"
|
|
109
|
+
version = "0.29.2"
|
|
110
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
+
checksum = "571575aa3749fa6216757dd47d2a3e7ef360f329a40f0666a9fbd14889024952"
|
|
112
|
+
dependencies = [
|
|
113
|
+
"heck",
|
|
114
|
+
"proc-macro2",
|
|
115
|
+
"quote",
|
|
116
|
+
"syn",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[[package]]
|
|
120
|
+
name = "quote"
|
|
121
|
+
version = "1.0.47"
|
|
122
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
123
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
124
|
+
dependencies = [
|
|
125
|
+
"proc-macro2",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "shlex"
|
|
130
|
+
version = "2.0.1"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
133
|
+
|
|
134
|
+
[[package]]
|
|
135
|
+
name = "syn"
|
|
136
|
+
version = "2.0.119"
|
|
137
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
138
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
139
|
+
dependencies = [
|
|
140
|
+
"proc-macro2",
|
|
141
|
+
"quote",
|
|
142
|
+
"unicode-ident",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
[[package]]
|
|
146
|
+
name = "target-lexicon"
|
|
147
|
+
version = "0.13.5"
|
|
148
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
150
|
+
|
|
151
|
+
[[package]]
|
|
152
|
+
name = "unicode-ident"
|
|
153
|
+
version = "1.0.24"
|
|
154
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
155
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "johnnybt_dsl"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "The DSL engine: mruby embedded in Rust, a strategy in, one JSON IR out."
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
[lib]
|
|
9
|
+
name = "johnnybt_dsl"
|
|
10
|
+
crate-type = ["cdylib", "rlib"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
pyo3 = { version = "0.29", features = ["abi3-py311"] }
|
|
14
|
+
|
|
15
|
+
[build-dependencies]
|
|
16
|
+
cc = "1"
|
|
17
|
+
|
|
18
|
+
[profile.release]
|
|
19
|
+
lto = true
|
|
20
|
+
codegen-units = 1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MJ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2010- mruby developers
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
+
copy of this software and associated documentation files (the "Software"),
|
|
5
|
+
to deal in the Software without restriction, including without limitation
|
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
19
|
+
DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: johnnybt-dsl
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Ruby
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
8
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE-mruby
|
|
11
|
+
Summary: A strategy DSL with a whole language behind it: mruby in Rust, JSON IR out.
|
|
12
|
+
Keywords: dsl,mruby,ruby,embedded,rust,ir
|
|
13
|
+
Author: MJ
|
|
14
|
+
License-Expression: MIT
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
17
|
+
Project-URL: Homepage, https://github.com/quant-on-quest/johnnybt-dsl
|
|
18
|
+
Project-URL: Repository, https://github.com/quant-on-quest/johnnybt-dsl
|
|
19
|
+
|
|
20
|
+
# johnnybt_dsl
|
|
21
|
+
|
|
22
|
+
一台装好的 **mruby 虚拟机**。跑几段 Ruby,取回它产出的那个字符串 —— 就这些。
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from johnnybt_dsl import compile, run
|
|
26
|
+
|
|
27
|
+
words = compile(open("dsl.rb").read(), "dsl.rb") # 一个进程编一次
|
|
28
|
+
ir = run([(words, "dsl.rb"), (source, "策略.rb")], answer="MyDSL.result")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**词是你自己的。** 这个包不知道什么是策略、什么是因子,也不规定 IR 长什么样:
|
|
32
|
+
那都是拿它写 DSL 的项目说了算。写死一套词就成了只服务一个项目的库。
|
|
33
|
+
|
|
34
|
+
**装上就能用**:wheel 里 mruby 已经编好了,用的人**不需要 GCC,也不需要 Ruby**。
|
|
35
|
+
那两样只有我们构建 wheel 时才要。
|
|
36
|
+
|
|
37
|
+
## 安装
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install johnnybt-dsl
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
预编译轮子,一个平台一个,`abi3` 绑 Python 3.11、覆盖 3.11–3.14:
|
|
44
|
+
|
|
45
|
+
| | x86_64 | arm64 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| Linux | manylinux_2_28(glibc 2.28 及以上) | manylinux_2_28(glibc 2.28 及以上) |
|
|
48
|
+
| macOS | 10.12 及以上 | 11.0 及以上 |
|
|
49
|
+
| Windows | 有 | 有 |
|
|
50
|
+
|
|
51
|
+
linux 的门槛比同系的两个 polars 插件(2.17)高一档,是因为这个包要编 C:
|
|
52
|
+
mruby 的构建会跑它刚编出来的 `mrbc`,所以每一格都得在自己的架构上原生构建,
|
|
53
|
+
而 pypa 提供原生镜像的最老的一档是 glibc 2.28。
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
| | |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `compile(source, name) -> bytes` | 编成字节码。字节码和解释器无关,编一次到处 load |
|
|
60
|
+
| `run(chunks, answer, context) -> str` | 按顺序跑几段(源码或字节码),再跑 `answer`,返回它的字符串。`context` 进全局变量 `$johnny_context`(惯例是 JSON,基类懒解析成 `JohnnyBtDSL.context`) |
|
|
61
|
+
| `run_file(path, before, answer)` | 同上,最后一段读自文件 |
|
|
62
|
+
|
|
63
|
+
一次 `run` 一个解释器:一份文件定义的东西不会漏进下一份。几段之间共用一个
|
|
64
|
+
编译上下文,所以局部变量跨得过去 —— 它们像一段程序,不像几份互不相干的文件。
|
|
65
|
+
|
|
66
|
+
## 里面有什么
|
|
67
|
+
|
|
68
|
+
| 件 | 做什么 |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `build.rs` | 取 mruby(钉住某个 commit)、按 `build_config.rb` 编、链接 `libmruby.a` |
|
|
71
|
+
| `src/sys.rs` | mruby 的 C API,**手写**的 extern 声明。十来个函数,不用生成器 |
|
|
72
|
+
| `src/shim.c` | mruby 里是宏的那几个(`mrb_test` / `mrb->exc`)和编译入口的跳板 |
|
|
73
|
+
| `src/engine.rs` | 解释器的生命周期,以及「跑几段、取一个字符串」 |
|
|
74
|
+
| `mrbgems/mruby-json/` | 我们自己的 gem:`JSON.generate` / `#to_json` / `JSON.parse`,双向都在 C 里(解析错误带字节位) |
|
|
75
|
+
| `mrbgems/mruby-dsl/` | 我们自己的 gem:`JohnnyBtDSL::Base` —— DSL 的基类(注册、declare、逐语句 trouble、manifest/ir 信封、`JohnnyBtDSL.context`)。**词不在这里**,词归定义语言的项目 |
|
|
76
|
+
|
|
77
|
+
## 一处 mruby 的实情
|
|
78
|
+
|
|
79
|
+
mruby 的 Prism 编译器带**全局状态**(`mrc_init_presym` 写一个文件级的
|
|
80
|
+
`offset`),两个解释器同时编译会互相踩。所以 `run` / `compile` 用一把锁串
|
|
81
|
+
起来 —— 一次求值不到一毫秒,串行的代价远小于「错得莫名其妙」。
|
|
82
|
+
|
|
83
|
+
## 构建(只有我们要)
|
|
84
|
+
|
|
85
|
+
* Rust、C 编译器
|
|
86
|
+
* Ruby —— mruby 自己的 rake 要它(`brew install ruby`)。解析器是 Prism,**不要 bison**
|
|
87
|
+
|
|
88
|
+
构建走真 `rake -m`(并行):mruby 自带的 `minirake` 完全串行,316 个目标文件
|
|
89
|
+
一个一个编,32 核机器上要几分钟;`rake -m` 同一棵树 **4 秒**。没有 rake 时退回
|
|
90
|
+
minirake。`vendor/mruby` 不进 git,第一次 `cargo build` 自己取。
|
|
91
|
+
|
|
92
|
+
测试:`vendor/mruby/build/host/bin/mruby mrbgems/run_tests.rb`(gem 那侧)与
|
|
93
|
+
`cargo test`(引擎那侧)。
|
|
94
|
+
|
|
95
|
+
## 许可
|
|
96
|
+
|
|
97
|
+
本包 MIT(见 `LICENSE`)。wheel 里静态链接了 **mruby**(MIT,见 `LICENSE-mruby`,
|
|
98
|
+
版权归 mruby developers);两个 mrbgem(`mruby-json`、`mruby-dsl`)是本仓库自己写的,
|
|
99
|
+
同样 MIT。
|
|
100
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# johnnybt_dsl
|
|
2
|
+
|
|
3
|
+
一台装好的 **mruby 虚拟机**。跑几段 Ruby,取回它产出的那个字符串 —— 就这些。
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from johnnybt_dsl import compile, run
|
|
7
|
+
|
|
8
|
+
words = compile(open("dsl.rb").read(), "dsl.rb") # 一个进程编一次
|
|
9
|
+
ir = run([(words, "dsl.rb"), (source, "策略.rb")], answer="MyDSL.result")
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**词是你自己的。** 这个包不知道什么是策略、什么是因子,也不规定 IR 长什么样:
|
|
13
|
+
那都是拿它写 DSL 的项目说了算。写死一套词就成了只服务一个项目的库。
|
|
14
|
+
|
|
15
|
+
**装上就能用**:wheel 里 mruby 已经编好了,用的人**不需要 GCC,也不需要 Ruby**。
|
|
16
|
+
那两样只有我们构建 wheel 时才要。
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pip install johnnybt-dsl
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
预编译轮子,一个平台一个,`abi3` 绑 Python 3.11、覆盖 3.11–3.14:
|
|
25
|
+
|
|
26
|
+
| | x86_64 | arm64 |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| Linux | manylinux_2_28(glibc 2.28 及以上) | manylinux_2_28(glibc 2.28 及以上) |
|
|
29
|
+
| macOS | 10.12 及以上 | 11.0 及以上 |
|
|
30
|
+
| Windows | 有 | 有 |
|
|
31
|
+
|
|
32
|
+
linux 的门槛比同系的两个 polars 插件(2.17)高一档,是因为这个包要编 C:
|
|
33
|
+
mruby 的构建会跑它刚编出来的 `mrbc`,所以每一格都得在自己的架构上原生构建,
|
|
34
|
+
而 pypa 提供原生镜像的最老的一档是 glibc 2.28。
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
| | |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `compile(source, name) -> bytes` | 编成字节码。字节码和解释器无关,编一次到处 load |
|
|
41
|
+
| `run(chunks, answer, context) -> str` | 按顺序跑几段(源码或字节码),再跑 `answer`,返回它的字符串。`context` 进全局变量 `$johnny_context`(惯例是 JSON,基类懒解析成 `JohnnyBtDSL.context`) |
|
|
42
|
+
| `run_file(path, before, answer)` | 同上,最后一段读自文件 |
|
|
43
|
+
|
|
44
|
+
一次 `run` 一个解释器:一份文件定义的东西不会漏进下一份。几段之间共用一个
|
|
45
|
+
编译上下文,所以局部变量跨得过去 —— 它们像一段程序,不像几份互不相干的文件。
|
|
46
|
+
|
|
47
|
+
## 里面有什么
|
|
48
|
+
|
|
49
|
+
| 件 | 做什么 |
|
|
50
|
+
|---|---|
|
|
51
|
+
| `build.rs` | 取 mruby(钉住某个 commit)、按 `build_config.rb` 编、链接 `libmruby.a` |
|
|
52
|
+
| `src/sys.rs` | mruby 的 C API,**手写**的 extern 声明。十来个函数,不用生成器 |
|
|
53
|
+
| `src/shim.c` | mruby 里是宏的那几个(`mrb_test` / `mrb->exc`)和编译入口的跳板 |
|
|
54
|
+
| `src/engine.rs` | 解释器的生命周期,以及「跑几段、取一个字符串」 |
|
|
55
|
+
| `mrbgems/mruby-json/` | 我们自己的 gem:`JSON.generate` / `#to_json` / `JSON.parse`,双向都在 C 里(解析错误带字节位) |
|
|
56
|
+
| `mrbgems/mruby-dsl/` | 我们自己的 gem:`JohnnyBtDSL::Base` —— DSL 的基类(注册、declare、逐语句 trouble、manifest/ir 信封、`JohnnyBtDSL.context`)。**词不在这里**,词归定义语言的项目 |
|
|
57
|
+
|
|
58
|
+
## 一处 mruby 的实情
|
|
59
|
+
|
|
60
|
+
mruby 的 Prism 编译器带**全局状态**(`mrc_init_presym` 写一个文件级的
|
|
61
|
+
`offset`),两个解释器同时编译会互相踩。所以 `run` / `compile` 用一把锁串
|
|
62
|
+
起来 —— 一次求值不到一毫秒,串行的代价远小于「错得莫名其妙」。
|
|
63
|
+
|
|
64
|
+
## 构建(只有我们要)
|
|
65
|
+
|
|
66
|
+
* Rust、C 编译器
|
|
67
|
+
* Ruby —— mruby 自己的 rake 要它(`brew install ruby`)。解析器是 Prism,**不要 bison**
|
|
68
|
+
|
|
69
|
+
构建走真 `rake -m`(并行):mruby 自带的 `minirake` 完全串行,316 个目标文件
|
|
70
|
+
一个一个编,32 核机器上要几分钟;`rake -m` 同一棵树 **4 秒**。没有 rake 时退回
|
|
71
|
+
minirake。`vendor/mruby` 不进 git,第一次 `cargo build` 自己取。
|
|
72
|
+
|
|
73
|
+
测试:`vendor/mruby/build/host/bin/mruby mrbgems/run_tests.rb`(gem 那侧)与
|
|
74
|
+
`cargo test`(引擎那侧)。
|
|
75
|
+
|
|
76
|
+
## 许可
|
|
77
|
+
|
|
78
|
+
本包 MIT(见 `LICENSE`)。wheel 里静态链接了 **mruby**(MIT,见 `LICENSE-mruby`,
|
|
79
|
+
版权归 mruby developers);两个 mrbgem(`mruby-json`、`mruby-dsl`)是本仓库自己写的,
|
|
80
|
+
同样 MIT。
|