Skip to content

Commit aca3fe6

Browse files
Replace typer with click (#39)
* Replace typer with click * Address comment * Fix pyodide-cli version * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * changelog --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ac4db6a commit aca3fe6

File tree

5 files changed

+66
-33
lines changed

5 files changed

+66
-33
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [0.1.1] - 2026-01-02
11+
12+
Dropped `typer` dependency for CLI.
13+
[#39](https://github.com/pyodide/pyodide-lock/pull/39)
14+
1015
## [0.1.0] - 2025-08-16
1116

1217
No functional changes. pyodide-lock is no longer an alpha version.

pyodide_lock/cli.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,60 @@
11
from pathlib import Path
22

3-
import typer
3+
import click
44

55
from .spec import PyodideLockSpec
66
from .utils import add_wheels_to_spec
77

8-
main = typer.Typer(help="manipulate pyodide-lock.json lockfiles.")
98

9+
@click.group(help="Manipulate pyodide-lock.json lockfiles.")
10+
def main():
11+
"""Manipulate pyodide-lock.json lockfiles."""
12+
pass
1013

11-
@main.command()
14+
15+
@main.command(short_help="Add wheels to a pyodide-lock.json lockfile.")
16+
@click.argument(
17+
"wheels", nargs=-1, type=click.Path(exists=True, path_type=Path), required=True
18+
)
19+
@click.option(
20+
"--ignore-missing-dependencies",
21+
is_flag=True,
22+
default=False,
23+
help="If this is true, dependencies which are not in the original lockfile or "
24+
"the added wheels will be added to the lockfile. Warning: This will allow a broken lockfile to be created.",
25+
)
26+
@click.option(
27+
"--input",
28+
type=click.Path(path_type=Path),
29+
default=Path("pyodide-lock.json"),
30+
help="Source lockfile",
31+
)
32+
@click.option(
33+
"--output",
34+
type=click.Path(path_type=Path),
35+
default=Path("pyodide-lock-new.json"),
36+
help="Updated lockfile",
37+
)
38+
@click.option(
39+
"--base-path",
40+
type=click.Path(path_type=Path),
41+
default=None,
42+
help="Base path for wheels - wheel file names will be created relative to this path.",
43+
)
44+
@click.option(
45+
"--wheel-url",
46+
type=str,
47+
default="",
48+
help="Base url which will be appended to the wheel location. "
49+
"Use this if you are hosting these wheels on a different server to core pyodide packages",
50+
)
1251
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-
),
52+
wheels,
53+
ignore_missing_dependencies,
54+
input,
55+
output,
56+
base_path,
57+
wheel_url,
3958
):
4059
"""Add a set of package wheels to an existing pyodide-lock.json and
4160
write it out to pyodide-lock-new.json
@@ -45,6 +64,10 @@ def add_wheels(
4564
this will fail if a dependency isn't available in either the
4665
existing lock file, or in the set of new wheels.
4766
67+
\b
68+
Arguments:
69+
WHEELS: List of paths to wheel files. (required)
70+
4871
"""
4972
sp = PyodideLockSpec.from_json(input)
5073
sp = add_wheels_to_spec(

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ dynamic = ["version"]
2323

2424
[project.optional-dependencies]
2525
cli = [
26-
"typer",
26+
"click",
27+
"pyodide-cli>=0.4.0",
2728
]
2829
wheel = [
2930
"pkginfo",
@@ -33,7 +34,7 @@ dev = [
3334
"pytest",
3435
"pytest-cov",
3536
"build",
36-
"typer",
37+
"click",
3738
# from wheel
3839
"pkginfo",
3940
"packaging",
@@ -77,6 +78,9 @@ select = [
7778
"PLE", # pylint errors
7879
"UP", # pyupgrade
7980
]
81+
ignore = [
82+
"E501", # line too long
83+
]
8084

8185
[tool.pytest.ini_options]
8286
addopts = '''

tests/test_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typer.testing import CliRunner
1+
from click.testing import CliRunner
22

33
from pyodide_lock.cli import main
44
from pyodide_lock.spec import PyodideLockSpec
@@ -15,6 +15,7 @@ def test_add_wheels_cli_integration(tmp_path, example_lock_spec, test_wheel_list
1515
result = runner.invoke(
1616
main,
1717
[
18+
"add-wheels",
1819
str(test_wheel_list[0]),
1920
"--input",
2021
str(input_file),

tests/test_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_base_relative_path(test_wheel_list, example_lock_spec):
7979
assert "needs-one" in example_lock_spec.packages
8080
assert "needs-one-opt" in example_lock_spec.packages
8181
assert example_lock_spec.packages["needs-one-opt"].file_name.startswith(
82-
"http://www.nowhere.org/dist/nEEds"
82+
"http://www.nowhere.org/dist/needs"
8383
)
8484

8585

0 commit comments

Comments
 (0)