nc-gcode-interpreter 0.0.10__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.
Files changed (60) hide show
  1. nc_gcode_interpreter-0.0.10/.github/workflows/build-and-release.yml +329 -0
  2. nc_gcode_interpreter-0.0.10/.gitignore +28 -0
  3. nc_gcode_interpreter-0.0.10/CONTRIBUTING.md +39 -0
  4. nc_gcode_interpreter-0.0.10/Cargo.lock +2153 -0
  5. nc_gcode_interpreter-0.0.10/Cargo.toml +19 -0
  6. nc_gcode_interpreter-0.0.10/Development.md +46 -0
  7. nc_gcode_interpreter-0.0.10/LICENSE +21 -0
  8. nc_gcode_interpreter-0.0.10/PKG-INFO +191 -0
  9. nc_gcode_interpreter-0.0.10/README.md +164 -0
  10. nc_gcode_interpreter-0.0.10/TODO.md +40 -0
  11. nc_gcode_interpreter-0.0.10/examples/arrays.csv +30 -0
  12. nc_gcode_interpreter-0.0.10/examples/arrays.mpf +15 -0
  13. nc_gcode_interpreter-0.0.10/examples/basic_math.csv +7 -0
  14. nc_gcode_interpreter-0.0.10/examples/basic_math.mpf +6 -0
  15. nc_gcode_interpreter-0.0.10/examples/custom_vars.csv +2 -0
  16. nc_gcode_interpreter-0.0.10/examples/custom_vars.mpf +1 -0
  17. nc_gcode_interpreter-0.0.10/examples/defaults.csv +3 -0
  18. nc_gcode_interpreter-0.0.10/examples/defaults.mpf +6 -0
  19. nc_gcode_interpreter-0.0.10/examples/for_loop.csv +18 -0
  20. nc_gcode_interpreter-0.0.10/examples/for_loop.mpf +5 -0
  21. nc_gcode_interpreter-0.0.10/examples/function_calls.csv +3 -0
  22. nc_gcode_interpreter-0.0.10/examples/function_calls.mpf +2 -0
  23. nc_gcode_interpreter-0.0.10/examples/if_statement.csv +2 -0
  24. nc_gcode_interpreter-0.0.10/examples/if_statement.mpf +13 -0
  25. nc_gcode_interpreter-0.0.10/examples/increment.csv +4 -0
  26. nc_gcode_interpreter-0.0.10/examples/increment.mpf +4 -0
  27. nc_gcode_interpreter-0.0.10/examples/loop.csv +321 -0
  28. nc_gcode_interpreter-0.0.10/examples/loop.mpf +48 -0
  29. nc_gcode_interpreter-0.0.10/examples/multiple_m_codes.csv +10 -0
  30. nc_gcode_interpreter-0.0.10/examples/multiple_m_codes.mpf +5 -0
  31. nc_gcode_interpreter-0.0.10/examples/simple.csv +6 -0
  32. nc_gcode_interpreter-0.0.10/examples/simple.mpf +6 -0
  33. nc_gcode_interpreter-0.0.10/examples/tool.csv +2 -0
  34. nc_gcode_interpreter-0.0.10/examples/tool.mpf +1 -0
  35. nc_gcode_interpreter-0.0.10/examples/trans.csv +4 -0
  36. nc_gcode_interpreter-0.0.10/examples/trans.mpf +7 -0
  37. nc_gcode_interpreter-0.0.10/examples/variables.csv +3 -0
  38. nc_gcode_interpreter-0.0.10/examples/variables.mpf +4 -0
  39. nc_gcode_interpreter-0.0.10/ggroups/generate_modal_ggroups.py +29 -0
  40. nc_gcode_interpreter-0.0.10/ggroups/generate_pest.py +57 -0
  41. nc_gcode_interpreter-0.0.10/ggroups/ggroups.pest +66 -0
  42. nc_gcode_interpreter-0.0.10/pyproject.toml +43 -0
  43. nc_gcode_interpreter-0.0.10/python/example/minimal.py +17 -0
  44. nc_gcode_interpreter-0.0.10/python/nc_gcode_interpreter/__init__.py +259 -0
  45. nc_gcode_interpreter-0.0.10/python/nc_gcode_interpreter/_internal.pyi +62 -0
  46. nc_gcode_interpreter-0.0.10/python/nc_gcode_interpreter/ggroups.json +2922 -0
  47. nc_gcode_interpreter-0.0.10/python/nc_gcode_interpreter/py.typed +0 -0
  48. nc_gcode_interpreter-0.0.10/python/tests/test_expected_output.py +68 -0
  49. nc_gcode_interpreter-0.0.10/python/tests/test_g_groups.py +23 -0
  50. nc_gcode_interpreter-0.0.10/rustfmt.toml +1 -0
  51. nc_gcode_interpreter-0.0.10/src/errors.rs +59 -0
  52. nc_gcode_interpreter-0.0.10/src/grammar.pest +193 -0
  53. nc_gcode_interpreter-0.0.10/src/interpret_rules.rs +686 -0
  54. nc_gcode_interpreter-0.0.10/src/interpreter.rs +268 -0
  55. nc_gcode_interpreter-0.0.10/src/lib.rs +65 -0
  56. nc_gcode_interpreter-0.0.10/src/main.rs +120 -0
  57. nc_gcode_interpreter-0.0.10/src/modal_groups.rs +65 -0
  58. nc_gcode_interpreter-0.0.10/src/state.rs +77 -0
  59. nc_gcode_interpreter-0.0.10/src/types.rs +25 -0
  60. nc_gcode_interpreter-0.0.10/uv.lock +1656 -0
