tiny-bclibc-wasm 0.0.1__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 (43) hide show
  1. tiny_bclibc_wasm-0.0.1/.github/dependabot.yml +30 -0
  2. tiny_bclibc_wasm-0.0.1/.github/workflows/pre-commit.yml +90 -0
  3. tiny_bclibc_wasm-0.0.1/.github/workflows/publish.yml +144 -0
  4. tiny_bclibc_wasm-0.0.1/.github/workflows/tests.yml +187 -0
  5. tiny_bclibc_wasm-0.0.1/.gitignore +24 -0
  6. tiny_bclibc_wasm-0.0.1/.gitmodules +4 -0
  7. tiny_bclibc_wasm-0.0.1/.pre-commit-config.yaml +68 -0
  8. tiny_bclibc_wasm-0.0.1/MANIFEST.in +13 -0
  9. tiny_bclibc_wasm-0.0.1/PKG-INFO +130 -0
  10. tiny_bclibc_wasm-0.0.1/README.md +120 -0
  11. tiny_bclibc_wasm-0.0.1/bclibc/LICENSE +165 -0
  12. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/base_types.h +563 -0
  13. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/engine.h +1907 -0
  14. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/interp.h +159 -0
  15. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/platform.h +96 -0
  16. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/traj_data.h +181 -0
  17. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc/v3d.h +171 -0
  18. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/include/tiny_bclibc.h +11 -0
  19. tiny_bclibc_wasm-0.0.1/bclibc/tiny_bclibc/wasm/tiny_bclibc_wasm.c +517 -0
  20. tiny_bclibc_wasm-0.0.1/build_wasm.py +127 -0
  21. tiny_bclibc_wasm-0.0.1/examples/basic.py +43 -0
  22. tiny_bclibc_wasm-0.0.1/pyproject.toml +96 -0
  23. tiny_bclibc_wasm-0.0.1/setup.cfg +4 -0
  24. tiny_bclibc_wasm-0.0.1/setup.py +38 -0
  25. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/__init__.py +765 -0
  26. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/__init__.pyi +282 -0
  27. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/_bclibc_version.txt +1 -0
  28. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/_drag_tables.py +345 -0
  29. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/_runner.py +446 -0
  30. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc/py.typed +0 -0
  31. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/PKG-INFO +130 -0
  32. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/SOURCES.txt +40 -0
  33. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/dependency_links.txt +1 -0
  34. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/requires.txt +3 -0
  35. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/scm_file_list.json +104 -0
  36. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/scm_version.json +8 -0
  37. tiny_bclibc_wasm-0.0.1/src/tiny_bclibc_wasm.egg-info/top_level.txt +1 -0
  38. tiny_bclibc_wasm-0.0.1/tests/conftest.py +48 -0
  39. tiny_bclibc_wasm-0.0.1/tests/run_natmod_suite.py +36 -0
  40. tiny_bclibc_wasm-0.0.1/tests/test_api.py +135 -0
  41. tiny_bclibc_wasm-0.0.1/tests/test_hosts.py +79 -0
  42. tiny_bclibc_wasm-0.0.1/tests/test_natmod_suite.py +39 -0
  43. tiny_bclibc_wasm-0.0.1/uv.lock +897 -0
