pin-west 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.
pin_west-0.1.0/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 urob
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 OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: pin-west
3
+ Version: 0.1.0
4
+ Summary: Pin revisions in west manifests to exact commit SHAs
5
+ Keywords: west,zephyr,zmk,manifest,pin,lockfile
6
+ Author: urob
7
+ Author-email: urob <978080+urob@users.noreply.github.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Build Tools
15
+ Classifier: Topic :: Software Development :: Embedded Systems
16
+ Classifier: Topic :: Software Development :: Version Control :: Git
17
+ Requires-Dist: west>=1.2
18
+ Requires-Dist: packaging>=23
19
+ Requires-Dist: pyyaml>=6
20
+ Requires-Python: >=3.13
21
+ Project-URL: Homepage, https://github.com/urob/pin-west
22
+ Project-URL: Repository, https://github.com/urob/pin-west
23
+ Project-URL: Issues, https://github.com/urob/pin-west/issues
24
+ Project-URL: Changelog, https://github.com/urob/pin-west/releases
25
+ Description-Content-Type: text/markdown
26
+
27
+ # pin-west
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/pin-west)](https://pypi.org/project/pin-west/)
30
+
31
+ Pin and update revisions in [west
32
+ manifests](https://docs.zephyrproject.org/latest/develop/west/manifest.html) to
33
+ exact commit SHAs.
34
+
35
+ ```diff
36
+ manifest:
37
+ projects:
38
+ - name: zephyr
39
+ - revision: 628a0d85e36938dddb6f0dfc6dc902de7359711c # v3.5.0+zmk-fixes (2025-07-10)
40
+ + revision: dacab4875df72109b96cc8977547a0dc04875bcd # v3.5.0+zmk-fixes (2026-08-18)
41
+ - name: zmk
42
+ - revision: v0.3
43
+ + revision: edf5c0814fd3ea202e43aad2d68fd32e882a518c # v0.3
44
+ - name: zmk-helpers
45
+ - revision: main
46
+ + revision: bc114546392b4615ac90a99140eaf21dde31209d # main (2026-08-18)
47
+ ```
48
+
49
+ With a few noted exceptions, `pin-west` needs neither an
50
+ initialized west workspace nor any clones. It ever only edits `revision` fields,
51
+ keeping all other formatting and comments byte-for-byte.
52
+
53
+ ## Install
54
+
55
+ **uv/pip**
56
+
57
+ pin-west is on [PyPI](https://pypi.org/project/pin-west/). With
58
+ [uv](https://docs.astral.sh/uv/), run it without installing:
59
+
60
+ ```sh
61
+ uvx pin-west check
62
+ ```
63
+
64
+ Or install it persistently:
65
+
66
+ ```sh
67
+ uv tool install pin-west # or: pipx install pin-west
68
+ ```
69
+
70
+ **nix**
71
+
72
+ With [Nix](https://nixos.org), run it without installing:
73
+
74
+ ```sh
75
+ nix run github:urob/pin-west -- check
76
+ ```
77
+
78
+ The flake also exposes `packages` and `overlays` defaults providing `pin-west`, and a `devShell`
79
+ with Python and `uv` for development.
80
+
81
+ ## Usage
82
+
83
+ By default, pin-west runs on `./west.yml` if it exists, or otherwise
84
+ — when run inside an initialized west workspace — the workspace's
85
+ configured manifest. Use `-f/--manifest` to explicitly specify the
86
+ manifest.
87
+
88
+ ```sh
89
+ # Pin every unpinned revision to the current head of its branch/tag:
90
+ pin-west pin [-f west.yml] [--dry-run]
91
+
92
+ # Inside an initialized west workspace: pin to the locally resolved
93
+ # revisions instead:
94
+ pin-west pin --local
95
+
96
+ # Also materialize and pin imported (indirect) projects into a managed
97
+ # section at the end of `projects:` (see "Imported projects" below):
98
+ pin-west pin --include-imports
99
+
100
+ # Bump projects (default: all) along what they track (see below): release
101
+ # pins to the latest release, branch/series pins to the tracked ref's head:
102
+ pin-west bump [PROJECT ...] [--dry-run]
103
+
104
+ # Constrain release-tracked bumps to the same major.minor / major series:
105
+ pin-west bump --patch # or: --minor
106
+
107
+ # Skip everything that doesn't track a release tag or series:
108
+ pin-west bump --releases-only
109
+
110
+ # Bump to an explicit branch or tag (switches what the pin tracks):
111
+ pin-west bump zephyr --ref v4.1.0+zmk-fixes
112
+
113
+ # Check that every revision is pinned to a full sha, that pinned shas exist
114
+ # on their remote, and that pins are consistent with their trailing comment
115
+ # (when one exists). Exit non-zero on any failure:
116
+ pin-west check
117
+
118
+ # Flags select a subset of the checks; e.g. only the pin check:
119
+ pin-west check --pinned # or: --shas, --comments
120
+ ```
121
+
122
+ Commands that talk to the GitHub API (`bump` and `check`) find a token via
123
+ `--gh-token`, then `$GITHUB_TOKEN` / `$GH_TOKEN`, then `gh auth token`; without
124
+ one, unauthenticated requests are rate-limited to 60/hour. Non-GitHub remotes
125
+ work throughout — they just skip the release lookup and the ancestry check.
126
+
127
+ ## Tracking
128
+
129
+ Pinned revisions get a trailing comment recording what they track. If a
130
+ tracking comment exists, `bump` uses it to infer the declared update scope
131
+ as follows:
132
+
133
+ - **Exact release** (`# v0.3.0`): bump to the latest release (limited by
134
+ `--patch`/`--minor` if specified). Targets *older* than the pin are
135
+ skipped, and an exact release tag that no longer points at the pinned commit
136
+ triggers a warning and holds the pin — release tags shouldn't move; use
137
+ `--ref` to force the move.
138
+ - **Floating release** (`# v0.3`, when refined tags like `v0.3.x` exist):
139
+ follow the alias tag wherever it moves; the comment keeps the alias.
140
+ - **Branch** (`# main (date)`): follow the branch head. Scope flags don't
141
+ apply and are ignored with a warning.
142
+
143
+ Pinned projects **without a tracking comment** are interpreted as exact releases
144
+ if a matching release tag exists (see above), and otherwise fall back to
145
+ latest-release → highest version tag → default branch.
146
+
147
+ **Unpinned projects** infer the declared intent from the manifest's `revision`
148
+ field. Names that are both a branch and a tag resolve to the tag.
149
+
150
+ **Explicit scopes:** `bump --ref GITREF` overwrites the inferred update scope
151
+ with `GITREF` (e.g., `main` or `v0.3`).
152
+
153
+ **Auditing tracking comments:** `check --comments` audits the tracking comments:
154
+ exact-release pins must match the tag's commit, floating-release pins must pin a
155
+ member of the release series, and branch pins must be ancestors of the branch's
156
+ head (GitHub only).
157
+
158
+ ## Pinning indirect dependencies
159
+
160
+ By default, only projects explicitly specified in the manifest are pinned or
161
+ updated. Use `pin --include-imports` to resolve and lock the entire manifest
162
+ instead.
163
+
164
+ This will embed a dependency section into the manifest, turning it into a
165
+ self-contained lockfile. Any future `pin-west` runs will continue locking
166
+ dependencies, re-resolving them when their parent project is re-pinned or
167
+ updated (a selective `bump PROJECT` only refreshes dependencies in the
168
+ tree of that project).
169
+
170
+ Deleting the dependency section in the manifest turns off dependency locking
171
+ (until re-enabled with `--include-imports`).
172
+
173
+ **Submanifests:** Pinning dependencies introduced by `self: import:`
174
+ requires running in an initialized workspace. Resolving an *imported*
175
+ project's submanifests (e.g. zephyr's) further requires that project's
176
+ clone to be checked out at its pin. Otherwise, submanifest dependencies
177
+ remain unpinned until a `west update` + `pin-west pin` cycle locks them.
@@ -0,0 +1,151 @@
1
+ # pin-west
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/pin-west)](https://pypi.org/project/pin-west/)
4
+
5
+ Pin and update revisions in [west
6
+ manifests](https://docs.zephyrproject.org/latest/develop/west/manifest.html) to
7
+ exact commit SHAs.
8
+
9
+ ```diff
10
+ manifest:
11
+ projects:
12
+ - name: zephyr
13
+ - revision: 628a0d85e36938dddb6f0dfc6dc902de7359711c # v3.5.0+zmk-fixes (2025-07-10)
14
+ + revision: dacab4875df72109b96cc8977547a0dc04875bcd # v3.5.0+zmk-fixes (2026-08-18)
15
+ - name: zmk
16
+ - revision: v0.3
17
+ + revision: edf5c0814fd3ea202e43aad2d68fd32e882a518c # v0.3
18
+ - name: zmk-helpers
19
+ - revision: main
20
+ + revision: bc114546392b4615ac90a99140eaf21dde31209d # main (2026-08-18)
21
+ ```
22
+
23
+ With a few noted exceptions, `pin-west` needs neither an
24
+ initialized west workspace nor any clones. It ever only edits `revision` fields,
25
+ keeping all other formatting and comments byte-for-byte.
26
+
27
+ ## Install
28
+
29
+ **uv/pip**
30
+
31
+ pin-west is on [PyPI](https://pypi.org/project/pin-west/). With
32
+ [uv](https://docs.astral.sh/uv/), run it without installing:
33
+
34
+ ```sh
35
+ uvx pin-west check
36
+ ```
37
+
38
+ Or install it persistently:
39
+
40
+ ```sh
41
+ uv tool install pin-west # or: pipx install pin-west
42
+ ```
43
+
44
+ **nix**
45
+
46
+ With [Nix](https://nixos.org), run it without installing:
47
+
48
+ ```sh
49
+ nix run github:urob/pin-west -- check
50
+ ```
51
+
52
+ The flake also exposes `packages` and `overlays` defaults providing `pin-west`, and a `devShell`
53
+ with Python and `uv` for development.
54
+
55
+ ## Usage
56
+
57
+ By default, pin-west runs on `./west.yml` if it exists, or otherwise
58
+ — when run inside an initialized west workspace — the workspace's
59
+ configured manifest. Use `-f/--manifest` to explicitly specify the
60
+ manifest.
61
+
62
+ ```sh
63
+ # Pin every unpinned revision to the current head of its branch/tag:
64
+ pin-west pin [-f west.yml] [--dry-run]
65
+
66
+ # Inside an initialized west workspace: pin to the locally resolved
67
+ # revisions instead:
68
+ pin-west pin --local
69
+
70
+ # Also materialize and pin imported (indirect) projects into a managed
71
+ # section at the end of `projects:` (see "Imported projects" below):
72
+ pin-west pin --include-imports
73
+
74
+ # Bump projects (default: all) along what they track (see below): release
75
+ # pins to the latest release, branch/series pins to the tracked ref's head:
76
+ pin-west bump [PROJECT ...] [--dry-run]
77
+
78
+ # Constrain release-tracked bumps to the same major.minor / major series:
79
+ pin-west bump --patch # or: --minor
80
+
81
+ # Skip everything that doesn't track a release tag or series:
82
+ pin-west bump --releases-only
83
+
84
+ # Bump to an explicit branch or tag (switches what the pin tracks):
85
+ pin-west bump zephyr --ref v4.1.0+zmk-fixes
86
+
87
+ # Check that every revision is pinned to a full sha, that pinned shas exist
88
+ # on their remote, and that pins are consistent with their trailing comment
89
+ # (when one exists). Exit non-zero on any failure:
90
+ pin-west check
91
+
92
+ # Flags select a subset of the checks; e.g. only the pin check:
93
+ pin-west check --pinned # or: --shas, --comments
94
+ ```
95
+
96
+ Commands that talk to the GitHub API (`bump` and `check`) find a token via
97
+ `--gh-token`, then `$GITHUB_TOKEN` / `$GH_TOKEN`, then `gh auth token`; without
98
+ one, unauthenticated requests are rate-limited to 60/hour. Non-GitHub remotes
99
+ work throughout — they just skip the release lookup and the ancestry check.
100
+
101
+ ## Tracking
102
+
103
+ Pinned revisions get a trailing comment recording what they track. If a
104
+ tracking comment exists, `bump` uses it to infer the declared update scope
105
+ as follows:
106
+
107
+ - **Exact release** (`# v0.3.0`): bump to the latest release (limited by
108
+ `--patch`/`--minor` if specified). Targets *older* than the pin are
109
+ skipped, and an exact release tag that no longer points at the pinned commit
110
+ triggers a warning and holds the pin — release tags shouldn't move; use
111
+ `--ref` to force the move.
112
+ - **Floating release** (`# v0.3`, when refined tags like `v0.3.x` exist):
113
+ follow the alias tag wherever it moves; the comment keeps the alias.
114
+ - **Branch** (`# main (date)`): follow the branch head. Scope flags don't
115
+ apply and are ignored with a warning.
116
+
117
+ Pinned projects **without a tracking comment** are interpreted as exact releases
118
+ if a matching release tag exists (see above), and otherwise fall back to
119
+ latest-release → highest version tag → default branch.
120
+
121
+ **Unpinned projects** infer the declared intent from the manifest's `revision`
122
+ field. Names that are both a branch and a tag resolve to the tag.
123
+
124
+ **Explicit scopes:** `bump --ref GITREF` overwrites the inferred update scope
125
+ with `GITREF` (e.g., `main` or `v0.3`).
126
+
127
+ **Auditing tracking comments:** `check --comments` audits the tracking comments:
128
+ exact-release pins must match the tag's commit, floating-release pins must pin a
129
+ member of the release series, and branch pins must be ancestors of the branch's
130
+ head (GitHub only).
131
+
132
+ ## Pinning indirect dependencies
133
+
134
+ By default, only projects explicitly specified in the manifest are pinned or
135
+ updated. Use `pin --include-imports` to resolve and lock the entire manifest
136
+ instead.
137
+
138
+ This will embed a dependency section into the manifest, turning it into a
139
+ self-contained lockfile. Any future `pin-west` runs will continue locking
140
+ dependencies, re-resolving them when their parent project is re-pinned or
141
+ updated (a selective `bump PROJECT` only refreshes dependencies in the
142
+ tree of that project).
143
+
144
+ Deleting the dependency section in the manifest turns off dependency locking
145
+ (until re-enabled with `--include-imports`).
146
+
147
+ **Submanifests:** Pinning dependencies introduced by `self: import:`
148
+ requires running in an initialized workspace. Resolving an *imported*
149
+ project's submanifests (e.g. zephyr's) further requires that project's
150
+ clone to be checked out at its pin. Otherwise, submanifest dependencies
151
+ remain unpinned until a `west update` + `pin-west pin` cycle locks them.
@@ -0,0 +1,57 @@
1
+ [project]
2
+ name = "pin-west"
3
+ version = "0.1.0"
4
+ description = "Pin revisions in west manifests to exact commit SHAs"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "west",
10
+ "zephyr",
11
+ "zmk",
12
+ "manifest",
13
+ "pin",
14
+ "lockfile",
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Software Development :: Build Tools",
22
+ "Topic :: Software Development :: Embedded Systems",
23
+ "Topic :: Software Development :: Version Control :: Git",
24
+ ]
25
+ requires-python = ">=3.13"
26
+ dependencies = [
27
+ "west>=1.2",
28
+ "packaging>=23",
29
+ "pyyaml>=6",
30
+ ]
31
+
32
+ [[project.authors]]
33
+ name = "urob"
34
+ email = "978080+urob@users.noreply.github.com"
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/urob/pin-west"
38
+ Repository = "https://github.com/urob/pin-west"
39
+ Issues = "https://github.com/urob/pin-west/issues"
40
+ Changelog = "https://github.com/urob/pin-west/releases"
41
+
42
+ [project.scripts]
43
+ pin-west = "pin_west:main"
44
+
45
+ [build-system]
46
+ requires = ["uv_build>=0.12.5,<0.13.0"]
47
+ build-backend = "uv_build"
48
+
49
+ [tool.uv.build-backend]
50
+ source-include = ["tests/**"]
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "pytest>=9.1.1",
55
+ "ruff>=0.16.3",
56
+ "ty>=0.0.72",
57
+ ]
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "pin-west"
3
+ version = "0.1.0"
4
+ description = "Pin revisions in west manifests to exact commit SHAs"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "urob", email = "978080+urob@users.noreply.github.com" }
10
+ ]
11
+ keywords = ["west", "zephyr", "zmk", "manifest", "pin", "lockfile"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Environment :: Console",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3.13",
17
+ "Topic :: Software Development :: Build Tools",
18
+ "Topic :: Software Development :: Embedded Systems",
19
+ "Topic :: Software Development :: Version Control :: Git",
20
+ ]
21
+ requires-python = ">=3.13"
22
+ dependencies = [
23
+ "west>=1.2",
24
+ "packaging>=23",
25
+ "pyyaml>=6",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/urob/pin-west"
30
+ Repository = "https://github.com/urob/pin-west"
31
+ Issues = "https://github.com/urob/pin-west/issues"
32
+ Changelog = "https://github.com/urob/pin-west/releases"
33
+
34
+ [project.scripts]
35
+ pin-west = "pin_west:main"
36
+
37
+ [build-system]
38
+ requires = ["uv_build>=0.12.5,<0.13.0"]
39
+ build-backend = "uv_build"
40
+
41
+ [tool.uv.build-backend]
42
+ # Ship the suite in the sdist so downstream packagers (nixpkgs, distros) can
43
+ # run it against the released artifact rather than a git checkout.
44
+ source-include = ["tests/**"]
45
+
46
+ [dependency-groups]
47
+ dev = [
48
+ "pytest>=9.1.1",
49
+ "ruff>=0.16.3",
50
+ "ty>=0.0.72",
51
+ ]
@@ -0,0 +1,3 @@
1
+ from .cli import __version__, main
2
+
3
+ __all__ = ["__version__", "main"]