pyselfupdate 0.7.0__tar.gz → 0.8.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.
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/PKG-INFO +10 -4
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/README.md +9 -3
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/github.py +4 -7
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/install.py +21 -10
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/updater.py +3 -1
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/.gitignore +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/LICENSE +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/pyproject.toml +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/__init__.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/config.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/errors.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/notifier.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/py.typed +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/source.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/state.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/typercmd.py +0 -0
- {pyselfupdate-0.7.0 → pyselfupdate-0.8.0}/src/pyselfupdate/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyselfupdate
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Self-update and update notification for Python CLIs installed with uv tool
|
|
5
5
|
Project-URL: Repository, https://github.com/datapointchris/pyselfupdate
|
|
6
6
|
Project-URL: Issues, https://github.com/datapointchris/pyselfupdate/issues
|
|
@@ -49,8 +49,9 @@ uv add pyselfupdate # the library alone, with no dependencies
|
|
|
49
49
|
uv add 'pyselfupdate[typer]' # adds typer and the ready-made `update` command
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
The supported Python versions are `requires-python` in `pyproject.toml`, which
|
|
53
|
+
uv checks before it installs. The floor is the first release carrying
|
|
54
|
+
`tomllib`.
|
|
54
55
|
|
|
55
56
|
## Starting from scratch
|
|
56
57
|
|
|
@@ -124,7 +125,7 @@ Nothing is printed when any of these hold:
|
|
|
124
125
|
| `NO_AUTO_UPDATE` or `MYTOOL_NO_AUTO_UPDATE` is set | Opted out |
|
|
125
126
|
| `--help` or `-h` comes before any `--` on the command line | typer runs the callback even for a subcommand's help screen, which is not work |
|
|
126
127
|
| stdout or stderr is not a terminal | `mytool list > out 2>&1` must stay clean |
|
|
127
|
-
|
|
|
128
|
+
| A variable in `pyselfupdate.notifier.CI_VARIABLES`, such as `CI`, is set | Not a human |
|
|
128
129
|
| Installed from a local path, an editable checkout, a branch or a commit | Nothing to compare against |
|
|
129
130
|
| Checked within the interval | One request per interval, not per invocation |
|
|
130
131
|
|
|
@@ -229,6 +230,11 @@ later `uv tool upgrade` stays held to them.
|
|
|
229
230
|
| Carries none | Installs unlocked and sets `lock_missing`. `lock_warning` names the tag, and `run_update` and `update_and_reexec` print it |
|
|
230
231
|
| Will not clone, uv will not export its lock, or git or uv is not on `PATH` | Raises `LockUnreadableError` and installs nothing |
|
|
231
232
|
|
|
233
|
+
A tool that is one member of a uv workspace installs as
|
|
234
|
+
`git+<repo>@<tag>#subdirectory=<member>`. `update` keeps the subdirectory, and
|
|
235
|
+
reads the workspace's one `uv.lock` at the repository root for that member's
|
|
236
|
+
dependencies alone.
|
|
237
|
+
|
|
232
238
|
An update reinstalls the tool's own extras, as in `mytool[fast]`, with their
|
|
233
239
|
dependencies held to the lock. Every `--with` and `--with-editable`
|
|
234
240
|
requirement is passed back to uv as well.
|
|
@@ -26,8 +26,9 @@ uv add pyselfupdate # the library alone, with no dependencies
|
|
|
26
26
|
uv add 'pyselfupdate[typer]' # adds typer and the ready-made `update` command
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
The supported Python versions are `requires-python` in `pyproject.toml`, which
|
|
30
|
+
uv checks before it installs. The floor is the first release carrying
|
|
31
|
+
`tomllib`.
|
|
31
32
|
|
|
32
33
|
## Starting from scratch
|
|
33
34
|
|
|
@@ -101,7 +102,7 @@ Nothing is printed when any of these hold:
|
|
|
101
102
|
| `NO_AUTO_UPDATE` or `MYTOOL_NO_AUTO_UPDATE` is set | Opted out |
|
|
102
103
|
| `--help` or `-h` comes before any `--` on the command line | typer runs the callback even for a subcommand's help screen, which is not work |
|
|
103
104
|
| stdout or stderr is not a terminal | `mytool list > out 2>&1` must stay clean |
|
|
104
|
-
|
|
|
105
|
+
| A variable in `pyselfupdate.notifier.CI_VARIABLES`, such as `CI`, is set | Not a human |
|
|
105
106
|
| Installed from a local path, an editable checkout, a branch or a commit | Nothing to compare against |
|
|
106
107
|
| Checked within the interval | One request per interval, not per invocation |
|
|
107
108
|
|
|
@@ -206,6 +207,11 @@ later `uv tool upgrade` stays held to them.
|
|
|
206
207
|
| Carries none | Installs unlocked and sets `lock_missing`. `lock_warning` names the tag, and `run_update` and `update_and_reexec` print it |
|
|
207
208
|
| Will not clone, uv will not export its lock, or git or uv is not on `PATH` | Raises `LockUnreadableError` and installs nothing |
|
|
208
209
|
|
|
210
|
+
A tool that is one member of a uv workspace installs as
|
|
211
|
+
`git+<repo>@<tag>#subdirectory=<member>`. `update` keeps the subdirectory, and
|
|
212
|
+
reads the workspace's one `uv.lock` at the repository root for that member's
|
|
213
|
+
dependencies alone.
|
|
214
|
+
|
|
209
215
|
An update reinstalls the tool's own extras, as in `mytool[fast]`, with their
|
|
210
216
|
dependencies held to the lock. Every `--with` and `--with-editable`
|
|
211
217
|
requirement is passed back to uv as well.
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"""GitHub as a release source.
|
|
2
2
|
|
|
3
|
-
Uses `urllib.request
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
It moves to httpx2 when this package needs a second request shape: a client
|
|
9
|
-
object, streaming, an asset download.
|
|
3
|
+
Uses `urllib.request`, because the package has no runtime dependencies. The
|
|
4
|
+
HTTP client weighed against that, and when to revisit it, are under the
|
|
5
|
+
zero-dependency constraint in the repository's CLAUDE.md.
|
|
6
|
+
`_CredentialScopedRedirects` covers the redirect hazard a client would.
|
|
10
7
|
"""
|
|
11
8
|
|
|
12
9
|
from __future__ import annotations
|
|
@@ -78,6 +78,10 @@ class Installation:
|
|
|
78
78
|
# or refuses it.
|
|
79
79
|
revision: str = ''
|
|
80
80
|
|
|
81
|
+
# The directory inside the repository holding the tool's project, for a
|
|
82
|
+
# uv workspace member installed with `#subdirectory=`. Empty at the root.
|
|
83
|
+
subdirectory: str = ''
|
|
84
|
+
|
|
81
85
|
extras: tuple[str, ...] = ()
|
|
82
86
|
|
|
83
87
|
# The receipt's other requirements, from `--with` and `--with-editable`, as
|
|
@@ -157,9 +161,9 @@ def read_installation(tool: str) -> Installation:
|
|
|
157
161
|
else:
|
|
158
162
|
rebuilt.append(line)
|
|
159
163
|
|
|
160
|
-
def installed_as(kind: InstallKind, url: str = '', revision: str = '') -> Installation:
|
|
164
|
+
def installed_as(kind: InstallKind, url: str = '', revision: str = '', subdirectory: str = '') -> Installation:
|
|
161
165
|
extras = tuple(own.get('extras') or ())
|
|
162
|
-
return Installation(tool, kind, url, revision, extras, tuple(rebuilt), _source_flags(recorded), tuple(unrebuildable))
|
|
166
|
+
return Installation(tool, kind, url, revision, subdirectory, extras, tuple(rebuilt), _source_flags(recorded), tuple(unrebuildable))
|
|
163
167
|
|
|
164
168
|
# A local checkout, however uv spelled it. Reinstalling one would
|
|
165
169
|
# discard the working copy the user is developing against.
|
|
@@ -170,7 +174,8 @@ def read_installation(tool: str) -> Installation:
|
|
|
170
174
|
git = own.get('git')
|
|
171
175
|
if git:
|
|
172
176
|
url, query, _ = _split_git(str(git))
|
|
173
|
-
|
|
177
|
+
subdirectory = query.get('subdirectory') or str(own.get('subdirectory') or '')
|
|
178
|
+
return installed_as(InstallKind.GIT, url=url, revision=query.get('rev', ''), subdirectory=subdirectory)
|
|
174
179
|
|
|
175
180
|
return installed_as(InstallKind.INDEX)
|
|
176
181
|
|
|
@@ -328,7 +333,8 @@ def requirement_for(installation: Installation, ref: str) -> str:
|
|
|
328
333
|
"""
|
|
329
334
|
named = f'{installation.tool}[{",".join(installation.extras)}]' if installation.extras else installation.tool
|
|
330
335
|
if installation.kind is InstallKind.GIT:
|
|
331
|
-
|
|
336
|
+
subdirectory = f'#subdirectory={installation.subdirectory}' if installation.subdirectory else ''
|
|
337
|
+
return f'{named} @ git+{installation.url}@{ref}{subdirectory}'
|
|
332
338
|
return f'{named}>={ref.removeprefix("v")}'
|
|
333
339
|
|
|
334
340
|
|
|
@@ -361,7 +367,7 @@ class Pins:
|
|
|
361
367
|
return flags
|
|
362
368
|
|
|
363
369
|
|
|
364
|
-
def read_lock(url: str, ref: str, *, extras: Sequence[str] = ()) -> Pins | None:
|
|
370
|
+
def read_lock(url: str, ref: str, *, extras: Sequence[str] = (), package: str = '', subdirectory: str = '') -> Pins | None:
|
|
365
371
|
"""What the `uv.lock` at `ref` of a git repository pins, or None when it has none.
|
|
366
372
|
|
|
367
373
|
`extras` are the extras the tool is installed with. Each is passed to
|
|
@@ -369,6 +375,10 @@ def read_lock(url: str, ref: str, *, extras: Sequence[str] = ()) -> Pins | None:
|
|
|
369
375
|
dependencies out. `--all-extras` fails on a project that declares two
|
|
370
376
|
extras as conflicting.
|
|
371
377
|
|
|
378
|
+
`subdirectory` names a uv workspace member, whose lock sits at the
|
|
379
|
+
repository root. The export then takes only `package`'s dependencies, and
|
|
380
|
+
the extras walk starts at that member.
|
|
381
|
+
|
|
372
382
|
Reads a shallow clone of the one ref and lets `uv export` interpret the lock.
|
|
373
383
|
The lock is also read directly for one thing the export drops: the extras
|
|
374
384
|
a dependent requests of a git dependency, which `_override_extras` restores.
|
|
@@ -400,7 +410,8 @@ def read_lock(url: str, ref: str, *, extras: Sequence[str] = ()) -> Pins | None:
|
|
|
400
410
|
lock = checkout / LOCK_NAME
|
|
401
411
|
if not lock.is_file():
|
|
402
412
|
return None
|
|
403
|
-
|
|
413
|
+
member = ('--package', package) if subdirectory and package else ()
|
|
414
|
+
export = [uv, *EXPORT, *member, *chain.from_iterable(('--extra', extra) for extra in extras)]
|
|
404
415
|
try:
|
|
405
416
|
exported = run_command(export, cwd=checkout, timeout=LOCK_READ_TIMEOUT_SECONDS)
|
|
406
417
|
except subprocess.TimeoutExpired as error:
|
|
@@ -408,14 +419,14 @@ def read_lock(url: str, ref: str, *, extras: Sequence[str] = ()) -> Pins | None:
|
|
|
408
419
|
if exported.returncode != 0:
|
|
409
420
|
raise LockUnreadableError(f'uv export would not read the uv.lock at {ref}: {_reason(exported)}')
|
|
410
421
|
try:
|
|
411
|
-
requested = _override_extras(tomllib.loads(lock.read_text(encoding='utf-8')), extras)
|
|
422
|
+
requested = _override_extras(tomllib.loads(lock.read_text(encoding='utf-8')), extras, root=subdirectory or '.')
|
|
412
423
|
except (OSError, tomllib.TOMLDecodeError) as error:
|
|
413
424
|
raise LockUnreadableError(f'cannot read the uv.lock at {ref}: {error}') from error
|
|
414
425
|
return _pins_from_export(exported.stdout, requested)
|
|
415
426
|
|
|
416
427
|
|
|
417
|
-
def _override_extras(lock: dict, extras: Sequence[str]) -> dict[str, tuple[str, ...]]:
|
|
418
|
-
"""The extras requested of each package, walking dependency edges from the project at the lock
|
|
428
|
+
def _override_extras(lock: dict, extras: Sequence[str], root: str = '.') -> dict[str, tuple[str, ...]]:
|
|
429
|
+
"""The extras requested of each package, walking dependency edges from the project at `root` in the lock.
|
|
419
430
|
|
|
420
431
|
An override replaces a requirement whole, extras included, and `uv export`
|
|
421
432
|
writes `gitdep @ git+...` where the tool declared `gitdep[x] @ git+...`.
|
|
@@ -430,7 +441,7 @@ def _override_extras(lock: dict, extras: Sequence[str]) -> dict[str, tuple[str,
|
|
|
430
441
|
packages: dict[str, list[dict]] = {}
|
|
431
442
|
for package in lock.get('package') or []:
|
|
432
443
|
packages.setdefault(package.get('name', ''), []).append(package)
|
|
433
|
-
project = ({'editable':
|
|
444
|
+
project = ({'editable': root}, {'virtual': root})
|
|
434
445
|
roots: list[str] = []
|
|
435
446
|
for name, entries in packages.items():
|
|
436
447
|
roots.extend(name for package in entries if package.get('source') in project)
|
|
@@ -167,7 +167,9 @@ def install_release(config: Config, result: Result, installation: Installation,
|
|
|
167
167
|
|
|
168
168
|
if installation.kind is InstallKind.GIT:
|
|
169
169
|
ref = result.release.install_ref()
|
|
170
|
-
pins = read_lock(
|
|
170
|
+
pins = read_lock(
|
|
171
|
+
installation.url, ref, extras=installation.extras, package=installation.tool, subdirectory=installation.subdirectory
|
|
172
|
+
)
|
|
171
173
|
else:
|
|
172
174
|
ref, pins = result.latest, None
|
|
173
175
|
run_install(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|