container-image-dist-ref 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.
Files changed (74) hide show
  1. container_image_dist_ref-0.4.0/.clippy.toml +5 -0
  2. container_image_dist_ref-0.4.0/.editorconfig +18 -0
  3. container_image_dist_ref-0.4.0/.gitattributes +1 -0
  4. container_image_dist_ref-0.4.0/.github/FUNDING.yaml +1 -0
  5. container_image_dist_ref-0.4.0/.github/workflows/python-release.yml +160 -0
  6. container_image_dist_ref-0.4.0/.github/workflows/python.yml +67 -0
  7. container_image_dist_ref-0.4.0/.github/workflows/rust.yml +63 -0
  8. container_image_dist_ref-0.4.0/.gitignore +18 -0
  9. container_image_dist_ref-0.4.0/.rustfmt.toml +3 -0
  10. container_image_dist_ref-0.4.0/ARCHITECTURE.md +55 -0
  11. container_image_dist_ref-0.4.0/Cargo.lock +566 -0
  12. container_image_dist_ref-0.4.0/Cargo.toml +32 -0
  13. container_image_dist_ref-0.4.0/LICENSE +201 -0
  14. container_image_dist_ref-0.4.0/Makefile +81 -0
  15. container_image_dist_ref-0.4.0/PKG-INFO +26 -0
  16. container_image_dist_ref-0.4.0/README.md +134 -0
  17. container_image_dist_ref-0.4.0/benches/basic_benchmark.rs +39 -0
  18. container_image_dist_ref-0.4.0/bindings/python/Cargo.lock +137 -0
  19. container_image_dist_ref-0.4.0/bindings/python/Cargo.toml +20 -0
  20. container_image_dist_ref-0.4.0/bindings/python/README.md +13 -0
  21. container_image_dist_ref-0.4.0/bindings/python/src/lib.rs +617 -0
  22. container_image_dist_ref-0.4.0/bindings/python/tests/test_bindings.py +348 -0
  23. container_image_dist_ref-0.4.0/bindings/python/tests/test_fixtures.py +74 -0
  24. container_image_dist_ref-0.4.0/bindings/python/uv.lock +262 -0
  25. container_image_dist_ref-0.4.0/examples/parse_canonical.rs +43 -0
  26. container_image_dist_ref-0.4.0/examples/parse_stdin.rs +49 -0
  27. container_image_dist_ref-0.4.0/grammars/digest.diff +9 -0
  28. container_image_dist_ref-0.4.0/grammars/digest_algorithm.diff +6 -0
  29. container_image_dist_ref-0.4.0/grammars/digest_encoded.diff +4 -0
  30. container_image_dist_ref-0.4.0/grammars/host_or_path.ebnf +9 -0
  31. container_image_dist_ref-0.4.0/grammars/host_subset.ebnf +5 -0
  32. container_image_dist_ref-0.4.0/grammars/oci_digest.ebnf +5 -0
  33. container_image_dist_ref-0.4.0/grammars/oci_name.ebnf +3 -0
  34. container_image_dist_ref-0.4.0/grammars/reference.ebnf +20 -0
  35. container_image_dist_ref-0.4.0/pyproject.toml +35 -0
  36. container_image_dist_ref-0.4.0/python/container_image_dist_ref/__init__.py +52 -0
  37. container_image_dist_ref-0.4.0/python/container_image_dist_ref/_native.pyi +113 -0
  38. container_image_dist_ref-0.4.0/python/container_image_dist_ref/py.typed +0 -0
  39. container_image_dist_ref-0.4.0/rust-toolchain.toml +5 -0
  40. container_image_dist_ref-0.4.0/scripts/check_release_versions.sh +35 -0
  41. container_image_dist_ref-0.4.0/scripts/diff_digest.sh +37 -0
  42. container_image_dist_ref-0.4.0/scripts/diff_digest_algorithm.sh +6 -0
  43. container_image_dist_ref-0.4.0/scripts/diff_digest_encoded.sh +4 -0
  44. container_image_dist_ref-0.4.0/scripts/fetch_dist_ref_grammar.sh +69 -0
  45. container_image_dist_ref-0.4.0/scripts/fetch_oci_digest_grammar.sh +17 -0
  46. container_image_dist_ref-0.4.0/scripts/fetch_oci_name_grammar.sh +40 -0
  47. container_image_dist_ref-0.4.0/scripts/host_subset.sh +3 -0
  48. container_image_dist_ref-0.4.0/scripts/lines.sh +9 -0
  49. container_image_dist_ref-0.4.0/scripts/prepare_release.sh +11 -0
  50. container_image_dist_ref-0.4.0/scripts/shout.sh +707 -0
  51. container_image_dist_ref-0.4.0/scripts/subset_host_or_path.sh +3 -0
  52. container_image_dist_ref-0.4.0/src/ambiguous/domain_or_tagged_ref.rs +213 -0
  53. container_image_dist_ref-0.4.0/src/ambiguous/host_or_path.rs +429 -0
  54. container_image_dist_ref-0.4.0/src/ambiguous/mod.rs +6 -0
  55. container_image_dist_ref-0.4.0/src/ambiguous/port_or_tag.rs +182 -0
  56. container_image_dist_ref-0.4.0/src/digest/algorithm.rs +244 -0
  57. container_image_dist_ref-0.4.0/src/digest/encoded.rs +198 -0
  58. container_image_dist_ref-0.4.0/src/digest/mod.rs +183 -0
  59. container_image_dist_ref-0.4.0/src/err.rs +132 -0
  60. container_image_dist_ref-0.4.0/src/lib.rs +915 -0
  61. container_image_dist_ref-0.4.0/src/name/domain/host.rs +156 -0
  62. container_image_dist_ref-0.4.0/src/name/domain/ipv6.rs +222 -0
  63. container_image_dist_ref-0.4.0/src/name/domain/mod.rs +215 -0
  64. container_image_dist_ref-0.4.0/src/name/domain/port.rs +45 -0
  65. container_image_dist_ref-0.4.0/src/name/domain/valid_ipv6.tsv +16 -0
  66. container_image_dist_ref-0.4.0/src/name/mod.rs +74 -0
  67. container_image_dist_ref-0.4.0/src/name/path.rs +300 -0
  68. container_image_dist_ref-0.4.0/src/span.rs +172 -0
  69. container_image_dist_ref-0.4.0/src/tag.rs +130 -0
  70. container_image_dist_ref-0.4.0/tests/fixtures/README.md +4 -0
  71. container_image_dist_ref-0.4.0/tests/fixtures/references/invalid/inputs.txt +13 -0
  72. container_image_dist_ref-0.4.0/tests/fixtures/references/outputs.tsv +46 -0
  73. container_image_dist_ref-0.4.0/tests/fixtures/references/valid/inputs.txt +32 -0
  74. container_image_dist_ref-0.4.0/tests/fixtures/references/xfail.txt +1 -0