@@ -0,0 +1,329 @@
1
+ # This file is autogenerated by maturin v1.7.4
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github --platform all
5
+ #
6
+ # Edited to:
7
+ # - build using binary bindings
8
+ # - extract the binaries from the wheel
9
+ # - upload both the wheel and the binary to the release
10
+ # - disable some platforms
11
+
12
+ name: Build and Release
13
+
14
+ on:
15
+ push:
16
+ branches:
17
+ - main
18
+ tags:
19
+ - 'v*'
20
+ pull_request:
21
+ workflow_dispatch:
22
+
23
+
24
+ permissions:
25
+ contents: write
26
+
27
+ env:
28
+ PROJECT_NAME: "nc-gcode-interpreter"
29
+ jobs:
30
+ lint:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: 3.13
37
+ - name: Install Python linter
38
+ run: pip install ruff
39
+ - name: Lint Python code with ruff
40
+ run: ruff check .
41
+
42
+ linux-x64:
43
+ needs: [lint]
44
+ runs-on: ${{ matrix.platform.runner }}
45
+ strategy:
46
+ matrix:
47
+ platform:
48
+ - runner: ubuntu-latest
49
+ target: x86_64
50
+ python-version: ["3.12", "3.13"]
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: ${{ matrix.python-version }}
56
+ - name: Update Cargo.toml Version
57
+ if: startsWith(github.ref, 'refs/tags/')
58
+ run: |
59
+ VERSION=${GITHUB_REF#refs/tags/v}
60
+ echo "Setting version to $VERSION"
61
+ sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
62
+ - name: Build wheels
63
+ uses: PyO3/maturin-action@v1
64
+ with:
65
+ target: ${{ matrix.platform.target }}
66
+ args: --release --out dist --find-interpreter
67
+ sccache: 'true'
68
+ manylinux: auto
69
+ - name: Upload wheels
70
+ uses: actions/upload-artifact@v4
71
+ with:
72
+ name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}-py${{ matrix.python-version }}-${{ github.sha }}
73
+ path: dist
74
+
75
+ test:
76
+ needs: [linux-x64]
77
+ runs-on: ubuntu-latest
78
+ strategy:
79
+ matrix:
80
+ python-version: ["3.12", "3.13"]
81
+ steps:
82
+ - uses: actions/checkout@v4
83
+ - uses: actions/download-artifact@v4
84
+ with:
85
+ name: wheels-ubuntu-latest-x86_64-py${{ matrix.python-version }}-${{ github.sha }}
86
+ path: dist
87
+ - uses: actions/setup-python@v5
88
+ with:
89
+ python-version: ${{ matrix.python-version }}
90
+ - name: Install py_opw_kinematics
91
+ shell: bash
92
+ run: |
93
+ set -e # Exit on error
94
+ PY_VERSION="${{ matrix.python-version }}"
95
+ PY_VERSION_NO_DOT="${PY_VERSION//./}"
96
+ WHL_FILES=(dist/*cp${PY_VERSION_NO_DOT}*.whl)
97
+ if [ ${#WHL_FILES[@]} -eq 0 ]; then
98
+ echo "No matching wheel files found!"
99
+ exit 1
100
+ fi
101
+ if [ ${#WHL_FILES[@]} -gt 1 ]; then
102
+ echo "Multiple wheel files found: ${WHL_FILES[*]}"
103
+ exit 1
104
+ fi
105
+ pip install "${WHL_FILES[0]}[test]"
106
+ - name: Run tests with pytest
107
+ run: pytest
108
+ - name: Type checking with mypy
109
+ run: mypy python
110
+ linux:
111
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
112
+ needs: [lint, test]
113
+ runs-on: ${{ matrix.platform.runner }}
114
+ strategy:
115
+ matrix:
116
+ platform:
117
+ # - runner: ubuntu-latest
118
+ # target: x86
119
+ - runner: ubuntu-latest
120
+ target: aarch64
121
+ python-version: ["3.12", "3.13"]
122
+ steps:
123
+ - uses: actions/checkout@v4
124
+ - uses: actions/setup-python@v5
125
+ with:
126
+ python-version: ${{ matrix.python-version }}
127
+ - name: Update Cargo.toml Version
128
+ if: startsWith(github.ref, 'refs/tags/')
129
+ shell: bash
130
+ run: |
131
+ set -e # Exit on error
132
+ VERSION=${GITHUB_REF#refs/tags/v}
133
+ echo "Setting version to $VERSION"
134
+ if ! sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
135
+ echo "Failed to update version in Cargo.toml"
136
+ exit 1
137
+ fi
138
+ - name: Build wheels
139
+ uses: PyO3/maturin-action@v1
140
+ with:
141
+ target: ${{ matrix.platform.target }}
142
+ args: --release --out dist --find-interpreter
143
+ sccache: 'true'
144
+ manylinux: auto
145
+ - name: Upload wheels
146
+ uses: actions/upload-artifact@v4
147
+ with:
148
+ name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}-py${{ matrix.python-version }}-${{ github.sha }}
149
+ path: dist
150
+
151
+ windows:
152
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
153
+ needs: [lint, test]
154
+ runs-on: ${{ matrix.platform.runner }}
155
+ strategy:
156
+ matrix:
157
+ platform:
158
+ - runner: windows-latest
159
+ target: x64
160
+ python-version: ["3.12", "3.13"]
161
+ steps:
162
+ - uses: actions/checkout@v4
163
+ - uses: actions/setup-python@v5
164
+ with:
165
+ python-version: ${{ matrix.python-version }}
166
+ architecture: ${{ matrix.platform.target }}
167
+ - name: Update Cargo.toml Version
168
+ if: startsWith(github.ref, 'refs/tags/')
169
+ shell: pwsh
170
+ run: |
171
+ $ErrorActionPreference = "Stop"
172
+ try {
173
+ $VERSION = $env:GITHUB_REF -replace 'refs/tags/v',''
174
+ Write-Host "Setting version to $VERSION"
175
+
176
+ # Read Cargo.toml as UTF-8
177
+ $path = Resolve-Path Cargo.toml
178
+ $content = [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::UTF8)
179
+
180
+ # Update version using multiline regex to match "version ="
181
+ $newContent = $content -replace '(?m)^\s*version\s*=\s*".*"', "version = `"$VERSION`""
182
+
183
+ if ($newContent -eq $content) {
184
+ throw "Version pattern not found in Cargo.toml"
185
+ }
186
+
187
+ # Write back with UTF-8 encoding
188
+ [System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)
189
+ Write-Host "Cargo.toml version updated successfully."
190
+ }
191
+ catch {
192
+ Write-Error "Failed to update version in Cargo.toml: $_"
193
+ exit 1
194
+ }
195
+
196
+ - name: Build wheels
197
+ uses: PyO3/maturin-action@v1
198
+ with:
199
+ target: ${{ matrix.platform.target }}
200
+ args: --release --out dist --find-interpreter
201
+ sccache: 'true'
202
+ - name: Upload wheels
203
+ uses: actions/upload-artifact@v4
204
+ with:
205
+ name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}-py${{ matrix.python-version }}-${{ github.sha }}
206
+ path: dist
207
+
208
+ macos:
209
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
210
+ needs: [lint, test]
211
+ runs-on: ${{ matrix.platform.runner }}
212
+ strategy:
213
+ matrix:
214
+ platform:
215
+ - runner: macos-latest
216
+ target: x86_64
217
+ - runner: macos-latest
218
+ target: aarch64
219
+ python-version: ["3.12", "3.13"]
220
+ steps:
221
+ - uses: actions/checkout@v4
222
+ - uses: actions/setup-python@v5
223
+ with:
224
+ python-version: ${{ matrix.python-version }}
225
+ - name: Update Cargo.toml Version
226
+ if: startsWith(github.ref, 'refs/tags/')
227
+ shell: bash
228
+ run: |
229
+ set -e # Exit on error
230
+ VERSION=${GITHUB_REF#refs/tags/v}
231
+ echo "Setting version to $VERSION"
232
+ if ! sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
233
+ echo "Failed to update version in Cargo.toml"
234
+ exit 1
235
+ fi
236
+ - name: Build wheels
237
+ uses: PyO3/maturin-action@v1
238
+ with:
239
+ target: ${{ matrix.platform.target }}
240
+ args: --release --out dist --find-interpreter
241
+ sccache: 'true'
242
+ - name: Upload wheels
243
+ uses: actions/upload-artifact@v4
244
+ with:
245
+ name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}-py${{ matrix.python-version }}-${{ github.sha }}
246
+ path: dist
247
+
248
+ sdist:
249
+ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
250
+ needs: [lint, test]
251
+ runs-on: ubuntu-latest
252
+ steps:
253
+ - uses: actions/checkout@v4
254
+ - uses: actions/setup-python@v5
255
+ with:
256
+ python-version: 3.12
257
+ - name: Update Cargo.toml Version
258
+ if: startsWith(github.ref, 'refs/tags/')
259
+ shell: bash
260
+ run: |
261
+ set -e # Exit on error
262
+ VERSION=${GITHUB_REF#refs/tags/v}
263
+ echo "Setting version to $VERSION"
264
+ if ! sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; then
265
+ echo "Failed to update version in Cargo.toml"
266
+ exit 1
267
+ fi
268
+ - name: Build sdist
269
+ uses: PyO3/maturin-action@v1
270
+ with:
271
+ command: sdist
272
+ args: --out dist
273
+ - name: Upload sdist
274
+ uses: actions/upload-artifact@v4
275
+ with:
276
+ name: wheels-sdist
277
+ path: dist
278
+
279
+ release:
280
+ name: Release
281
+ runs-on: ubuntu-latest
282
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
283
+ needs: [linux, linux-x64, windows, macos, sdist]
284
+ permissions:
285
+ id-token: write
286
+ contents: write
287
+ attestations: write
288
+ steps:
289
+ - uses: actions/download-artifact@v4
290
+ with:
291
+ merge-multiple: true
292
+ path: dist
293
+ - uses: actions/setup-python@v5
294
+ with:
295
+ python-version: 3.12
296
+ - name: Generate artifact attestation
297
+ uses: actions/attest-build-provenance@v1
298
+ with:
299
+ subject-path: 'dist/*'
300
+ - name: Publish to PyPI
301
+ if: startsWith(github.ref, 'refs/tags/')
302
+ uses: PyO3/maturin-action@v1
303
+ with:
304
+ command: upload
305
+ args: --non-interactive --skip-existing dist/*
306
+ - name: Prepare release assets
307
+ run: |
308
+ mkdir release-assets
309
+ cp dist/*.tar.gz release-assets/
310
+ cp dist/*.whl release-assets/
311
+ # Remove any duplicate files based on their content
312
+ cd release-assets
313
+ for f in *.whl; do
314
+ if [ -f "$f" ]; then
315
+ # Keep only one copy of each unique file
316
+ sha256sum "$f" | sort -u | while read -r sum file; do
317
+ others=$(sha256sum * | grep "$sum" | cut -d' ' -f2- | grep -v "^$file$" || true)
318
+ for other in $others; do
319
+ rm -f "$other"
320
+ done
321
+ done
322
+ fi
323
+ done
324
+ - name: Upload to GitHub Release
325
+ uses: softprops/action-gh-release@v2
326
+ with:
327
+ files: release-assets/*
328
+ fail_on_unmatched_files: false
329
+ prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
@@ -0,0 +1,28 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ debug/
4
+ target/
5
+ dist/
6
+
7
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
8
+ # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
9
+ #Cargo.lock
10
+
11
+ # These are backup files generated by rustfmt
12
+ **/*.rs.bk
13
+
14
+ # MSVC Windows builds of rustc generate these, which store debugging information
15
+ *.pdb
16
+
17
+ # RustRover
18
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
19
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
20
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
21
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
22
+ #.idea/
23
+
24
+ # python
25
+ .venv
26
+ __pycache__
27
+ python/**/*.so
28
+ python/**/*.pyc
@@ -0,0 +1,39 @@
1
+ # Contributing to NC-GCode-Interpreter
2
+
3
+ We welcome contributions to the NC-GCode-Interpreter project! This document provides guidelines for contributing to the project.
4
+
5
+ ## Submitting Changes
6
+
7
+ 1. Open a pull request against the main repository.
8
+ 2. Describe your changes in the pull request description.
9
+
10
+ ## Code Style
11
+
12
+ - Follow the Rust style guide for Rust code.
13
+ - Use PEP 8 style guide for Python code.
14
+ - Use meaningful variable and function names.
15
+ - Comment your code where necessary.
16
+
17
+ ## Reporting Bugs
18
+
19
+ - Use the GitHub Issues page to report bugs.
20
+ - Describe the bug in detail, including steps to reproduce.
21
+ - Include the version of NC-GCode-Interpreter you're using.
22
+ - Include the platform you are using NC-GCode-Interpreter on. (e.g. Windows x64, macOS ARM)
23
+ - Include whether the bug occurred in the Python package or the CLI.
24
+
25
+ ## Feature Requests
26
+ We appreciate your interest in improving NC-GCode-Interpreter! Please note:
27
+
28
+ - Our primary focus is on features that align with our specific business use case.
29
+ - We encourage you to implement new features yourself if they fall outside our current scope.
30
+ - If you believe a feature would benefit our business use case:
31
+ 1. Open an issue on the GitHub Issues page to discuss the feature.
32
+ 2. Clearly describe the feature and its potential benefits, especially how it relates to NC code interpretation and our use case.
33
+ 3. Be prepared to (partially) implement the feature yourself if approved.
34
+
35
+ ## Questions
36
+
37
+ If you have any questions about contributing, please open an issue or reach out to the maintainers.
38
+
39
+ Thank you for contributing to NC-GCode-Interpreter!