Skip to content

Commit e039a06

Browse files
Replace typer with click (#50)
* Replace typer with click * Update pyodide-cli dependency version --------- Co-authored-by: Gyeongjae Choi <[email protected]>
1 parent 365a8e5 commit e039a06

File tree

2 files changed

+84
-54
lines changed

2 files changed

+84
-54
lines changed

auditwheel_emscripten/cli/main.py

Lines changed: 83 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
from pathlib import Path
22

3-
import typer
3+
import click
44

55
from .. import function_type, get_exports, get_imports, repair, show
66
from ..show import locate_dependency
77
from ..wheel_utils import unpack_if_wheel
88

9-
app = typer.Typer()
109

11-
12-
@app.callback(no_args_is_help=True)
13-
def main():
10+
@click.group(no_args_is_help=True)
11+
def app():
1412
"""Auditwheel-like tool for emscripten wheels and shared libraries."""
1513

1614

@@ -43,19 +41,18 @@ def print_dylib(
4341

4442

4543
@app.command("show")
44+
@click.argument("wheel_or_so_file", type=click.Path(path_type=Path))
45+
@click.option("--with-runtime-paths", "-r", is_flag=True, help="Show runtime paths.")
4646
def _show(
47-
wheel_or_so_file: Path = typer.Argument(
48-
..., help="Path to wheel or a shared library file."
49-
),
50-
show_runtime_paths: bool = typer.Option(
51-
False,
52-
"-r",
53-
"--with-runtime-paths",
54-
help="Show runtime paths.",
55-
),
47+
wheel_or_so_file: Path,
48+
show_runtime_paths: bool,
5649
):
5750
"""
5851
Show shared library dependencies of a wheel or a shared library file.
52+
53+
\b
54+
Arguments:
55+
WHEEL_OR_SO_FILE: Path to wheel or a shared library file. (required)
5956
"""
6057
try:
6158
libraries = show(wheel_or_so_file)
@@ -68,25 +65,33 @@ def _show(
6865

6966

7067
@app.command("repair")
68+
@click.argument("wheel_file", type=click.Path(path_type=Path))
69+
@click.option(
70+
"--libdir",
71+
type=click.Path(path_type=Path),
72+
default="lib",
73+
help="Path to the directory containing the shared libraries.",
74+
show_default=True,
75+
)
76+
@click.option(
77+
"--output-dir",
78+
type=click.Path(path_type=Path),
79+
default=None,
80+
help="Directory to output repaired wheel or shared library. (default: overwrite the input file)",
81+
)
82+
@click.option("--with-runtime-paths", "-r", is_flag=True, help="Show runtime paths.")
7183
def _repair(
72-
wheel_file: Path = typer.Argument(..., help="Path to wheel file."),
73-
libdir: Path = typer.Option(
74-
"lib",
75-
help="Path to the directory containing the shared libraries.",
76-
),
77-
output_dir: Path = typer.Option(
78-
None,
79-
help="Directory to output repaired wheel or shared library. (default: overwrite the input file)",
80-
),
81-
show_runtime_paths: bool = typer.Option(
82-
False,
83-
"-r",
84-
"--with-runtime-paths",
85-
help="Show runtime paths.",
86-
),
84+
wheel_file: Path,
85+
libdir: Path,
86+
output_dir: Path | None,
87+
show_runtime_paths: bool,
8788
):
8889
"""
8990
Repair a wheel file: copy shared libraries to the wheel directory.
91+
92+
\b
93+
Arguments:
94+
WHEEL_FILE: Path to wheel file. (required)
9095
"""
9196
try:
9297
repaired_wheel = repair(
@@ -105,35 +110,54 @@ def _repair(
105110

106111

107112
@app.command("copy")
113+
@click.argument("wheel_file", type=click.Path(path_type=Path))
114+
@click.option(
115+
"--libdir",
116+
type=click.Path(path_type=Path),
117+
default="lib",
118+
help="Path to the directory containing the shared libraries.",
119+
show_default=True,
120+
)
121+
@click.option(
122+
"--output-dir",
123+
type=click.Path(path_type=Path),
124+
default=None,
125+
help="Directory to output repaired wheel or shared library. (default: overwrite the input file)",
126+
)
108127
def _copy(
109-
wheel_file: Path = typer.Argument(..., help="Path to wheel file."),
110-
libdir: Path = typer.Option(
111-
"lib",
112-
help="Path to the directory containing the shared libraries.",
113-
),
114-
output_dir: Path = typer.Option(
115-
None,
116-
help="Directory to output repaired wheel or shared library. (default: overwrite the input file)",
117-
),
128+
wheel_file: Path,
129+
libdir: Path,
130+
output_dir: Path | None,
118131
):
119132
"""
120133
[Deprecated] Copy shared libraries to the wheel directory. Works same as `repair`. Use `repair` instead.
134+
135+
\b
136+
Arguments:
137+
WHEEL_FILE: Path to wheel file. (required)
121138
"""
122139
return _repair(wheel_file, libdir, output_dir)
123140

124141

125142
@app.command("exports")
143+
@click.argument("wheel_or_so_file", type=click.Path(path_type=Path))
144+
@click.option(
145+
"--show-type",
146+
is_flag=True,
147+
help="Show function type.",
148+
default=False,
149+
show_default=True,
150+
)
126151
def _exports(
127-
wheel_or_so_file: Path = typer.Argument(
128-
..., help="Path to wheel or a shared library file."
129-
),
130-
show_type: bool = typer.Option(
131-
False,
132-
help="Show function type.",
133-
),
152+
wheel_or_so_file: Path,
153+
show_type: bool,
134154
):
135155
"""
136156
Show exports of a wheel or a shared library file.
157+
158+
\b
159+
Arguments:
160+
WHEEL_OR_SO_FILE: Path to wheel or a shared library file. (required)
137161
"""
138162
try:
139163
exports = get_exports(wheel_or_so_file)
@@ -154,17 +178,24 @@ def _exports(
154178

155179

156180
@app.command("imports")
181+
@click.argument("wheel_or_so_file", type=click.Path(path_type=Path))
182+
@click.option(
183+
"--show-type",
184+
is_flag=True,
185+
help="Show function type.",
186+
default=False,
187+
show_default=True,
188+
)
157189
def _imports(
158-
wheel_or_so_file: Path = typer.Argument(
159-
..., help="Path to wheel or a shared library file."
160-
),
161-
show_type: bool = typer.Option(
162-
False,
163-
help="Show function type.",
164-
),
190+
wheel_or_so_file: Path,
191+
show_type: bool,
165192
):
166193
"""
167194
Show imports of a wheel or a shared library file.
195+
196+
\b
197+
Arguments:
198+
WHEEL_OR_SO_FILE: Path to wheel or a shared library file. (required)
168199
"""
169200
try:
170201
imports = get_imports(wheel_or_so_file)

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ requires-python = ">=3.12"
1212
dependencies = [
1313
"leb128",
1414
"packaging",
15-
"pyodide-cli",
16-
"typer",
15+
"pyodide-cli>=0.4",
1716
"wheel",
1817
]
1918
license.file = "LICENSE"

0 commit comments

Comments
 (0)