@@ -0,0 +1,30 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "uv"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ groups:
8
+ python-dependencies:
9
+ patterns:
10
+ - "*"
11
+
12
+ - package-ecosystem: "github-actions"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "weekly"
16
+ groups:
17
+ actions:
18
+ patterns:
19
+ - "*"
20
+
21
+ # The bclibc submodule: a weekly PR when its tracked branch (.gitmodules) moves.
22
+ - package-ecosystem: "gitsubmodule"
23
+ directory: "/"
24
+ schedule:
25
+ interval: "weekly"
26
+
27
+ - package-ecosystem: "pre-commit"
28
+ directory: "/"
29
+ schedule:
30
+ interval: "weekly"
@@ -0,0 +1,90 @@
1
+ name: Pre-commit
2
+
3
+ # Same flow as py-ballisticcalc's: run every hook; on a pull request from this repo, commit what the
4
+ # auto-fixing hooks (ruff) changed and verify again; anywhere else, changed files are a failure.
5
+
6
+ on:
7
+ push:
8
+ pull_request:
9
+ workflow_dispatch:
10
+ workflow_call:
11
+
12
+ concurrency:
13
+ group: pre-commit-${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ permissions:
17
+ contents: write
18
+
19
+ jobs:
20
+ pre-commit:
21
+ name: pre-commit run --all-files
22
+ runs-on: ubuntu-latest
23
+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
24
+ steps:
25
+ - uses: actions/checkout@v7
26
+ with:
27
+ fetch-depth: 0 # setuptools_scm needs tags for the package version
28
+ ref: ${{ github.head_ref || github.ref_name }}
29
+ submodules: recursive # the uv-sync hook compiles the .wasm modules from the bclibc submodule
30
+
31
+ - name: Install uv
32
+ uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4
33
+ with:
34
+ python-version: "3.11"
35
+
36
+ - name: Fetch micropython-bclibc's natmod test suite (run by the pytest hook)
37
+ run: |
38
+ curl -sSfL -o "$RUNNER_TEMP/test_bclibc.py" \
39
+ https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/main/tests/test_bclibc.py
40
+ echo "BCLIBC_NATMOD_SUITE=$RUNNER_TEMP/test_bclibc.py" >> "$GITHUB_ENV"
41
+
42
+ - name: Install pre-commit
43
+ run: uv tool install pre-commit
44
+
45
+ - name: Run pre-commit
46
+ id: first_run
47
+ continue-on-error: true
48
+ run: pre-commit run --all-files --show-diff-on-failure
49
+
50
+ - name: Check for changes
51
+ id: diff
52
+ run: |
53
+ if [ -n "$(git status --porcelain)" ]; then
54
+ echo "changed=true" >> "$GITHUB_OUTPUT"
55
+ else
56
+ echo "changed=false" >> "$GITHUB_OUTPUT"
57
+ fi
58
+
59
+ - name: Fail (no auto-fixable changes, but hooks failed)
60
+ if: steps.diff.outputs.changed == 'false' && steps.first_run.outcome == 'failure'
61
+ run: exit 1
62
+
63
+ - name: Fail (changes produced, but not on a pull_request)
64
+ if: steps.diff.outputs.changed == 'true' && github.event_name != 'pull_request'
65
+ run: |
66
+ echo "pre-commit modified files, but auto-commit only runs on pull_request events."
67
+ git status --porcelain
68
+ exit 1
69
+
70
+ - name: Re-run pre-commit after auto-fixes
71
+ id: verify_run
72
+ if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request'
73
+ continue-on-error: true
74
+ run: pre-commit run --all-files --show-diff-on-failure
75
+
76
+ - name: Fail (issues remain after auto-fix)
77
+ if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' && steps.verify_run.outcome == 'failure'
78
+ run: exit 1
79
+
80
+ - name: Commit and push auto-fixes
81
+ if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' && steps.verify_run.outcome == 'success'
82
+ env:
83
+ # through the environment, not inlined: a branch name is attacker-controlled text
84
+ BRANCH: ${{ github.head_ref || github.ref_name }}
85
+ run: |
86
+ git config user.name "github-actions[bot]"
87
+ git config user.email "github-actions[bot]@users.noreply.github.com"
88
+ git add -A
89
+ git commit -m "style: auto-fix via pre-commit"
90
+ git push origin "HEAD:$BRANCH"
@@ -0,0 +1,144 @@
1
+ name: Publish
2
+
3
+ # On a v* tag: build the sdist and the (pure-Python, py3-none-any) wheel, publish them to PyPI, and
4
+ # draft a GitHub release carrying them plus what non-pip users need:
5
+ # tiny_bclibc_dp.wasm / tiny_bclibc_sp.wasm the modules themselves, for any other host
6
+ # tiny_bclibc-pythonista.zip the ready-to-copy package folder for Pythonista
7
+ #
8
+ # workflow_dispatch builds (and optionally publishes to TestPyPI) without a tag.
9
+ #
10
+ # PyPI publishing uses trusted publishing: the `pypi` / `testpypi` environments must exist in this
11
+ # repo, and the project on PyPI must list this repo + workflow (publish.yml) as a trusted publisher.
12
+
13
+ on:
14
+ push:
15
+ tags:
16
+ - "v*"
17
+ workflow_dispatch:
18
+ inputs:
19
+ testpypi:
20
+ description: "Publish to TestPyPI"
21
+ required: false
22
+ type: boolean
23
+ default: false
24
+ version:
25
+ description: "Override version (e.g. 0.1.0rc1); TestPyPI needs one without a dev/local suffix"
26
+ required: false
27
+ type: string
28
+ default: ""
29
+
30
+ run-name: >
31
+ Publish → ${{ github.event_name == 'push' && 'PyPI' ||
32
+ inputs.testpypi && 'TestPyPI' || 'build only' }}
33
+
34
+ permissions:
35
+ contents: read
36
+
37
+ jobs:
38
+ build:
39
+ name: Build sdist + wheel
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v7
43
+ with:
44
+ fetch-depth: 0 # setuptools_scm needs tags
45
+ submodules: recursive
46
+
47
+ - name: Install uv
48
+ uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4
49
+
50
+ - name: Build (the wheel is built from the sdist, so this proves the sdist builds on its own)
51
+ env:
52
+ SETUPTOOLS_SCM_PRETEND_VERSION: ${{ inputs.version }}
53
+ # PyPI/TestPyPI reject local version segments (+g<hash>); keep them on build-only runs.
54
+ SETUPTOOLS_SCM_OVERRIDES_FOR_TINY_BCLIBC_WASM: >-
55
+ ${{ (github.event_name == 'push' || inputs.testpypi) && '{local_scheme = "no-local-version"}' || '' }}
56
+ run: uv build --out-dir dist
57
+
58
+ - name: Smoke-test the wheel in a clean environment
59
+ run: |
60
+ uv venv -q /tmp/smoke
61
+ uv pip install -q --python /tmp/smoke dist/*.whl
62
+ cd /tmp && TINY_BCLIBC_HOST=node /tmp/smoke/bin/python -c "
63
+ import tiny_bclibc as bc
64
+ shot = bc.Shot(bc=0.31, weight_grain=168, diameter_inch=0.308, muzzle_velocity_fps=2750, sight_height_ft=0.125)
65
+ angle = bc.zero(shot, 300 / 0.3048)
66
+ print(bc.version(), bc.host(), angle)
67
+ assert abs(angle - 0.002502) < 1e-4
68
+ "
69
+
70
+ - name: Release extras (standalone .wasm, Pythonista zip)
71
+ run: |
72
+ mkdir -p extras
73
+ python3 - <<'EOF'
74
+ import glob, zipfile
75
+ wheel = zipfile.ZipFile(glob.glob("dist/*.whl")[0])
76
+ with zipfile.ZipFile("extras/tiny_bclibc-pythonista.zip", "w", zipfile.ZIP_DEFLATED) as z:
77
+ for name in wheel.namelist():
78
+ if name.startswith("tiny_bclibc/"):
79
+ z.writestr(name, wheel.read(name))
80
+ if name.endswith(".wasm"):
81
+ open("extras/" + name.split("/")[-1], "wb").write(wheel.read(name))
82
+ z.write("examples/basic.py", "basic.py")
83
+ EOF
84
+ ls -l dist extras
85
+
86
+ - uses: actions/upload-artifact@v7
87
+ with:
88
+ name: dist
89
+ path: dist
90
+ retention-days: 14
91
+
92
+ - uses: actions/upload-artifact@v7
93
+ with:
94
+ name: extras
95
+ path: extras
96
+ retention-days: 14
97
+
98
+ publish:
99
+ needs: build
100
+ if: github.event_name == 'push' || inputs.testpypi
101
+ runs-on: ubuntu-latest
102
+ environment: ${{ github.event_name == 'push' && 'pypi' || 'testpypi' }}
103
+ permissions:
104
+ id-token: write
105
+ steps:
106
+ - uses: actions/download-artifact@v8
107
+ with:
108
+ name: dist
109
+ path: dist
110
+
111
+ - name: Publish to PyPI
112
+ if: github.event_name == 'push'
113
+ uses: pypa/gh-action-pypi-publish@release/v1
114
+ with:
115
+ skip-existing: true
116
+
117
+ - name: Publish to TestPyPI
118
+ if: github.event_name == 'workflow_dispatch'
119
+ uses: pypa/gh-action-pypi-publish@release/v1
120
+ with:
121
+ skip-existing: true
122
+ repository-url: https://test.pypi.org/legacy/
123
+
124
+ release:
125
+ needs: build
126
+ if: github.event_name == 'push'
127
+ runs-on: ubuntu-latest
128
+ permissions:
129
+ contents: write
130
+ steps:
131
+ - uses: actions/download-artifact@v8
132
+ with:
133
+ path: artifacts
134
+
135
+ - name: Create GitHub release (draft)
136
+ env:
137
+ GH_TOKEN: ${{ github.token }}
138
+ run: |
139
+ gh release create "${{ github.ref_name }}" \
140
+ --repo "${{ github.repository }}" \
141
+ --title "tiny-bclibc-wasm ${{ github.ref_name }}" \
142
+ --generate-notes \
143
+ --draft \
144
+ artifacts/dist/* artifacts/extras/*
@@ -0,0 +1,187 @@
1
+ name: Tests
2
+
3
+ # Builds the package from source (which compiles the .wasm modules with the ziglang build requirement)
4
+ # and runs the suite once per WebAssembly runtime, selected with pytest's --wasm-runtime (see
5
+ # tests/conftest.py; a runtime that can't start fails the step, it is never skipped):
6
+ #
7
+ # test: every OS x CPython oldest/newest + PyPy, on wasmtime and on Node (both available on
8
+ # every runner), and on wasm3 where pywasm3 installs (CPython 3.11+; built from git).
9
+ # jsc: WebKitGTK's JavaScriptCore -- the engine behind Pythonista's JSContext -- with its JIT
10
+ # and without it (iOS apps like Pythonista run it without), as the stand-in for an iOS
11
+ # device.
12
+ # coverage: combines the Ubuntu runs of all the runtimes (each one exercises its own host class
13
+ # in _runner.py) and uploads the result to Codecov.
14
+
15
+ on:
16
+ push:
17
+ paths-ignore: &non-code-paths
18
+ - "**.md"
19
+ - "LICENSE"
20
+ pull_request:
21
+ paths-ignore: *non-code-paths
22
+ workflow_dispatch:
23
+
24
+ concurrency:
25
+ group: tests-${{ github.workflow }}-${{ github.ref }}
26
+ cancel-in-progress: true
27
+
28
+ permissions:
29
+ contents: read
30
+
31
+ jobs:
32
+ test:
33
+ name: ${{ matrix.os }} / ${{ matrix.python-version }}
34
+ runs-on: ${{ matrix.os }}
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ os: [ubuntu-latest, windows-latest, macos-latest]
39
+ python-version: ["3.10", "3.14", "pypy3.11"]
40
+ defaults:
41
+ run:
42
+ shell: bash
43
+ env:
44
+ # Coverage only from Ubuntu: one path layout to combine, and the runtimes behave the same
45
+ # elsewhere (which the other legs still verify).
46
+ COV_ARGS: ${{ matrix.os == 'ubuntu-latest' && '--cov --cov-report=' || '' }}
47
+ COV_ID: ${{ matrix.os }}-${{ matrix.python-version }}
48
+ steps:
49
+ - uses: actions/checkout@v7
50
+ with:
51
+ fetch-depth: 0 # setuptools_scm needs tags for the package version
52
+ submodules: recursive
53
+
54
+ - name: Install uv
55
+ uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4
56
+ with:
57
+ python-version: ${{ matrix.python-version }}
58
+
59
+ - name: Fetch micropython-bclibc's natmod test suite
60
+ run: |
61
+ curl -sSfL -o "$RUNNER_TEMP/test_bclibc.py" \
62
+ https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/main/tests/test_bclibc.py
63
+ echo "BCLIBC_NATMOD_SUITE=$RUNNER_TEMP/test_bclibc.py" >> "$GITHUB_ENV"
64
+
65
+ - name: Build and install (compiles the .wasm modules)
66
+ run: uv sync --locked
67
+
68
+ - name: pytest --wasm-runtime wasmtime
69
+ run: uv run --locked pytest -v --wasm-runtime wasmtime $COV_ARGS
70
+ env:
71
+ COVERAGE_FILE: .coverage.${{ env.COV_ID }}-wasmtime
72
+
73
+ - name: pytest --wasm-runtime node
74
+ if: ${{ !cancelled() }} # run every runtime even if an earlier one failed
75
+ run: uv run --locked pytest -v --wasm-runtime node $COV_ARGS
76
+ env:
77
+ COVERAGE_FILE: .coverage.${{ env.COV_ID }}-node
78
+
79
+ - name: pytest --wasm-runtime wasm3
80
+ # pywasm3 is a dev dependency only on CPython >= 3.11 (see pyproject.toml)
81
+ if: ${{ !cancelled() && matrix.python-version != '3.10' && !startsWith(matrix.python-version, 'pypy') }}
82
+ run: uv run --locked pytest -v --wasm-runtime wasm3 $COV_ARGS
83
+ env:
84
+ COVERAGE_FILE: .coverage.${{ env.COV_ID }}-wasm3
85
+
86
+ - name: Example
87
+ run: uv run --locked python examples/basic.py
88
+
89
+ - name: Upload coverage data
90
+ if: ${{ matrix.os == 'ubuntu-latest' && !cancelled() }}
91
+ uses: actions/upload-artifact@v7
92
+ with:
93
+ name: coverage-data-${{ env.COV_ID }}
94
+ path: .coverage.*
95
+ include-hidden-files: true
96
+ if-no-files-found: error
97
+ retention-days: 3
98
+
99
+ jsc:
100
+ name: WebKitGTK JavaScriptCore
101
+ runs-on: ubuntu-latest
102
+ steps:
103
+ - uses: actions/checkout@v7
104
+ with:
105
+ fetch-depth: 0
106
+ submodules: recursive
107
+
108
+ - name: Install JavaScriptCore + PyGObject
109
+ run: |
110
+ sudo apt-get update -q
111
+ sudo apt-get install -y -q gir1.2-javascriptcoregtk-4.1 python3-gi
112
+
113
+ - name: Install uv
114
+ uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4
115
+
116
+ - name: Fetch micropython-bclibc's natmod test suite
117
+ run: |
118
+ curl -sSfL -o "$RUNNER_TEMP/test_bclibc.py" \
119
+ https://raw.githubusercontent.com/ballistics-lab/micropython-bclibc/main/tests/test_bclibc.py
120
+ echo "BCLIBC_NATMOD_SUITE=$RUNNER_TEMP/test_bclibc.py" >> "$GITHUB_ENV"
121
+
122
+ # python3-gi is built for the distribution's own Python, so use that interpreter with its
123
+ # site-packages visible.
124
+ - name: Build and install into a system-site-packages venv
125
+ run: |
126
+ uv venv --system-site-packages --python /usr/bin/python3 .venv
127
+ uv pip install -e . pytest pytest-cov
128
+
129
+ - name: pytest --wasm-runtime gi-jsc (JIT on)
130
+ run: .venv/bin/python -m pytest -v --wasm-runtime gi-jsc --cov --cov-report=
131
+ env:
132
+ JSC_useJIT: "true"
133
+ COVERAGE_FILE: .coverage.jsc-jit
134
+
135
+ - name: pytest --wasm-runtime gi-jsc (JIT off, as on iOS)
136
+ if: ${{ !cancelled() }}
137
+ run: .venv/bin/python -m pytest -v --wasm-runtime gi-jsc --cov --cov-report=
138
+ env:
139
+ JSC_useJIT: "false"
140
+ COVERAGE_FILE: .coverage.jsc-nojit
141
+
142
+ - name: Example
143
+ run: TINY_BCLIBC_HOST=gi-jsc .venv/bin/python examples/basic.py
144
+
145
+ - name: Upload coverage data
146
+ if: ${{ !cancelled() }}
147
+ uses: actions/upload-artifact@v7
148
+ with:
149
+ name: coverage-data-jsc
150
+ path: .coverage.*
151
+ include-hidden-files: true
152
+ if-no-files-found: error
153
+ retention-days: 3
154
+
155
+ coverage:
156
+ name: Combine coverage + Codecov
157
+ needs: [test, jsc]
158
+ if: ${{ !cancelled() && github.actor != 'dependabot[bot]' }}
159
+ runs-on: ubuntu-latest
160
+ permissions:
161
+ contents: read
162
+ id-token: write # Codecov OIDC upload, no token secret needed
163
+ steps:
164
+ - uses: actions/checkout@v7
165
+
166
+ - name: Install uv
167
+ uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4
168
+
169
+ - name: Download coverage data
170
+ uses: actions/download-artifact@v8
171
+ with:
172
+ pattern: coverage-data-*
173
+ merge-multiple: true
174
+
175
+ - name: Combine coverage
176
+ run: |
177
+ uvx coverage combine
178
+ uvx coverage report
179
+ uvx coverage xml
180
+ uvx coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY"
181
+
182
+ - name: Upload to Codecov
183
+ uses: codecov/codecov-action@v7
184
+ with:
185
+ use_oidc: true
186
+ files: ./coverage.xml
187
+ fail_ci_if_error: true
@@ -0,0 +1,24 @@
1
+ **/__pycache__
2
+ **/.ruff_cache/
3
+ **/.pytest_cache/
4
+ **/.idea
5
+ **/*.pyd
6
+ **/*.so
7
+ **/*.dylib
8
+ **/build
9
+ **/dist
10
+ **/wheelhouse
11
+ **/*.egg-info
12
+ **/.venv
13
+ **/*.ps1
14
+ **/debug
15
+ .vscode
16
+
17
+ # build_wasm.py output (compiled on every build from the bclibc submodule, shipped inside the wheel)
18
+ src/tiny_bclibc/*.wasm
19
+ src/tiny_bclibc/_bclibc_version.txt
20
+ # coverage
21
+ .coverage
22
+ .coverage.*
23
+ coverage.xml
24
+ htmlcov/
@@ -0,0 +1,4 @@
1
+ [submodule "bclibc"]
2
+ path = bclibc
3
+ url = https://github.com/ballistics-lab/bclibc.git
4
+ branch = tiny-bclibc-wasm
@@ -0,0 +1,68 @@
1
+ default_install_hook_types: [pre-commit]
2
+ default_language_version:
3
+ python: python3
4
+
5
+ repos:
6
+ - repo: local
7
+ hooks:
8
+ - id: uv-lock
9
+ name: uv lock check
10
+ entry: uv
11
+ # --check only, not --upgrade: same reasoning as py-ballisticcalc's hook -- --upgrade would
12
+ # re-resolve to whatever is newest on PyPI at run time and fail later pushes with no code
13
+ # change involved. --check only verifies uv.lock still matches pyproject.toml.
14
+ args: ["lock", "--check"]
15
+ language: system
16
+ pass_filenames: false
17
+ files: '^(pyproject\.toml|uv\.lock)$'
18
+
19
+ - id: uv-sync
20
+ name: uv sync before hooks
21
+ entry: uv
22
+ # Rebuilds the editable install -- and with it the .wasm modules -- whenever pyproject.toml's
23
+ # [tool.uv] cache-keys changed (build hooks, wrapper C source, tiny_bclibc headers).
24
+ args: ["sync"]
25
+ language: system
26
+ pass_filenames: false
27
+
28
+ - id: uv-pyright
29
+ name: pyright
30
+ entry: uv
31
+ args: ["run", "pyright"]
32
+ language: system
33
+ pass_filenames: false
34
+ files: '\.pyi?$'
35
+
36
+ - id: uv-stubtest
37
+ name: stubtest (__init__.pyi matches the module)
38
+ entry: uv
39
+ args: ["run", "python", "-m", "mypy.stubtest", "tiny_bclibc"]
40
+ language: system
41
+ pass_filenames: false
42
+ files: '^src/.*\.pyi?$'
43
+
44
+ - id: uv-ruff-check
45
+ name: ruff lint & fix
46
+ entry: uv
47
+ args: ["run", "ruff", "check", "--fix"]
48
+ language: system
49
+ pass_filenames: false
50
+ files: '\.pyi?$'
51
+
52
+ - id: uv-ruff-format
53
+ name: ruff format
54
+ entry: uv
55
+ args: ["run", "ruff", "format"]
56
+ language: system
57
+ pass_filenames: false
58
+ files: '\.pyi?$'
59
+
60
+ - id: uv-pytest
61
+ name: pytest
62
+ entry: uv
63
+ # Fast (well under a second): host agreement + micropython-bclibc's natmod suite in both
64
+ # precisions (skipped when ../micropython-bclibc isn't checked out).
65
+ args: ["run", "pytest", "-q"]
66
+ language: system
67
+ pass_filenames: false
68
+ files: '(\.py|\.c|\.h|pyproject\.toml)$'
@@ -0,0 +1,13 @@
1
+ # The sdist must be buildable on its own: build hooks plus the tiny_bclibc sources they compile
2
+ # From the bclibc submodule only what build_wasm.py compiles: setuptools_scm would otherwise ship all
3
+ # of it (the C++ engine, its CI, ...), and without the explicit grafts a fresh clone that setuptools_scm
4
+ # doesn't list would ship none of it.
5
+ include build_wasm.py setup.py README.md
6
+ graft src
7
+ prune bclibc
8
+ graft bclibc/tiny_bclibc/include
9
+ graft bclibc/tiny_bclibc/wasm
10
+ include bclibc/LICENSE
11
+ graft tests
12
+ graft examples
13
+ global-exclude *.wasm __pycache__ *.py[cod]