@@ -0,0 +1,5 @@
1
+ # see https://doc.rust-lang.org/stable/clippy/configuration.html
2
+ # see https://rust-lang.github.io/rust-clippy/master/index.html#Configuration
3
+ arithmetic-side-effects-allowed = [
4
+ "usize",
5
+ ] # we're never going to overflow something that large
@@ -0,0 +1,18 @@
1
+ [*]
2
+ indent_size = 2
3
+ indent_style = space
4
+ trim_trailing_whitespace = true
5
+ insert_final_newline = true
6
+ charset = utf-8
7
+
8
+ [*.rs]
9
+ indent_size = 4
10
+
11
+ [*.py]
12
+ indent_size = 4
13
+
14
+ [Makefile]
15
+ indent_style = tab
16
+
17
+ [*.{go,tsv}]
18
+ indent_style = tab
@@ -0,0 +1 @@
1
+ flake.lock linguist-generated=true
@@ -0,0 +1 @@
1
+ github: skalt
@@ -0,0 +1,160 @@
1
+ name: Release Python
2
+
3
+ # Pushing a tag like v0.3.0 builds the sdist and platform wheels and publishes
4
+ # them to PyPI with trusted publishing. Manual runs publish the same artifacts
5
+ # to TestPyPI, which is useful for checking the release pipeline.
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ concurrency:
15
+ group: python-release-${{ github.ref }}
16
+ cancel-in-progress: false
17
+
18
+ env:
19
+ CARGO_TERM_COLOR: always
20
+
21
+ jobs:
22
+ # Publishing must be gated on the Rust and Python workflows passing. GitHub
23
+ # Actions has no cross-workflow `needs`, so they are exposed as reusable
24
+ # workflows and called here.
25
+ rust:
26
+ name: Rust checks
27
+ uses: ./.github/workflows/rust.yml
28
+ permissions:
29
+ contents: read
30
+ issues: write
31
+
32
+ python:
33
+ name: Python checks
34
+ uses: ./.github/workflows/python.yml
35
+
36
+ sdist:
37
+ name: Build sdist
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/checkout@v7
41
+ - name: Verify package versions match the tag
42
+ if: startsWith(github.ref, 'refs/tags/')
43
+ run: ./scripts/check_release_versions.sh
44
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
45
+ with:
46
+ enable-cache: false
47
+ - uses: dtolnay/rust-toolchain@stable
48
+ - name: Build sdist
49
+ run: uv build --sdist --out-dir dist
50
+ working-directory: bindings/python
51
+ - uses: actions/upload-artifact@v7
52
+ with:
53
+ name: wheels-sdist
54
+ path: bindings/python/dist/*.tar.gz
55
+ if-no-files-found: error
56
+
57
+ wheels:
58
+ name: Build ${{ matrix.name }} wheel
59
+ runs-on: ${{ matrix.os }}
60
+ strategy:
61
+ fail-fast: true
62
+ # Where the `target` values come from:
63
+ # https://doc.rust-lang.org/nightly/rustc/platform-support.html
64
+ # (or run `rustc --print target-list`).
65
+ # maturin-action `target` and `manylinux` inputs:
66
+ # https://github.com/PyO3/maturin-action#inputs
67
+ # manylinux and musllinux tags:
68
+ # https://github.com/PyO3/maturin-action#manylinux-docker-container
69
+ matrix:
70
+ include:
71
+ - name: linux-x86_64
72
+ os: ubuntu-latest
73
+ target: x86_64-unknown-linux-gnu
74
+ manylinux: "2_17"
75
+ - name: linux-aarch64
76
+ os: ubuntu-latest
77
+ target: aarch64-unknown-linux-gnu
78
+ manylinux: "2_17"
79
+ - name: musllinux-x86_64
80
+ os: ubuntu-latest
81
+ target: x86_64-unknown-linux-musl
82
+ manylinux: "musllinux_1_2"
83
+ - name: musllinux-aarch64
84
+ os: ubuntu-latest
85
+ target: aarch64-unknown-linux-musl
86
+ manylinux: "musllinux_1_2"
87
+ - name: macos-x86_64
88
+ os: macos-15-intel
89
+ target: x86_64-apple-darwin
90
+ manylinux: "auto"
91
+ - name: macos-arm64
92
+ os: macos-latest
93
+ target: aarch64-apple-darwin
94
+ manylinux: "auto"
95
+ - name: windows-x86_64
96
+ os: windows-latest
97
+ target: x86_64-pc-windows-msvc
98
+ manylinux: "auto"
99
+ steps:
100
+ - uses: actions/checkout@v7
101
+ - uses: actions/setup-python@v7
102
+ with:
103
+ python-version: "3.11"
104
+ - name: Build wheel
105
+ uses: PyO3/maturin-action@v1
106
+ with:
107
+ command: build
108
+ target: ${{ matrix.target }}
109
+ manylinux: ${{ matrix.manylinux }}
110
+ args: --release --locked --compatibility pypi --out dist
111
+ working-directory: bindings/python
112
+ - uses: actions/upload-artifact@v7
113
+ with:
114
+ name: wheels-${{ matrix.name }}
115
+ path: bindings/python/dist/*.whl
116
+ if-no-files-found: error
117
+
118
+ publish-pypi:
119
+ name: Publish to PyPI
120
+ needs: [rust, python, sdist, wheels]
121
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
122
+ runs-on: ubuntu-latest
123
+ environment:
124
+ name: pypi
125
+ url: https://pypi.org/project/container-image-dist-ref/
126
+ permissions:
127
+ id-token: write
128
+ steps:
129
+ - uses: actions/download-artifact@v8
130
+ with:
131
+ pattern: wheels-*
132
+ merge-multiple: true
133
+ path: dist
134
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
135
+ with:
136
+ enable-cache: false
137
+ - name: Publish to PyPI
138
+ run: uv publish --trusted-publishing always 'dist/*'
139
+
140
+ publish-testpypi:
141
+ name: Publish to TestPyPI
142
+ needs: [rust, python, sdist, wheels]
143
+ if: github.event_name == 'workflow_dispatch'
144
+ runs-on: ubuntu-latest
145
+ environment:
146
+ name: testpypi
147
+ url: https://test.pypi.org/project/container_image_dist_ref/
148
+ permissions:
149
+ id-token: write
150
+ steps:
151
+ - uses: actions/download-artifact@v8
152
+ with:
153
+ pattern: wheels-*
154
+ merge-multiple: true
155
+ path: dist
156
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
157
+ with:
158
+ enable-cache: false
159
+ - name: Publish to TestPyPI
160
+ run: uv publish --trusted-publishing always --publish-url https://test.pypi.org/legacy/ --check-url https://test.pypi.org/simple/ 'dist/*'
@@ -0,0 +1,67 @@
1
+ name: Python
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+ # Lets release.yml run these checks before publishing.
9
+ workflow_call:
10
+
11
+ env:
12
+ CARGO_TERM_COLOR: always
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+ concurrency:
18
+ group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
19
+ cancel-in-progress: true
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ python-version: ["3.11", "3.16"]
24
+ steps:
25
+ - uses: actions/checkout@v7
26
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+ enable-cache: true
30
+ cache-dependency-glob: bindings/python/uv.lock
31
+ - uses: dtolnay/rust-toolchain@stable
32
+ - name: Install the package and dev dependencies
33
+ run: uv sync --locked --group dev
34
+ working-directory: bindings/python
35
+ - name: Check formatting
36
+ run: uv run --locked ruff format --check .
37
+ working-directory: bindings/python
38
+ - name: Run tests
39
+ run: uv run --locked pytest tests -q
40
+ working-directory: bindings/python
41
+
42
+ wheel:
43
+ name: Test built wheel
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v7
47
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
48
+ with:
49
+ python-version: "3.13"
50
+ enable-cache: true
51
+ cache-dependency-glob: bindings/python/uv.lock
52
+ - uses: dtolnay/rust-toolchain@stable
53
+ - name: Build wheel
54
+ uses: PyO3/maturin-action@v1
55
+ with:
56
+ command: build
57
+ args: --release --locked --out dist
58
+ working-directory: bindings/python
59
+ manylinux: auto
60
+ - name: Install wheel and pytest with uv
61
+ run: |
62
+ uv venv
63
+ uv pip install dist/*.whl pytest
64
+ working-directory: bindings/python
65
+ - name: Run tests against the installed wheel
66
+ run: uv run --no-project pytest tests -q
67
+ working-directory: bindings/python
@@ -0,0 +1,63 @@
1
+ name: Rust
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+ # Lets release.yml run these checks before publishing.
9
+ workflow_call:
10
+
11
+ env:
12
+ CARGO_TERM_COLOR: always
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ concurrency:
18
+ group: ${{ github.workflow }}-${{ github.ref }}
19
+ cancel-in-progress: true
20
+ permissions:
21
+ issues: write # required for peter-evans/create-issue-from-file
22
+ steps:
23
+ - uses: actions/checkout@v7
24
+ - name: Build
25
+ run: cargo build --verbose
26
+ - name: Clippy
27
+ run: cargo clippy
28
+ - name: fmt
29
+ run: cargo fmt --check
30
+ - name: Run tests
31
+ run: cargo test --verbose
32
+ - name: Build (release)
33
+ run: cargo build --release --verbose
34
+ - name: Run tests (release)
35
+ run: cargo test --release --verbose
36
+ - name: build docs
37
+ run: cargo doc
38
+
39
+ - name: Restore lychee cache
40
+ uses: actions/cache@v4
41
+ with:
42
+ path: .lycheecache
43
+ key: cache-lychee-${{ github.sha }}
44
+ restore-keys: cache-lychee-
45
+
46
+ - name: Link Checker
47
+ id: lychee
48
+ uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # 2.9.0
49
+ # see https://github.com/lycheeverse/lychee-action
50
+ with:
51
+ args: --verbose --no-progress --cache --max-cache-age 1d --exclude=./target/package .
52
+ fail: false
53
+ format: markdown
54
+ output: ./lychee/out.md
55
+ jobSummary: true
56
+
57
+ - name: Create Issue From File
58
+ if: steps.lychee.outputs.exit_code != 0
59
+ uses: peter-evans/create-issue-from-file@v5
60
+ with:
61
+ title: Link Checker Report
62
+ content-filepath: ./lychee/out.md
63
+ labels: report, automated issue
@@ -0,0 +1,18 @@
1
+ .direnv
2
+ target
3
+ result*
4
+ # ./result* is owned by `nix build`.
5
+ # see https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-build
6
+ **/testdata/fuzz/*
7
+
8
+ # scratch files
9
+ temp*
10
+ .cache
11
+
12
+ # python bindings
13
+ __pycache__/
14
+ *.py[cod]
15
+ .venv/
16
+ .pytest_cache/
17
+ bindings/python/dist/
18
+ bindings/python/*.egg-info/
@@ -0,0 +1,3 @@
1
+ # https://rust-lang.github.io/rustfmt/
2
+ newline_style = "Unix"
3
+ use_try_shorthand = true
@@ -0,0 +1,55 @@
1
+ # Architecture
2
+
3
+ This document records this project's design principles.
4
+ Inspired by https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html
5
+
6
+ ## Fun optimizations
7
+
8
+ The speed and memory footprint of image reference parsing is highly unlikely to ever matter to a program handling gigabytes of images.
9
+ However, optimizing the parsing is fun, and fun is encouraged in this repository.
10
+
11
+ ### Parse ascii bytes
12
+
13
+ This library takes an input ascii string (a slice of bytes) and parses the lengths of each of the sections of an image reference.
14
+ Using ascii only avoids allocating unicode `char`s which each weigh 4 bytes.
15
+
16
+ <!-- I learned this optimization from the `regex` crate! -->
17
+
18
+ ### Avoid backtracking
19
+
20
+ Re-parsing bytes costs time and memory.
21
+ Peeking one byte ahead is ok.
22
+ Re-parsing sections on error to find an invalid character is also ok as long as the benchmarks don't regress.
23
+
24
+ ### Keep only one copy of a string slice
25
+
26
+ `&str`s are expensive: they cost 2 `usize`s.
27
+ Prefer holding one `&str` and many short lengths in-memory, then splitting new `&str`s using the lengths on-demand.
28
+
29
+ ### Store short lengths
30
+
31
+ Use the smallest unsigned integer size that can represent the length of a section of an image reference.
32
+ Since most sections of an image reference are under 255 ascii characters long, most lengths can be represented using a `u8`.
33
+ The encoded section of the digest is technically unbounded, but practically can be measured with a `u16`.
34
+
35
+ ### All lengths are implicitly optional
36
+
37
+ Since all lengths can be 0, treat 0 as the `None` value rather than using extra space for an `Option<Length>`.
38
+ Temporarily converting a length to an `Option<length>` is ok, since it's roughly equivalent to using a temporary bool while checking `len == 0`.
39
+
40
+ <!-- I'm not 100% on the Option<L>/bool equivalence, but I do know it's cheap -->
41
+
42
+ ### debug mode
43
+
44
+ Record invariants using `debug_assert!(..)` instead of `assert!(..)` to avoid extra computation in release mode.
45
+ Put extra debugging variables behind [`#[cfg(debug_assertions)]` conditional-compilation](https://doc.rust-lang.org/reference/conditional-compilation.html#debug_assertions) macros.
46
+
47
+ ### 0 dependencies
48
+
49
+ To keep the library size small and keep ownership of all of the relevant logic.
50
+
51
+ I chose not to use the excellent [`regex` crate](https://github.com/rust-lang/regex) since:
52
+
53
+ 1. writing the parsers as pure functions avoids issues of [cross-thread resource contention](https://docs.rs/regex/latest/regex/#sharing-a-regex-across-threads-can-result-in-contention).
54
+ 1. I _think_ `regex` relies on pointer-sized offsets for capture groups, which cancels out the short-length optimizations. A scan through the `regex` and `regex-automata` docs and issues didn't reveal a way to use `u8`s .
55
+ If you know a way to get `regex` to use custom offset sizes, please let me know in [this repo's issues](https://github.com/SKalt/container_image_dist_ref/issues)!