carla-pack-registry 0.3.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.
Files changed (52) hide show
  1. carla_pack_registry-0.3.0/.github/workflows/ci.yml +49 -0
  2. carla_pack_registry-0.3.0/.github/workflows/release.yml +316 -0
  3. carla_pack_registry-0.3.0/.gitignore +6 -0
  4. carla_pack_registry-0.3.0/Cargo.lock +2353 -0
  5. carla_pack_registry-0.3.0/Cargo.toml +41 -0
  6. carla_pack_registry-0.3.0/LICENSE +202 -0
  7. carla_pack_registry-0.3.0/PKG-INFO +177 -0
  8. carla_pack_registry-0.3.0/README.md +157 -0
  9. carla_pack_registry-0.3.0/docs/architecture.md +157 -0
  10. carla_pack_registry-0.3.0/docs/pack-repository.md +136 -0
  11. carla_pack_registry-0.3.0/docs/release.md +33 -0
  12. carla_pack_registry-0.3.0/docs/security.md +51 -0
  13. carla_pack_registry-0.3.0/pyproject.toml +42 -0
  14. carla_pack_registry-0.3.0/python/carla_pack_registry/__init__.py +43 -0
  15. carla_pack_registry-0.3.0/python/carla_pack_registry/__main__.py +3 -0
  16. carla_pack_registry-0.3.0/python/carla_pack_registry/_core.pyi +102 -0
  17. carla_pack_registry-0.3.0/python/carla_pack_registry/cli.py +446 -0
  18. carla_pack_registry-0.3.0/python/carla_pack_registry/deploy.py +115 -0
  19. carla_pack_registry-0.3.0/python/carla_pack_registry/publish.py +86 -0
  20. carla_pack_registry-0.3.0/python/carla_pack_registry/py.typed +0 -0
  21. carla_pack_registry-0.3.0/python/tests/__init__.py +0 -0
  22. carla_pack_registry-0.3.0/python/tests/conftest.py +198 -0
  23. carla_pack_registry-0.3.0/python/tests/packs.py +115 -0
  24. carla_pack_registry-0.3.0/python/tests/test_deploy.py +139 -0
  25. carla_pack_registry-0.3.0/python/tests/test_e2e.py +180 -0
  26. carla_pack_registry-0.3.0/python/tests/test_formats.py +106 -0
  27. carla_pack_registry-0.3.0/python/tests/test_publish_hf.py +113 -0
  28. carla_pack_registry-0.3.0/rustfmt.toml +2 -0
  29. carla_pack_registry-0.3.0/scripts/bump-cli-version.py +78 -0
  30. carla_pack_registry-0.3.0/src/auth.rs +121 -0
  31. carla_pack_registry-0.3.0/src/client.rs +556 -0
  32. carla_pack_registry-0.3.0/src/error.rs +83 -0
  33. carla_pack_registry-0.3.0/src/formats.rs +338 -0
  34. carla_pack_registry-0.3.0/src/github.rs +159 -0
  35. carla_pack_registry-0.3.0/src/hf.rs +92 -0
  36. carla_pack_registry-0.3.0/src/lib.rs +29 -0
  37. carla_pack_registry-0.3.0/src/manifest.rs +602 -0
  38. carla_pack_registry-0.3.0/src/pack.rs +380 -0
  39. carla_pack_registry-0.3.0/src/python.rs +369 -0
  40. carla_pack_registry-0.3.0/src/s3.rs +287 -0
  41. carla_pack_registry-0.3.0/src/sigv4.rs +183 -0
  42. carla_pack_registry-0.3.0/src/store.rs +134 -0
  43. carla_pack_registry-0.3.0/src/time.rs +111 -0
  44. carla_pack_registry-0.3.0/templates/pack-repo/.github/workflows/carla-pack-credentials-aws.yml +66 -0
  45. carla_pack_registry-0.3.0/templates/pack-repo/.github/workflows/carla-pack-credentials-r2.yml +73 -0
  46. carla_pack_registry-0.3.0/templates/pack-repo/carla-packs.huggingface.toml +20 -0
  47. carla_pack_registry-0.3.0/templates/pack-repo/carla-packs.toml +23 -0
  48. carla_pack_registry-0.3.0/tests/auth.rs +104 -0
  49. carla_pack_registry-0.3.0/tests/common/mod.rs +112 -0
  50. carla_pack_registry-0.3.0/tests/flow.rs +391 -0
  51. carla_pack_registry-0.3.0/tests/large.rs +233 -0
  52. carla_pack_registry-0.3.0/tests/pack.rs +134 -0
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ concurrency:
12
+ group: ci-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ rust:
17
+ runs-on: ubuntu-24.04
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+ - uses: dtolnay/rust-toolchain@stable
21
+ with:
22
+ components: rustfmt, clippy
23
+ - run: cargo fmt --check
24
+ - run: cargo clippy --all-targets --features python -- -D warnings
25
+ - run: cargo test
26
+
27
+ python:
28
+ runs-on: ubuntu-24.04
29
+ strategy:
30
+ matrix:
31
+ python-version: ["3.10", "3.13"]
32
+ steps:
33
+ - uses: actions/checkout@v5
34
+ - uses: dtolnay/rust-toolchain@stable
35
+ - uses: actions/setup-python@v6
36
+ with:
37
+ python-version: ${{ matrix.python-version }}
38
+ - name: Build the wheel and run the Python tests (end to end against moto's S3 with IAM auth)
39
+ run: |
40
+ python -m venv .venv && . .venv/bin/activate
41
+ pip install "maturin>=1.9,<2" "pytest>=8" "moto[server]==5.2.5" boto3 "huggingface_hub>=0.32"
42
+ maturin build --release -o dist
43
+ pip install dist/*.whl
44
+ carla-pack --version
45
+ pytest -v -p no:cacheprovider
46
+ - name: Workflow templates are valid YAML
47
+ run: |
48
+ . .venv/bin/activate && pip install pyyaml
49
+ python -c "import sys, yaml; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" templates/pack-repo/.github/workflows/*.yml
@@ -0,0 +1,316 @@
1
+ # Cuts releases of the carla-pack-registry Python package (the carla-pack CLI) and
2
+ # publishes them to PyPI. The mechanism is simple_lanelet2's (itself from tier4/splatsim).
3
+ #
4
+ # push to main when the merged PR carries exactly one `release:major|minor|patch`
5
+ # label, the `release` job bumps Cargo.toml + Cargo.lock,
6
+ # commits, tags `vX.Y.Z`, creates the GitHub release, and the same run
7
+ # builds, tests and publishes that tag. No label: nothing happens.
8
+ # push a v* tag a hand-cut tag (a hotfix, say) is built and published directly.
9
+ # pull_request / workflow_dispatch
10
+ # a dry run: wheels and sdist are built and tested, nothing is tagged
11
+ # or published. Pull requests only run it when they touch packaging.
12
+ #
13
+ # Publishing lives in this file rather than in an `on: push: tags` workflow on purpose:
14
+ # the auto-release tag is pushed with GITHUB_TOKEN, and a token-pushed tag starts no
15
+ # workflow runs.
16
+ #
17
+ # PyPI authentication is Trusted Publishing, so there is no token in the secrets. It is
18
+ # configured once on PyPI (pending publisher: owner `hakuturu583`, repository
19
+ # `carla_content_pack_registry`, workflow `release.yml`, environment `pypi`); until then
20
+ # the publish job fails and the artifacts stay downloadable from the run. See
21
+ # docs/release.md. A version can never be replaced on PyPI, so the tagged commit is
22
+ # tested again here rather than trusting CI on the merge.
23
+
24
+ name: Release
25
+
26
+ on:
27
+ push:
28
+ branches: [main]
29
+ tags: ["v*"]
30
+ pull_request:
31
+ paths:
32
+ - .github/workflows/release.yml
33
+ - scripts/bump-cli-version.py
34
+ - Cargo.toml
35
+ - Cargo.lock
36
+ - pyproject.toml
37
+ - LICENSE
38
+ - README.md
39
+ workflow_dispatch:
40
+
41
+ permissions:
42
+ contents: read
43
+
44
+ # Only pull-request dry runs are grouped (a newer push supersedes an older one). Pushes to
45
+ # main are not: GitHub keeps one pending run per group and cancels the rest, so a group
46
+ # would silently drop a labelled merge that queued behind another. Two releases racing
47
+ # are handled where it matters instead, in `commit, tag and push`.
48
+ concurrency:
49
+ group: release-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
50
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
51
+
52
+ jobs:
53
+ # Reads the release label off the merged PR and, if there is one, bumps, tags and
54
+ # creates the GitHub release. Only on a push to main.
55
+ release:
56
+ name: cut the release tag
57
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
58
+ runs-on: ubuntu-24.04
59
+ permissions:
60
+ contents: write
61
+ outputs:
62
+ bump: ${{ steps.pr.outputs.bump }}
63
+ tag: ${{ steps.bump.outputs.tag }}
64
+ steps:
65
+ - name: read the release label off the merged PR
66
+ id: pr
67
+ env:
68
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69
+ run: |
70
+ set -euo pipefail
71
+ pr_json=$(gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
72
+ --jq '.[0] // empty' 2>/dev/null || true)
73
+ if [ -z "$pr_json" ]; then
74
+ echo "No PR associated with this push -- nothing to release"
75
+ echo "bump=none" >> "$GITHUB_OUTPUT"
76
+ exit 0
77
+ fi
78
+ labels=$(echo "$pr_json" | jq -r '[.labels[].name] | join(",")')
79
+ bump=none
80
+ count=0
81
+ for lvl in major minor patch; do
82
+ if echo ",$labels," | grep -q ",release:${lvl},"; then
83
+ bump=$lvl
84
+ count=$((count + 1))
85
+ fi
86
+ done
87
+ if [ "$count" -gt 1 ]; then
88
+ echo "::error::More than one release label on the PR -- pick exactly one"
89
+ exit 1
90
+ fi
91
+ echo "bump=${bump}" >> "$GITHUB_OUTPUT"
92
+ echo "Resolved bump level: ${bump}"
93
+
94
+ - uses: actions/checkout@v5
95
+ if: steps.pr.outputs.bump != 'none'
96
+ with:
97
+ ref: main
98
+ fetch-depth: 0
99
+
100
+ # Bumps from the tip of main, not from the merged commit, and retries when another
101
+ # release (or any push) lands first: the rejected commit is dropped, main is fetched
102
+ # again and the bump recomputed, so two merges never claim the same version.
103
+ - name: bump, commit, tag and push
104
+ if: steps.pr.outputs.bump != 'none'
105
+ id: bump
106
+ env:
107
+ BUMP: ${{ steps.pr.outputs.bump }}
108
+ run: |
109
+ set -euo pipefail
110
+ git config user.name "github-actions[bot]"
111
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
112
+ for attempt in 1 2 3 4 5; do
113
+ git fetch --quiet --tags origin main
114
+ git reset --quiet --hard FETCH_HEAD
115
+ next=$(python3 scripts/bump-cli-version.py "$BUMP")
116
+ tag="v${next}"
117
+ if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
118
+ echo "::error::Tag ${tag} already exists"
119
+ exit 1
120
+ fi
121
+ git add Cargo.toml Cargo.lock
122
+ git commit --quiet -m "chore(release): ${tag}"
123
+ if git push origin HEAD:main; then
124
+ git tag -a "${tag}" -m "Release ${tag}"
125
+ git push origin "${tag}"
126
+ echo "tag=${tag}" >> "$GITHUB_OUTPUT"
127
+ echo "Released ${tag} (${BUMP})"
128
+ exit 0
129
+ fi
130
+ echo "main moved while releasing (attempt ${attempt}); bumping again from the new tip"
131
+ sleep $((attempt * 5))
132
+ done
133
+ echo "::error::Could not push the release commit to main"
134
+ exit 1
135
+
136
+ - name: GitHub release with generated notes
137
+ if: steps.pr.outputs.bump != 'none'
138
+ env:
139
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140
+ run: |
141
+ gh release create "${{ steps.bump.outputs.tag }}" \
142
+ --title "${{ steps.bump.outputs.tag }}" \
143
+ --generate-notes
144
+
145
+ # Works out, for every entry point, which commit to build and whether to publish it.
146
+ resolve:
147
+ name: resolve what to build
148
+ needs: [release]
149
+ if: always()
150
+ runs-on: ubuntu-24.04
151
+ outputs:
152
+ proceed: ${{ steps.r.outputs.proceed }}
153
+ ref: ${{ steps.r.outputs.ref }}
154
+ publish: ${{ steps.r.outputs.publish }}
155
+ version: ${{ steps.r.outputs.version }}
156
+ steps:
157
+ - id: r
158
+ env:
159
+ EVENT: ${{ github.event_name }}
160
+ REF: ${{ github.ref }}
161
+ REF_NAME: ${{ github.ref_name }}
162
+ SHA: ${{ github.sha }}
163
+ BUMP: ${{ needs.release.outputs.bump }}
164
+ TAG: ${{ needs.release.outputs.tag }}
165
+ run: |
166
+ set -euo pipefail
167
+ proceed=false; publish=false; ref="$SHA"
168
+ if [ "$EVENT" = "push" ] && [[ "$REF" == refs/tags/v* ]]; then
169
+ proceed=true; publish=true; ref="$REF_NAME" # a hand-cut tag
170
+ elif [ "$EVENT" = "push" ] && [ "$REF" = "refs/heads/main" ]; then
171
+ if [ "$BUMP" != "none" ] && [ -n "$TAG" ]; then
172
+ proceed=true; publish=true; ref="$TAG" # the auto-release
173
+ fi
174
+ elif [ "$EVENT" = "workflow_dispatch" ] || [ "$EVENT" = "pull_request" ]; then
175
+ proceed=true # a dry run
176
+ fi
177
+ version=""
178
+ if [ "$publish" = true ]; then version="${ref#v}"; fi
179
+ {
180
+ echo "proceed=$proceed"
181
+ echo "publish=$publish"
182
+ echo "ref=$ref"
183
+ echo "version=$version"
184
+ } >> "$GITHUB_OUTPUT"
185
+ echo "event=$EVENT ref=$ref proceed=$proceed publish=$publish version=$version"
186
+
187
+ verify:
188
+ name: test the commit to release
189
+ needs: [resolve]
190
+ # `release` is skipped outside main pushes, and a skipped ancestor skips everything
191
+ # downstream unless the condition says otherwise -- hence `!cancelled()`.
192
+ if: ${{ !cancelled() && needs.resolve.result == 'success' && needs.resolve.outputs.proceed == 'true' }}
193
+ runs-on: ubuntu-24.04
194
+ steps:
195
+ - uses: actions/checkout@v5
196
+ with:
197
+ ref: ${{ needs.resolve.outputs.ref }}
198
+ - name: the version in the tag must be the version in the package
199
+ if: needs.resolve.outputs.publish == 'true'
200
+ env:
201
+ TAG: ${{ needs.resolve.outputs.version }}
202
+ run: |
203
+ PKG=$(python3 scripts/bump-cli-version.py --show)
204
+ echo "tag=$TAG package=$PKG"
205
+ test "$TAG" = "$PKG"
206
+ - uses: dtolnay/rust-toolchain@stable
207
+ with:
208
+ components: rustfmt, clippy
209
+ - run: cargo fmt --check
210
+ - run: cargo clippy --locked --all-targets --features python -- -D warnings
211
+ - run: cargo test --locked
212
+
213
+ wheels:
214
+ name: wheel (${{ matrix.os }} ${{ matrix.target }})
215
+ needs: [resolve, verify]
216
+ if: ${{ !cancelled() && needs.verify.result == 'success' }}
217
+ strategy:
218
+ matrix:
219
+ # Each wheel is built on a runner of its own architecture, so the wheel that is
220
+ # uploaded is also the one installed and tested below. abi3-py310: one wheel per
221
+ # platform serves every Python from 3.10.
222
+ include:
223
+ - { os: linux, runner: ubuntu-24.04, target: x86_64, manylinux: "2_28" }
224
+ - { os: linux, runner: ubuntu-24.04-arm, target: aarch64, manylinux: "2_28" }
225
+ - { os: macos, runner: macos-15, target: aarch64 }
226
+ - { os: macos, runner: macos-15-intel, target: x86_64 }
227
+ - { os: windows, runner: windows-2022, target: x64 }
228
+ runs-on: ${{ matrix.runner }}
229
+ steps:
230
+ - uses: actions/checkout@v5
231
+ with:
232
+ ref: ${{ needs.resolve.outputs.ref }}
233
+ - uses: PyO3/maturin-action@v1
234
+ with:
235
+ target: ${{ matrix.target }}
236
+ manylinux: ${{ matrix.manylinux || 'auto' }}
237
+ args: --release --locked --out dist
238
+ - uses: actions/setup-python@v6
239
+ with:
240
+ python-version: "3.12"
241
+ # The artifact itself, installed clean: the command, the import and the Python
242
+ # tests. The end-to-end (moto) and Hugging Face tests skip without their extras;
243
+ # ci.yml runs them on every PR.
244
+ - name: test the wheel that is about to be published
245
+ shell: bash
246
+ run: |
247
+ python -m venv "$RUNNER_TEMP/fresh"
248
+ PY="$RUNNER_TEMP/fresh/bin/python"
249
+ [ -x "$PY" ] || PY="$RUNNER_TEMP/fresh/Scripts/python.exe"
250
+ "$PY" -m pip install --quiet dist/*.whl "pytest>=8"
251
+ "$PY" -m carla_pack_registry --version
252
+ "$PY" -c "import carla_pack_registry as m; assert m.deploy_pack and m.Client and m.publish; print(m.__version__)"
253
+ "$PY" -m pytest -q -p no:cacheprovider python/tests
254
+ - uses: actions/upload-artifact@v4
255
+ with:
256
+ name: wheel-${{ matrix.os }}-${{ matrix.target }}
257
+ path: dist/*.whl
258
+
259
+ sdist:
260
+ name: sdist
261
+ needs: [resolve, verify]
262
+ if: ${{ !cancelled() && needs.verify.result == 'success' }}
263
+ runs-on: ubuntu-24.04
264
+ steps:
265
+ - uses: actions/checkout@v5
266
+ with:
267
+ ref: ${{ needs.resolve.outputs.ref }}
268
+ - uses: PyO3/maturin-action@v1
269
+ with:
270
+ command: sdist
271
+ args: --out dist
272
+ # The sdist is what lets other platforms build from source, so it is built once
273
+ # into a wheel here rather than shipped untried.
274
+ - uses: actions/setup-python@v6
275
+ with:
276
+ python-version: "3.12"
277
+ - name: build and import a wheel from the sdist
278
+ run: |
279
+ python -m venv "$RUNNER_TEMP/fresh"
280
+ "$RUNNER_TEMP/fresh/bin/python" -m pip install --quiet dist/*.tar.gz
281
+ "$RUNNER_TEMP/fresh/bin/carla-pack" --version
282
+ - uses: actions/upload-artifact@v4
283
+ with:
284
+ name: sdist
285
+ path: dist/*.tar.gz
286
+
287
+ publish:
288
+ name: publish to PyPI
289
+ needs: [resolve, wheels, sdist]
290
+ if: ${{ !cancelled() && needs.wheels.result == 'success' && needs.sdist.result == 'success' && needs.resolve.outputs.publish == 'true' }}
291
+ runs-on: ubuntu-24.04
292
+ environment:
293
+ name: pypi
294
+ url: https://pypi.org/p/carla-pack-registry
295
+ permissions:
296
+ id-token: write # Trusted Publishing; no token in secrets.
297
+ steps:
298
+ - uses: actions/download-artifact@v4
299
+ with:
300
+ pattern: wheel-*
301
+ path: dist
302
+ merge-multiple: true
303
+ - uses: actions/download-artifact@v4
304
+ with:
305
+ name: sdist
306
+ path: dist
307
+ - run: ls -l dist
308
+ # PyPI rejects metadata that names a file the archive lacks, after the build and
309
+ # the OIDC exchange; checking here first costs nothing.
310
+ - name: check the metadata before uploading
311
+ run: pipx run twine check --strict dist/*
312
+ # PyPI never replaces a file but accepts missing ones for an existing release, so
313
+ # a re-run can add what an earlier attempt failed to upload.
314
+ - uses: pypa/gh-action-pypi-publish@release/v1
315
+ with:
316
+ skip-existing: true
@@ -0,0 +1,6 @@
1
+ target/
2
+ .venv/
3
+ dist/
4
+ __pycache__/
5
+ *.so
6
+ .pytest_cache/