pyodide-lock 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.
- pyodide_lock-0.1.0/.codecov.yml +1 -0
- pyodide_lock-0.1.0/.github/workflows/main.yml +53 -0
- pyodide_lock-0.1.0/.gitignore +4 -0
- pyodide_lock-0.1.0/.pre-commit-config.yaml +48 -0
- pyodide_lock-0.1.0/CHANGELOG.md +79 -0
- pyodide_lock-0.1.0/LICENSE +28 -0
- pyodide_lock-0.1.0/PKG-INFO +65 -0
- pyodide_lock-0.1.0/README.md +37 -0
- pyodide_lock-0.1.0/pyodide_lock/__init__.py +9 -0
- pyodide_lock-0.1.0/pyodide_lock/cli.py +57 -0
- pyodide_lock-0.1.0/pyodide_lock/py.typed +0 -0
- pyodide_lock-0.1.0/pyodide_lock/spec.py +88 -0
- pyodide_lock-0.1.0/pyodide_lock/utils.py +394 -0
- pyodide_lock-0.1.0/pyproject.toml +86 -0
- pyodide_lock-0.1.0/tests/conftest.py +162 -0
- pyodide_lock-0.1.0/tests/data/pyodide-lock-0.22.1.json.gz +0 -0
- pyodide_lock-0.1.0/tests/data/pyodide-lock-0.23.3.json.gz +0 -0
- pyodide_lock-0.1.0/tests/test_cli.py +31 -0
- pyodide_lock-0.1.0/tests/test_spec.py +115 -0
- pyodide_lock-0.1.0/tests/test_utils.py +57 -0
- pyodide_lock-0.1.0/tests/test_wheel.py +203 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
comment: false
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
name: CI
|
|
3
|
+
on: ["push", "pull_request"]
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- name: Set up Python 3.10
|
|
16
|
+
uses: actions/setup-python@v3
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.10"
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
- name: Build
|
|
24
|
+
run: |
|
|
25
|
+
pyproject-build
|
|
26
|
+
- name: Test with pytest
|
|
27
|
+
run: |
|
|
28
|
+
pytest --cov=. --cov-report=xml
|
|
29
|
+
- name: Upload coverage
|
|
30
|
+
uses: codecov/codecov-action@v3
|
|
31
|
+
with:
|
|
32
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
33
|
+
|
|
34
|
+
deploy:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
|
37
|
+
environment: PyPi-deploy
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v3
|
|
40
|
+
|
|
41
|
+
- uses: actions/setup-python@v4
|
|
42
|
+
with:
|
|
43
|
+
python-version: 3.12
|
|
44
|
+
- name: Install requirements and build wheel
|
|
45
|
+
shell: bash -l {0}
|
|
46
|
+
run: |
|
|
47
|
+
python -m pip install build twine
|
|
48
|
+
python -m build .
|
|
49
|
+
- name: Publish package
|
|
50
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
51
|
+
with:
|
|
52
|
+
user: __token__
|
|
53
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: "3.12"
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: "v5.0.0"
|
|
6
|
+
hooks:
|
|
7
|
+
- id: check-added-large-files
|
|
8
|
+
- id: check-case-conflict
|
|
9
|
+
- id: check-merge-conflict
|
|
10
|
+
- id: check-symlinks
|
|
11
|
+
- id: check-yaml
|
|
12
|
+
- id: debug-statements
|
|
13
|
+
- id: end-of-file-fixer
|
|
14
|
+
- id: mixed-line-ending
|
|
15
|
+
- id: trailing-whitespace
|
|
16
|
+
|
|
17
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
18
|
+
rev: "v0.11.4"
|
|
19
|
+
hooks:
|
|
20
|
+
- id: ruff
|
|
21
|
+
args: [--fix]
|
|
22
|
+
|
|
23
|
+
- repo: https://github.com/psf/black
|
|
24
|
+
rev: "25.1.0"
|
|
25
|
+
hooks:
|
|
26
|
+
- id: black
|
|
27
|
+
|
|
28
|
+
- repo: https://github.com/pre-commit/pygrep-hooks
|
|
29
|
+
rev: "v1.10.0"
|
|
30
|
+
hooks:
|
|
31
|
+
- id: python-use-type-annotations
|
|
32
|
+
exclude: docs/sphinx_pyodide/tests/test_directives\.py
|
|
33
|
+
|
|
34
|
+
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
35
|
+
rev: "v0.10.0.1"
|
|
36
|
+
hooks:
|
|
37
|
+
- id: shellcheck
|
|
38
|
+
|
|
39
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
40
|
+
rev: "v1.15.0"
|
|
41
|
+
hooks:
|
|
42
|
+
- id: mypy
|
|
43
|
+
args: []
|
|
44
|
+
additional_dependencies:
|
|
45
|
+
- pydantic
|
|
46
|
+
|
|
47
|
+
ci:
|
|
48
|
+
autoupdate_schedule: "quarterly"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2025-08-16
|
|
11
|
+
|
|
12
|
+
No functional changes. pyodide-lock is no longer an alpha version.
|
|
13
|
+
|
|
14
|
+
## [0.1.0a8] - 2024-09-17
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Support stable ABI (`abi3`) wheels in lock file.
|
|
19
|
+
[#32](https://github.com/pyodide/pyodide-lock/pull/32)
|
|
20
|
+
|
|
21
|
+
## [0.1.0a7] - 2024-08-08
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- `shared_library` key is removed from the lock file.
|
|
26
|
+
[#31](https://github.com/pyodide/pyodide-lock/pull/31)
|
|
27
|
+
|
|
28
|
+
## [0.1.0a6] - 2024-04-03
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- The `info` field now contains an optional `abi_version`.
|
|
33
|
+
[#27](https://github.com/pyodide/pyodide-lock/pull/27)
|
|
34
|
+
|
|
35
|
+
## [0.1.0a5] - 2024-04-03
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- `pydantic >= 2.0` is now required.
|
|
40
|
+
[#26](https://github.com/pyodide/pyodide-lock/pull/26)
|
|
41
|
+
|
|
42
|
+
## [0.1.0a4] - 2023-11-17
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Pinned to `pydantic >=1.10.2,<2`
|
|
47
|
+
[#23](https://github.com/pyodide/pyodide-lock/pull/23)
|
|
48
|
+
|
|
49
|
+
- Added `PackageSpec.from_wheel` for generating a package spec from a `.whl` file
|
|
50
|
+
[#18](https://github.com/pyodide/pyodide-lock/pull/18)
|
|
51
|
+
|
|
52
|
+
- Added `parse_top_level_import_name` for finding importable names in `.whl` files
|
|
53
|
+
[#17](https://github.com/pyodide/pyodide-lock/pull/17)
|
|
54
|
+
|
|
55
|
+
- Added `pyodide lockfile add_wheels` CLI command.
|
|
56
|
+
[#20](https://github.com/pyodide/pyodide-lock/pull/20)
|
|
57
|
+
|
|
58
|
+
## [0.1.0a3] - 2023-09-15
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Fixed package home/issues URL metadata in `pyproject.toml`
|
|
63
|
+
[#15](https://github.com/pyodide/pyodide-lock/pull/15)
|
|
64
|
+
|
|
65
|
+
- Fixed `PyodideLockSpec.to_json` to not add newlines to the output by default.
|
|
66
|
+
[#12](https://github.com/pyodide/pyodide-lock/pull/12)
|
|
67
|
+
|
|
68
|
+
## [0.1.0a2] - 2023-07-21
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- Add `check_wheel_filenames` method to `PyodideLockSpec` that checks that the
|
|
73
|
+
package name in version are consistent between the wheel filename and the
|
|
74
|
+
corresponding pyodide-lock.json fields
|
|
75
|
+
[#11](https://github.com/pyodide/pyodide-lock/pull/11)
|
|
76
|
+
|
|
77
|
+
## [0.1.0a1] - 2023-06-23
|
|
78
|
+
|
|
79
|
+
Initial release
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Roman Yurchak
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyodide-lock
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tooling to manage the `pyodide-lock.json` file
|
|
5
|
+
Project-URL: Homepage, https://github.com/pyodide/pyodide-lock
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/pyodide/pyodide-lock/issues
|
|
7
|
+
Author: Pyodide developers
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: pydantic>=2
|
|
14
|
+
Provides-Extra: cli
|
|
15
|
+
Requires-Dist: typer; extra == 'cli'
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: build; extra == 'dev'
|
|
18
|
+
Requires-Dist: packaging; extra == 'dev'
|
|
19
|
+
Requires-Dist: pkginfo; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
22
|
+
Requires-Dist: typer; extra == 'dev'
|
|
23
|
+
Requires-Dist: wheel; extra == 'dev'
|
|
24
|
+
Provides-Extra: wheel
|
|
25
|
+
Requires-Dist: packaging; extra == 'wheel'
|
|
26
|
+
Requires-Dist: pkginfo; extra == 'wheel'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# pyodide-lock
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/pyodide-lock/)
|
|
32
|
+

|
|
33
|
+
[](https://codecov.io/gh/pyodide/pyodide-lock)
|
|
34
|
+
|
|
35
|
+
Tooling to manage the `pyodide-lock.json` file.
|
|
36
|
+
|
|
37
|
+
Note: the API of this package is still being iterated on and may change completely
|
|
38
|
+
before the 0.1 release.
|
|
39
|
+
|
|
40
|
+
The `pyodide-lock` file is used to lock the versions of the packages that are
|
|
41
|
+
used in a given Pyodide application. Packages included in `pyodide-lock.json`
|
|
42
|
+
will be auto-loaded at import time, when using `pyodide.runPythonAsync` or
|
|
43
|
+
running in JupyterLite or PyScript, and do not need to be explicitly installed
|
|
44
|
+
with micropip.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install pyodide-lock
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Python API
|
|
53
|
+
|
|
54
|
+
To parsing and write the `pyodide-lock.json` (formerly `repodata.json`) file:
|
|
55
|
+
```py
|
|
56
|
+
from pyodide_lock import PyodideLockSpec
|
|
57
|
+
|
|
58
|
+
lock_spec = PyodideLockSpec.from_json("pyodide-lock.json")
|
|
59
|
+
# Make some changes
|
|
60
|
+
lock_spec.to_json("pyodide-lock.json")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
BSD-3-Clause License
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# pyodide-lock
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pyodide-lock/)
|
|
4
|
+

|
|
5
|
+
[](https://codecov.io/gh/pyodide/pyodide-lock)
|
|
6
|
+
|
|
7
|
+
Tooling to manage the `pyodide-lock.json` file.
|
|
8
|
+
|
|
9
|
+
Note: the API of this package is still being iterated on and may change completely
|
|
10
|
+
before the 0.1 release.
|
|
11
|
+
|
|
12
|
+
The `pyodide-lock` file is used to lock the versions of the packages that are
|
|
13
|
+
used in a given Pyodide application. Packages included in `pyodide-lock.json`
|
|
14
|
+
will be auto-loaded at import time, when using `pyodide.runPythonAsync` or
|
|
15
|
+
running in JupyterLite or PyScript, and do not need to be explicitly installed
|
|
16
|
+
with micropip.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install pyodide-lock
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Python API
|
|
25
|
+
|
|
26
|
+
To parsing and write the `pyodide-lock.json` (formerly `repodata.json`) file:
|
|
27
|
+
```py
|
|
28
|
+
from pyodide_lock import PyodideLockSpec
|
|
29
|
+
|
|
30
|
+
lock_spec = PyodideLockSpec.from_json("pyodide-lock.json")
|
|
31
|
+
# Make some changes
|
|
32
|
+
lock_spec.to_json("pyodide-lock.json")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
BSD-3-Clause License
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from .spec import PyodideLockSpec
|
|
6
|
+
from .utils import add_wheels_to_spec
|
|
7
|
+
|
|
8
|
+
main = typer.Typer(help="manipulate pyodide-lock.json lockfiles.")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@main.command()
|
|
12
|
+
def add_wheels(
|
|
13
|
+
wheels: list[Path],
|
|
14
|
+
ignore_missing_dependencies: bool = typer.Option(
|
|
15
|
+
help="If this is true, dependencies "
|
|
16
|
+
"which are not in the original lockfile or "
|
|
17
|
+
"the added wheels will be added to the lockfile. "
|
|
18
|
+
"Warning: This will allow a broken lockfile to "
|
|
19
|
+
"be created.",
|
|
20
|
+
default=False,
|
|
21
|
+
),
|
|
22
|
+
input: Path = typer.Option(
|
|
23
|
+
help="Source lockfile", default=Path("pyodide-lock.json")
|
|
24
|
+
),
|
|
25
|
+
output: Path = typer.Option(
|
|
26
|
+
help="Updated lockfile", default=Path("pyodide-lock-new.json")
|
|
27
|
+
),
|
|
28
|
+
base_path: Path = typer.Option(
|
|
29
|
+
help="Base path for wheels - wheel file "
|
|
30
|
+
"names will be created relative to this path.",
|
|
31
|
+
default=None,
|
|
32
|
+
),
|
|
33
|
+
wheel_url: str = typer.Option(
|
|
34
|
+
help="Base url which will be appended to the wheel location."
|
|
35
|
+
"Use this if you are hosting these wheels on a different "
|
|
36
|
+
"server to core pyodide packages",
|
|
37
|
+
default="",
|
|
38
|
+
),
|
|
39
|
+
):
|
|
40
|
+
"""Add a set of package wheels to an existing pyodide-lock.json and
|
|
41
|
+
write it out to pyodide-lock-new.json
|
|
42
|
+
|
|
43
|
+
Each package in the wheel will be added to the output lockfile,
|
|
44
|
+
including resolution of dependencies in the lock file. By default
|
|
45
|
+
this will fail if a dependency isn't available in either the
|
|
46
|
+
existing lock file, or in the set of new wheels.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
sp = PyodideLockSpec.from_json(input)
|
|
50
|
+
sp = add_wheels_to_spec(
|
|
51
|
+
sp,
|
|
52
|
+
wheels,
|
|
53
|
+
base_path=base_path,
|
|
54
|
+
base_url=wheel_url,
|
|
55
|
+
ignore_missing_dependencies=ignore_missing_dependencies,
|
|
56
|
+
)
|
|
57
|
+
sp.to_json(output)
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InfoSpec(BaseModel):
|
|
9
|
+
arch: Literal["wasm32", "wasm64"] = "wasm32"
|
|
10
|
+
platform: str
|
|
11
|
+
version: str
|
|
12
|
+
python: str
|
|
13
|
+
abi_version: str | None = None
|
|
14
|
+
model_config = ConfigDict(extra="forbid")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PackageSpec(BaseModel):
|
|
18
|
+
name: str
|
|
19
|
+
version: str
|
|
20
|
+
file_name: str = Field(
|
|
21
|
+
description="Path (or URL) to wheel.",
|
|
22
|
+
)
|
|
23
|
+
install_dir: str
|
|
24
|
+
sha256: str = ""
|
|
25
|
+
package_type: Literal[
|
|
26
|
+
"package", "cpython_module", "shared_library", "static_library"
|
|
27
|
+
] = "package"
|
|
28
|
+
imports: list[str] = []
|
|
29
|
+
depends: list[str] = []
|
|
30
|
+
unvendored_tests: bool = False
|
|
31
|
+
# This field is deprecated and will not be included in the output
|
|
32
|
+
shared_library: bool = Field(default=False, exclude=True)
|
|
33
|
+
model_config = ConfigDict(extra="forbid")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class PyodideLockSpec(BaseModel):
|
|
37
|
+
"""A specification for the pyodide-lock.json file."""
|
|
38
|
+
|
|
39
|
+
info: InfoSpec
|
|
40
|
+
packages: dict[str, PackageSpec]
|
|
41
|
+
model_config = ConfigDict(extra="forbid")
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def from_json(cls, path: Path) -> "PyodideLockSpec":
|
|
45
|
+
"""Read the lock spec from a json file."""
|
|
46
|
+
with path.open("r", encoding="utf-8") as fh:
|
|
47
|
+
data = json.load(fh)
|
|
48
|
+
return cls(**data)
|
|
49
|
+
|
|
50
|
+
def to_json(self, path: Path, indent: int | None = None) -> None:
|
|
51
|
+
"""Write the lock spec to a json file."""
|
|
52
|
+
with path.open("w", encoding="utf-8") as fh:
|
|
53
|
+
model_dict = self.model_dump()
|
|
54
|
+
json_str = json.dumps(model_dict, indent=indent, sort_keys=True)
|
|
55
|
+
fh.write(json_str)
|
|
56
|
+
|
|
57
|
+
def check_wheel_filenames(self) -> None:
|
|
58
|
+
"""Check that the package name and version are consistent in wheel filenames"""
|
|
59
|
+
from packaging.utils import (
|
|
60
|
+
canonicalize_name,
|
|
61
|
+
canonicalize_version,
|
|
62
|
+
parse_wheel_filename,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
errors: dict[str, list[str]] = {}
|
|
66
|
+
for name, spec in self.packages.items():
|
|
67
|
+
if not spec.file_name.endswith(".whl"):
|
|
68
|
+
continue
|
|
69
|
+
name_in_wheel, ver, _, _ = parse_wheel_filename(spec.file_name)
|
|
70
|
+
if canonicalize_name(name_in_wheel) != canonicalize_name(spec.name):
|
|
71
|
+
errors.setdefault(name, []).append(
|
|
72
|
+
f"Package name in wheel filename {name_in_wheel!r} "
|
|
73
|
+
f"does not match {spec.name!r}"
|
|
74
|
+
)
|
|
75
|
+
if canonicalize_version(ver) != canonicalize_version(spec.version):
|
|
76
|
+
errors.setdefault(name, []).append(
|
|
77
|
+
f"Version in the wheel filename {canonicalize_version(ver)!r} "
|
|
78
|
+
f"does not match package version "
|
|
79
|
+
f"{canonicalize_version(spec.version)!r}"
|
|
80
|
+
)
|
|
81
|
+
if errors:
|
|
82
|
+
error_msg = "check_wheel_filenames failed:\n"
|
|
83
|
+
|
|
84
|
+
error_msg += " - " + "\n - ".join(
|
|
85
|
+
f"{name}:\n - " + "\n - ".join(errs)
|
|
86
|
+
for name, errs in errors.items()
|
|
87
|
+
)
|
|
88
|
+
raise ValueError(error_msg)
|