uv-metadata 1.0.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.
- uv_metadata-1.0.0/.claude/settings.json +17 -0
- uv_metadata-1.0.0/.github/workflows/release.yml +27 -0
- uv_metadata-1.0.0/.github/workflows/tests.yml +40 -0
- uv_metadata-1.0.0/.gitignore +18 -0
- uv_metadata-1.0.0/CLAUDE.md +72 -0
- uv_metadata-1.0.0/LICENSE +21 -0
- uv_metadata-1.0.0/PKG-INFO +205 -0
- uv_metadata-1.0.0/README.md +191 -0
- uv_metadata-1.0.0/pyproject.toml +66 -0
- uv_metadata-1.0.0/setup.cfg +4 -0
- uv_metadata-1.0.0/tests/conftest.py +7 -0
- uv_metadata-1.0.0/tests/requirements.txt +2 -0
- uv_metadata-1.0.0/tests/sample-dist/colorama-0.1.zip +0 -0
- uv_metadata-1.0.0/tests/sample-dist/mock-0.6.0.tar.gz +0 -0
- uv_metadata-1.0.0/tests/sample-dist/uv_metadata-1.0.0-py3-none-any.whl +0 -0
- uv_metadata-1.0.0/tests/sample-dist/uv_metadata-1.0.0.tar.gz +0 -0
- uv_metadata-1.0.0/tests/test_cli.py +152 -0
- uv_metadata-1.0.0/tox.ini +45 -0
- uv_metadata-1.0.0/uv-metadata-spec.md +104 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/PKG-INFO +205 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/SOURCES.txt +24 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/dependency_links.txt +1 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/entry_points.txt +2 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/requires.txt +3 -0
- uv_metadata-1.0.0/uv_metadata.egg-info/top_level.txt +1 -0
- uv_metadata-1.0.0/uv_metadata.py +409 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(.venv/bin/pytest *)",
|
|
5
|
+
"Bash(.venv/bin/uv-metadata *)",
|
|
6
|
+
"Bash(uv pip *)",
|
|
7
|
+
"Bash(tox *)",
|
|
8
|
+
"Bash(ruff *)",
|
|
9
|
+
"Bash(.tox/typecheck/bin/pyright *)",
|
|
10
|
+
"Bash(git log *)",
|
|
11
|
+
"Bash(git diff *)",
|
|
12
|
+
"Bash(git status *)",
|
|
13
|
+
"Bash(git branch *)",
|
|
14
|
+
"Bash(git show *)"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v[0-9]*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: release
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write # mandatory for trusted publishing
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
|
+
- uses: actions/setup-python@v6
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.14"
|
|
22
|
+
|
|
23
|
+
- uses: astral-sh/setup-uv@v8.0.0
|
|
24
|
+
- run: uvx --with tox-uv tox -e py,style
|
|
25
|
+
- run: uv build
|
|
26
|
+
- name: Publish to PyPI
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
- uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- uses: astral-sh/setup-uv@v8.0.0
|
|
24
|
+
- run: uv venv
|
|
25
|
+
- run: uv pip install -U tox-uv
|
|
26
|
+
- run: .venv/bin/tox -e py
|
|
27
|
+
|
|
28
|
+
linters:
|
|
29
|
+
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v6
|
|
34
|
+
- uses: actions/setup-python@v6
|
|
35
|
+
with:
|
|
36
|
+
python-version: "3.14"
|
|
37
|
+
- uses: astral-sh/setup-uv@v8.0.0
|
|
38
|
+
- run: uv venv
|
|
39
|
+
- run: uv pip install -U tox-uv
|
|
40
|
+
- run: .venv/bin/tox -e style
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
Single-file CLI tool (`uv_metadata.py`) that inspects Python package metadata without installing.
|
|
8
|
+
Published on PyPI as `uv-metadata`, runnable via `uvx uv-metadata`. Requires `uv` on PATH.
|
|
9
|
+
|
|
10
|
+
## Commands
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
# Run all checks (tests on py311+py314, coverage, ruff, pyright)
|
|
14
|
+
tox
|
|
15
|
+
|
|
16
|
+
# Run tests only (single Python version)
|
|
17
|
+
tox -e py311
|
|
18
|
+
|
|
19
|
+
# Run a single test
|
|
20
|
+
.venv/bin/pytest tests/test_cli.py::test_package -xvs
|
|
21
|
+
|
|
22
|
+
# Lint and format check
|
|
23
|
+
tox -e style
|
|
24
|
+
|
|
25
|
+
# Auto-fix lint/format
|
|
26
|
+
tox -e reformat
|
|
27
|
+
|
|
28
|
+
# Type check
|
|
29
|
+
tox -e typecheck
|
|
30
|
+
|
|
31
|
+
# Run the tool locally
|
|
32
|
+
.venv/bin/uv-metadata requests
|
|
33
|
+
.venv/bin/uv-metadata .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
All logic lives in `uv_metadata.py`. The flow is:
|
|
39
|
+
|
|
40
|
+
1. **`main()`** — CLI entry point (argparse), calls `get_metadata_from_pip_spec()`
|
|
41
|
+
2. **`get_metadata_from_pip_spec()`** — routes input to the right extraction strategy:
|
|
42
|
+
- Local files (.whl/.zip/.tar.gz) → `extract_metadata_from_file()` → `ZipReader`/`TarReader`
|
|
43
|
+
- Local dist-info/egg-info dir → `extract_metadata_from_dist_info()`
|
|
44
|
+
- Local project folder → `extract_metadata_from_project_folder()` (PEP 517 build)
|
|
45
|
+
- Git/URL refs → `extract_metadata_from_uv_install()` (temp install via uv)
|
|
46
|
+
- Plain package names → `extract_metadata_from_uv_resolve()` (fast: resolve + stream wheel metadata via HTTP range requests, fallback: download sdist)
|
|
47
|
+
3. **All paths converge** on `extract_metadata_from_dist_info()` which uses `importlib.metadata.PathDistribution`
|
|
48
|
+
|
|
49
|
+
Key design details:
|
|
50
|
+
- Archive extraction uses a `MetadataReader` ABC with `ZipReader` and `TarReader` subclasses (context managers)
|
|
51
|
+
- Two compiled regexes (`_INFO_DIR_RX`, `_ROOT_PKG_INFO_RX`) drive metadata file discovery, built from the `METADATA_FILES` tuple
|
|
52
|
+
- `PKG-INFO` files are renamed to `METADATA` before reading so `PathDistribution` handles both formats
|
|
53
|
+
- `UNKNOWN` sentinel values from old metadata are filtered out
|
|
54
|
+
- `description` (long description) is stripped by default; `--full` flag preserves it
|
|
55
|
+
- `canonical_git_url()` accepts plain GitHub HTTPS URLs and `git@` SSH shorthand
|
|
56
|
+
|
|
57
|
+
## Testing
|
|
58
|
+
|
|
59
|
+
Tests use the `runez` library's `ClickRunner` fixture (`cli`). The pattern is:
|
|
60
|
+
```python
|
|
61
|
+
def test_example(cli):
|
|
62
|
+
cli.run("requests", "-kversion")
|
|
63
|
+
assert cli.succeeded
|
|
64
|
+
payload = json.loads(cli.logged.stdout.contents())
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Test fixtures in `tests/sample-dist/` include real archived packages (colorama, mock, uv-metadata itself).
|
|
68
|
+
|
|
69
|
+
## Versioning
|
|
70
|
+
|
|
71
|
+
Uses `setuptools-scm` with `local_scheme = "dirty-tag"`. Version is derived from git tags (`v*`).
|
|
72
|
+
Release workflow triggers on tag push, publishes to PyPI via trusted publishing.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Zoran Simic
|
|
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 THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uv-metadata
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Inspect any Python package metadata without installing
|
|
5
|
+
Author: Zoran Simic
|
|
6
|
+
Project-URL: Homepage, https://github.com/zsimic/uv-metadata
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: build
|
|
11
|
+
Requires-Dist: pyproject-hooks
|
|
12
|
+
Requires-Dist: seekablehttpfile
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# uv-metadata
|
|
16
|
+
|
|
17
|
+
Inspect any Python package metadata from any source without installing.
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
$ uvx uv-metadata requests -kversion
|
|
21
|
+
2.32.4
|
|
22
|
+
|
|
23
|
+
$ uvx uv-metadata requests -krequires_python
|
|
24
|
+
>=3.10
|
|
25
|
+
|
|
26
|
+
$ uvx uv-metadata 'pip<23' -kversion
|
|
27
|
+
22.3.1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Works with published packages, local wheels/sdists, project folders, and git repos.
|
|
31
|
+
For published packages, metadata is streamed directly from the remote wheel via HTTP range
|
|
32
|
+
requests — typically a few KB, no full download needed.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Why this is useful
|
|
36
|
+
|
|
37
|
+
Getting package metadata as JSON from a simple CLI opens up a lot of possibilities:
|
|
38
|
+
|
|
39
|
+
- **Scripting**: what's the latest version of a package? What about the last 2.x release?
|
|
40
|
+
What's the latest version that still supports Python 3.7?
|
|
41
|
+
(`uvx uv-metadata -p3.7 setuptools -kversion`)
|
|
42
|
+
- **Validation**: CI checks that verify your package metadata is complete before publishing —
|
|
43
|
+
are author, URL, license, classifiers all present?
|
|
44
|
+
- **Verifying your own project**: after setting up dynamic versioning (e.g. `setuptools-scm`),
|
|
45
|
+
just run `uvx uv-metadata .` to confirm your metadata looks right — no need to build or install
|
|
46
|
+
- **Dependency auditing**: quickly check what a package requires, what Python versions it supports,
|
|
47
|
+
or what entry points it exposes — all without installing anything
|
|
48
|
+
|
|
49
|
+
This project also serves as a reference implementation for a proposed native
|
|
50
|
+
[`uv metadata`](https://github.com/zsimic/uv-metadata/blob/main/uv-metadata-spec.md) subcommand
|
|
51
|
+
(see [astral-sh/uv#6037](https://github.com/astral-sh/uv/issues/6037) and the [spec](https://github.com/zsimic/uv-metadata/blob/main/uv-metadata-spec.md)).
|
|
52
|
+
|
|
53
|
+
Requires `uv` on `PATH`.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
# Run directly (no install needed)
|
|
60
|
+
uvx uv-metadata requests
|
|
61
|
+
|
|
62
|
+
# Or install permanently
|
|
63
|
+
uv tool install uv-metadata
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Quick examples
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
# Full metadata as JSON
|
|
71
|
+
uvx uv-metadata flask
|
|
72
|
+
|
|
73
|
+
# Single key
|
|
74
|
+
uvx uv-metadata flask -kversion
|
|
75
|
+
|
|
76
|
+
# Version constraint
|
|
77
|
+
uvx uv-metadata 'flask<3' -kversion
|
|
78
|
+
|
|
79
|
+
# Local project
|
|
80
|
+
uvx uv-metadata .
|
|
81
|
+
|
|
82
|
+
# Local wheel or sdist
|
|
83
|
+
uvx uv-metadata ./dist/mypackage-1.0.0-py3-none-any.whl
|
|
84
|
+
|
|
85
|
+
# Git repo
|
|
86
|
+
uvx uv-metadata git+https://github.com/psf/requests@main
|
|
87
|
+
|
|
88
|
+
# Target a specific Python version
|
|
89
|
+
uvx uv-metadata numpy -p3.9 -kversion
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Input routing
|
|
94
|
+
|
|
95
|
+
| Input | Strategy |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `.`, `./path`, `/abs/path`, or any existing filesystem path | |
|
|
98
|
+
|  directory with `pyproject.toml` or `setup.py` | Build metadata via PEP 517 |
|
|
99
|
+
|  `*.dist-info` or `*.egg-info` directory | Read directly |
|
|
100
|
+
|  `*.whl` or `*.zip` file | Extract from zip archive |
|
|
101
|
+
|  `*.tar.gz` file | Extract from tarball |
|
|
102
|
+
| `git+https://...`, `git@...`, or `pkg @ url` | Install to temp dir, read dist-info |
|
|
103
|
+
| plain name or version constraint (`name`, `name>=x`, etc.) | Resolve via uv, stream dist-info from remote wheel; fall back to downloading sdist |
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## Output format
|
|
107
|
+
|
|
108
|
+
JSON with sorted keys. The `description` (long description) field is omitted by default
|
|
109
|
+
as it is typically very large; use `--full` to include it.
|
|
110
|
+
|
|
111
|
+
```shell
|
|
112
|
+
$ uvx uv-metadata pip
|
|
113
|
+
{
|
|
114
|
+
"author_email": "The pip developers <distutils-sig@python.org>",
|
|
115
|
+
"classifiers": [
|
|
116
|
+
"Development Status :: 5 - Production/Stable",
|
|
117
|
+
...
|
|
118
|
+
],
|
|
119
|
+
"description_content_type": "text/x-rst",
|
|
120
|
+
"entry_points": {
|
|
121
|
+
"console_scripts": {
|
|
122
|
+
"pip": "pip._internal.cli.main:main",
|
|
123
|
+
"pip3": "pip._internal.cli.main:main"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"license_expression": "MIT",
|
|
127
|
+
"metadata_version": "2.4",
|
|
128
|
+
"name": "pip",
|
|
129
|
+
"project_url": [
|
|
130
|
+
"Documentation, https://pip.pypa.io",
|
|
131
|
+
"Source, https://github.com/pypa/pip"
|
|
132
|
+
],
|
|
133
|
+
"requires_python": ">=3.9",
|
|
134
|
+
"summary": "The PyPA recommended tool for installing Python packages.",
|
|
135
|
+
"version": "26.0.1"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Structural rules:
|
|
140
|
+
- Keys are `lower_snake_case`
|
|
141
|
+
- Single-occurrence fields: plain string
|
|
142
|
+
- Multi-occurrence fields: list of strings
|
|
143
|
+
- `entry_points`: `{"group": {"name": "module:attr"}}`
|
|
144
|
+
- `top_level`: list of top-level importable names
|
|
145
|
+
- `UNKNOWN` values are omitted
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
## CLI reference
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
usage: uv-metadata [-h] [-p PYTHON] [-k KEY] [--full] [package]
|
|
152
|
+
|
|
153
|
+
Output the metadata of a package, in machine-readable format
|
|
154
|
+
|
|
155
|
+
positional arguments:
|
|
156
|
+
package Package to inspect (default: current folder)
|
|
157
|
+
|
|
158
|
+
options:
|
|
159
|
+
-h, --help show this help message and exit
|
|
160
|
+
-p, --python PYTHON Python version to target (e.g. 3.11)
|
|
161
|
+
-k, --key KEY Show only this key from the metadata
|
|
162
|
+
--full Include full description in output
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## How it works
|
|
167
|
+
|
|
168
|
+
### Fast path for published packages
|
|
169
|
+
|
|
170
|
+
1. `uv pip compile --format pylock.toml` resolves to a concrete wheel URL without downloading
|
|
171
|
+
2. `SeekableHttpFile` + `ZipFile` streams only the dist-info files via HTTP range requests
|
|
172
|
+
3. Falls back to downloading the sdist when no wheel is available
|
|
173
|
+
|
|
174
|
+
### Unified metadata reading
|
|
175
|
+
|
|
176
|
+
All extraction strategies produce a dist-info folder which is read by
|
|
177
|
+
`importlib.metadata.PathDistribution`. Both `METADATA` (wheels) and `PKG-INFO` (sdists)
|
|
178
|
+
are handled transparently.
|
|
179
|
+
|
|
180
|
+
### Archive extraction
|
|
181
|
+
|
|
182
|
+
A `MetadataReader` base class with `ZipReader` and `TarReader` implementations provides
|
|
183
|
+
uniform member discovery and extraction across archive formats.
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## Dependencies
|
|
187
|
+
|
|
188
|
+
| Package | Purpose |
|
|
189
|
+
|---|---|
|
|
190
|
+
| [`build`](https://pypi.org/project/build/) | PEP 517 metadata building for local project folders |
|
|
191
|
+
| [`pyproject-hooks`](https://pypi.org/project/pyproject-hooks/) | Quiet subprocess runner used by `build` |
|
|
192
|
+
| [`seekablehttpfile`](https://pypi.org/project/seekablehttpfile/) | HTTP range requests for streaming dist-info from remote wheels |
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
## Relevant PEPs
|
|
196
|
+
|
|
197
|
+
- [PEP 241](https://peps.python.org/pep-0241/) – Metadata for Python Software Packages 1.0
|
|
198
|
+
- [PEP 314](https://peps.python.org/pep-0314/) – Metadata for Python Software Packages 1.1
|
|
199
|
+
- [PEP 345](https://peps.python.org/pep-0345/) – Metadata for Python Software Packages 1.2
|
|
200
|
+
- [PEP 566](https://peps.python.org/pep-0566/) – Metadata for Python Software Packages 2.1
|
|
201
|
+
- [PEP 508](https://peps.python.org/pep-0508/) – Dependency specification for Python Software Packages
|
|
202
|
+
- [PEP 517](https://peps.python.org/pep-0517/) – A build-system independent format for source trees
|
|
203
|
+
- [PEP 643](https://peps.python.org/pep-0643/) – Metadata for Package Source Distributions
|
|
204
|
+
- [PEP 658](https://peps.python.org/pep-0658/) – Serve Distribution Metadata in the Simple Repository API
|
|
205
|
+
- [PEP 639](https://peps.python.org/pep-0639/) – Improving License Clarity with Better Package Metadata
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# uv-metadata
|
|
2
|
+
|
|
3
|
+
Inspect any Python package metadata from any source without installing.
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
$ uvx uv-metadata requests -kversion
|
|
7
|
+
2.32.4
|
|
8
|
+
|
|
9
|
+
$ uvx uv-metadata requests -krequires_python
|
|
10
|
+
>=3.10
|
|
11
|
+
|
|
12
|
+
$ uvx uv-metadata 'pip<23' -kversion
|
|
13
|
+
22.3.1
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Works with published packages, local wheels/sdists, project folders, and git repos.
|
|
17
|
+
For published packages, metadata is streamed directly from the remote wheel via HTTP range
|
|
18
|
+
requests — typically a few KB, no full download needed.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Why this is useful
|
|
22
|
+
|
|
23
|
+
Getting package metadata as JSON from a simple CLI opens up a lot of possibilities:
|
|
24
|
+
|
|
25
|
+
- **Scripting**: what's the latest version of a package? What about the last 2.x release?
|
|
26
|
+
What's the latest version that still supports Python 3.7?
|
|
27
|
+
(`uvx uv-metadata -p3.7 setuptools -kversion`)
|
|
28
|
+
- **Validation**: CI checks that verify your package metadata is complete before publishing —
|
|
29
|
+
are author, URL, license, classifiers all present?
|
|
30
|
+
- **Verifying your own project**: after setting up dynamic versioning (e.g. `setuptools-scm`),
|
|
31
|
+
just run `uvx uv-metadata .` to confirm your metadata looks right — no need to build or install
|
|
32
|
+
- **Dependency auditing**: quickly check what a package requires, what Python versions it supports,
|
|
33
|
+
or what entry points it exposes — all without installing anything
|
|
34
|
+
|
|
35
|
+
This project also serves as a reference implementation for a proposed native
|
|
36
|
+
[`uv metadata`](https://github.com/zsimic/uv-metadata/blob/main/uv-metadata-spec.md) subcommand
|
|
37
|
+
(see [astral-sh/uv#6037](https://github.com/astral-sh/uv/issues/6037) and the [spec](https://github.com/zsimic/uv-metadata/blob/main/uv-metadata-spec.md)).
|
|
38
|
+
|
|
39
|
+
Requires `uv` on `PATH`.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
# Run directly (no install needed)
|
|
46
|
+
uvx uv-metadata requests
|
|
47
|
+
|
|
48
|
+
# Or install permanently
|
|
49
|
+
uv tool install uv-metadata
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Quick examples
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
# Full metadata as JSON
|
|
57
|
+
uvx uv-metadata flask
|
|
58
|
+
|
|
59
|
+
# Single key
|
|
60
|
+
uvx uv-metadata flask -kversion
|
|
61
|
+
|
|
62
|
+
# Version constraint
|
|
63
|
+
uvx uv-metadata 'flask<3' -kversion
|
|
64
|
+
|
|
65
|
+
# Local project
|
|
66
|
+
uvx uv-metadata .
|
|
67
|
+
|
|
68
|
+
# Local wheel or sdist
|
|
69
|
+
uvx uv-metadata ./dist/mypackage-1.0.0-py3-none-any.whl
|
|
70
|
+
|
|
71
|
+
# Git repo
|
|
72
|
+
uvx uv-metadata git+https://github.com/psf/requests@main
|
|
73
|
+
|
|
74
|
+
# Target a specific Python version
|
|
75
|
+
uvx uv-metadata numpy -p3.9 -kversion
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Input routing
|
|
80
|
+
|
|
81
|
+
| Input | Strategy |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `.`, `./path`, `/abs/path`, or any existing filesystem path | |
|
|
84
|
+
|  directory with `pyproject.toml` or `setup.py` | Build metadata via PEP 517 |
|
|
85
|
+
|  `*.dist-info` or `*.egg-info` directory | Read directly |
|
|
86
|
+
|  `*.whl` or `*.zip` file | Extract from zip archive |
|
|
87
|
+
|  `*.tar.gz` file | Extract from tarball |
|
|
88
|
+
| `git+https://...`, `git@...`, or `pkg @ url` | Install to temp dir, read dist-info |
|
|
89
|
+
| plain name or version constraint (`name`, `name>=x`, etc.) | Resolve via uv, stream dist-info from remote wheel; fall back to downloading sdist |
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Output format
|
|
93
|
+
|
|
94
|
+
JSON with sorted keys. The `description` (long description) field is omitted by default
|
|
95
|
+
as it is typically very large; use `--full` to include it.
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
$ uvx uv-metadata pip
|
|
99
|
+
{
|
|
100
|
+
"author_email": "The pip developers <distutils-sig@python.org>",
|
|
101
|
+
"classifiers": [
|
|
102
|
+
"Development Status :: 5 - Production/Stable",
|
|
103
|
+
...
|
|
104
|
+
],
|
|
105
|
+
"description_content_type": "text/x-rst",
|
|
106
|
+
"entry_points": {
|
|
107
|
+
"console_scripts": {
|
|
108
|
+
"pip": "pip._internal.cli.main:main",
|
|
109
|
+
"pip3": "pip._internal.cli.main:main"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"license_expression": "MIT",
|
|
113
|
+
"metadata_version": "2.4",
|
|
114
|
+
"name": "pip",
|
|
115
|
+
"project_url": [
|
|
116
|
+
"Documentation, https://pip.pypa.io",
|
|
117
|
+
"Source, https://github.com/pypa/pip"
|
|
118
|
+
],
|
|
119
|
+
"requires_python": ">=3.9",
|
|
120
|
+
"summary": "The PyPA recommended tool for installing Python packages.",
|
|
121
|
+
"version": "26.0.1"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Structural rules:
|
|
126
|
+
- Keys are `lower_snake_case`
|
|
127
|
+
- Single-occurrence fields: plain string
|
|
128
|
+
- Multi-occurrence fields: list of strings
|
|
129
|
+
- `entry_points`: `{"group": {"name": "module:attr"}}`
|
|
130
|
+
- `top_level`: list of top-level importable names
|
|
131
|
+
- `UNKNOWN` values are omitted
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## CLI reference
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
usage: uv-metadata [-h] [-p PYTHON] [-k KEY] [--full] [package]
|
|
138
|
+
|
|
139
|
+
Output the metadata of a package, in machine-readable format
|
|
140
|
+
|
|
141
|
+
positional arguments:
|
|
142
|
+
package Package to inspect (default: current folder)
|
|
143
|
+
|
|
144
|
+
options:
|
|
145
|
+
-h, --help show this help message and exit
|
|
146
|
+
-p, --python PYTHON Python version to target (e.g. 3.11)
|
|
147
|
+
-k, --key KEY Show only this key from the metadata
|
|
148
|
+
--full Include full description in output
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
## How it works
|
|
153
|
+
|
|
154
|
+
### Fast path for published packages
|
|
155
|
+
|
|
156
|
+
1. `uv pip compile --format pylock.toml` resolves to a concrete wheel URL without downloading
|
|
157
|
+
2. `SeekableHttpFile` + `ZipFile` streams only the dist-info files via HTTP range requests
|
|
158
|
+
3. Falls back to downloading the sdist when no wheel is available
|
|
159
|
+
|
|
160
|
+
### Unified metadata reading
|
|
161
|
+
|
|
162
|
+
All extraction strategies produce a dist-info folder which is read by
|
|
163
|
+
`importlib.metadata.PathDistribution`. Both `METADATA` (wheels) and `PKG-INFO` (sdists)
|
|
164
|
+
are handled transparently.
|
|
165
|
+
|
|
166
|
+
### Archive extraction
|
|
167
|
+
|
|
168
|
+
A `MetadataReader` base class with `ZipReader` and `TarReader` implementations provides
|
|
169
|
+
uniform member discovery and extraction across archive formats.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Dependencies
|
|
173
|
+
|
|
174
|
+
| Package | Purpose |
|
|
175
|
+
|---|---|
|
|
176
|
+
| [`build`](https://pypi.org/project/build/) | PEP 517 metadata building for local project folders |
|
|
177
|
+
| [`pyproject-hooks`](https://pypi.org/project/pyproject-hooks/) | Quiet subprocess runner used by `build` |
|
|
178
|
+
| [`seekablehttpfile`](https://pypi.org/project/seekablehttpfile/) | HTTP range requests for streaming dist-info from remote wheels |
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
## Relevant PEPs
|
|
182
|
+
|
|
183
|
+
- [PEP 241](https://peps.python.org/pep-0241/) – Metadata for Python Software Packages 1.0
|
|
184
|
+
- [PEP 314](https://peps.python.org/pep-0314/) – Metadata for Python Software Packages 1.1
|
|
185
|
+
- [PEP 345](https://peps.python.org/pep-0345/) – Metadata for Python Software Packages 1.2
|
|
186
|
+
- [PEP 566](https://peps.python.org/pep-0566/) – Metadata for Python Software Packages 2.1
|
|
187
|
+
- [PEP 508](https://peps.python.org/pep-0508/) – Dependency specification for Python Software Packages
|
|
188
|
+
- [PEP 517](https://peps.python.org/pep-0517/) – A build-system independent format for source trees
|
|
189
|
+
- [PEP 643](https://peps.python.org/pep-0643/) – Metadata for Package Source Distributions
|
|
190
|
+
- [PEP 658](https://peps.python.org/pep-0658/) – Serve Distribution Metadata in the Simple Repository API
|
|
191
|
+
- [PEP 639](https://peps.python.org/pep-0639/) – Improving License Clarity with Better Package Metadata
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "setuptools-scm"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.setuptools_scm]
|
|
6
|
+
local_scheme = "dirty-tag"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "uv-metadata"
|
|
10
|
+
dynamic = ["version"]
|
|
11
|
+
description = "Inspect any Python package metadata without installing"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
authors = [{name = "Zoran Simic"}]
|
|
15
|
+
urls = {Homepage = "https://github.com/zsimic/uv-metadata"}
|
|
16
|
+
dependencies = [
|
|
17
|
+
"build",
|
|
18
|
+
"pyproject-hooks", # dependency of build but imported so stated here
|
|
19
|
+
"seekablehttpfile", # HTTP range requests for streaming remote wheel metadata
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
uv-metadata = "uv_metadata:main"
|
|
24
|
+
|
|
25
|
+
[tool.ruff]
|
|
26
|
+
cache-dir = ".tox/.ruff_cache"
|
|
27
|
+
line-length = 140
|
|
28
|
+
|
|
29
|
+
[tool.ruff.lint]
|
|
30
|
+
extend-select = [
|
|
31
|
+
"B", # flake8-bugbear
|
|
32
|
+
"C4", # flake8-comprehensions
|
|
33
|
+
"C90", # mccabe
|
|
34
|
+
"E", # pycodestyle errors
|
|
35
|
+
"ERA", # eradicate
|
|
36
|
+
"EXE", # flake8-executable
|
|
37
|
+
"F", # pyflakes
|
|
38
|
+
"FLY", # flynt
|
|
39
|
+
"G", # flake8-logging-format
|
|
40
|
+
"I", # isort
|
|
41
|
+
"INT", # flake8-gettext
|
|
42
|
+
"PGH", # pygrep-hooks
|
|
43
|
+
"PIE", # flake8-pie
|
|
44
|
+
"PT", # flake8-pytest
|
|
45
|
+
"PYI", # flake8-pyi
|
|
46
|
+
"Q", # flake8-quotes
|
|
47
|
+
"RSE", # flake8-raise
|
|
48
|
+
"RUF", # ruff-specific
|
|
49
|
+
"SLOT", # flake8-slots
|
|
50
|
+
"T10", # flake8-debugger
|
|
51
|
+
"TID", # flake8-tidy-imports
|
|
52
|
+
"TCH", # flake8-type-checking
|
|
53
|
+
"W", # pycodestyle warnings
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint.isort]
|
|
57
|
+
order-by-type = false
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint.mccabe]
|
|
60
|
+
max-complexity = 20
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.pydocstyle]
|
|
63
|
+
convention = "numpy"
|
|
64
|
+
|
|
65
|
+
[tool.pyright]
|
|
66
|
+
include = ["uv_metadata.py", "tests"]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|