-
Notifications
You must be signed in to change notification settings - Fork 11
Replace typer with click #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,60 @@ | ||
| from pathlib import Path | ||
|
|
||
| import typer | ||
| import click | ||
|
|
||
| from .spec import PyodideLockSpec | ||
| from .utils import add_wheels_to_spec | ||
|
|
||
| main = typer.Typer(help="manipulate pyodide-lock.json lockfiles.") | ||
|
|
||
| @click.group(help="Manipulate pyodide-lock.json lockfiles.") | ||
| def main(): | ||
| """Manipulate pyodide-lock.json lockfiles.""" | ||
| pass | ||
|
|
||
| @main.command() | ||
|
|
||
| @main.command(short_help="Add wheels to a pyodide-lock.json lockfile.") | ||
| @click.argument( | ||
| "wheels", nargs=-1, type=click.Path(exists=True, path_type=Path), required=True | ||
| ) | ||
| @click.option( | ||
| "--ignore-missing-dependencies", | ||
| is_flag=True, | ||
| default=False, | ||
| help="If this is true, dependencies which are not in the original lockfile or " | ||
| "the added wheels will be added to the lockfile. Warning: This will allow a broken lockfile to be created.", | ||
| ) | ||
| @click.option( | ||
| "--input", | ||
| type=click.Path(path_type=Path), | ||
| default=Path("pyodide-lock.json"), | ||
| help="Source lockfile", | ||
| ) | ||
| @click.option( | ||
| "--output", | ||
| type=click.Path(path_type=Path), | ||
| default=Path("pyodide-lock-new.json"), | ||
| help="Updated lockfile", | ||
| ) | ||
| @click.option( | ||
| "--base-path", | ||
| type=click.Path(path_type=Path), | ||
| default=None, | ||
| help="Base path for wheels - wheel file names will be created relative to this path.", | ||
| ) | ||
| @click.option( | ||
| "--wheel-url", | ||
| type=str, | ||
| default="", | ||
| help="Base url which will be appended to the wheel location. " | ||
| "Use this if you are hosting these wheels on a different server to core pyodide packages", | ||
| ) | ||
| def add_wheels( | ||
| wheels: list[Path], | ||
| ignore_missing_dependencies: bool = typer.Option( | ||
| help="If this is true, dependencies " | ||
| "which are not in the original lockfile or " | ||
| "the added wheels will be added to the lockfile. " | ||
| "Warning: This will allow a broken lockfile to " | ||
| "be created.", | ||
| default=False, | ||
| ), | ||
| input: Path = typer.Option( | ||
| help="Source lockfile", default=Path("pyodide-lock.json") | ||
| ), | ||
| output: Path = typer.Option( | ||
| help="Updated lockfile", default=Path("pyodide-lock-new.json") | ||
| ), | ||
| base_path: Path = typer.Option( | ||
| help="Base path for wheels - wheel file " | ||
| "names will be created relative to this path.", | ||
| default=None, | ||
| ), | ||
| wheel_url: str = typer.Option( | ||
| help="Base url which will be appended to the wheel location." | ||
| "Use this if you are hosting these wheels on a different " | ||
| "server to core pyodide packages", | ||
| default="", | ||
| ), | ||
| wheels, | ||
| ignore_missing_dependencies, | ||
| input, | ||
| output, | ||
| base_path, | ||
| wheel_url, | ||
| ): | ||
| """Add a set of package wheels to an existing pyodide-lock.json and | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arguments are not printed by default in or something similar.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Thanks for the pointer! |
||
| write it out to pyodide-lock-new.json | ||
|
|
@@ -45,6 +64,10 @@ def add_wheels( | |
| this will fail if a dependency isn't available in either the | ||
| existing lock file, or in the set of new wheels. | ||
|
|
||
| \b | ||
| Arguments: | ||
| WHEELS: List of paths to wheel files. (required) | ||
|
|
||
| """ | ||
| sp = PyodideLockSpec.from_json(input) | ||
| sp = add_wheels_to_spec( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ def test_base_relative_path(test_wheel_list, example_lock_spec): | |
| assert "needs-one" in example_lock_spec.packages | ||
| assert "needs-one-opt" in example_lock_spec.packages | ||
| assert example_lock_spec.packages["needs-one-opt"].file_name.startswith( | ||
| "http://www.nowhere.org/dist/nEEds" | ||
| "http://www.nowhere.org/dist/needs" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why it was written with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably to test name canonicalization
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure why the original test was written with |
||
| ) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
Noneaccepted asclick.Path? Astyperversion worked well, it will do so, but I am slightly concerned about its behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does. I believe click will not change the None to something else, and it should be fine then.