Skip to content

Commit

Permalink
add typer to dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joemarshall committed Sep 29, 2023
1 parent 1bc04ee commit 44a80bb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 47 deletions.
98 changes: 51 additions & 47 deletions pyodide_lock/cli/lockfile.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
from pathlib import Path

import typer
try:
import typer

from ..spec import PyodideLockSpec
from ..spec import PyodideLockSpec

main = typer.Typer()
main = typer.Typer()

@main.command()
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,
),
in_lockfile: Path = typer.Option(
help="Source lockfile (input)", default=Path("pyodide-lock.json")
),
out_lockfile: Path = typer.Option(
help="Updated lockfile (output)", 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="",
),
):
"""Add a set of package wheels to an existing pyodide-lock.json and
write it out to pyodide-lock-new.json
@main.command()
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,
),
in_lockfile: Path = typer.Option(
help="Source lockfile (input)", default=Path("pyodide-lock.json")
),
out_lockfile: Path = typer.Option(
help="Updated lockfile (output)", 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="",
),
):
"""Add a set of package wheels to an existing pyodide-lock.json and
write it out to pyodide-lock-new.json
Each package in the wheel will be added to the output lockfile,
including resolution of dependencies in the lock file. By default
this will fail if a dependency isn't available in either the
existing lock file, or in the set of new wheels.
Each package in the wheel will be added to the output lockfile,
including resolution of dependencies in the lock file. By default
this will fail if a dependency isn't available in either the
existing lock file, or in the set of new wheels.
"""
sp = PyodideLockSpec.from_json(in_lockfile)
sp.add_wheels(
wheels,
base_path=base_path,
base_url=wheel_url,
ignore_missing_dependencies=ignore_missing_dependencies,
)
sp.to_json(out_lockfile)

"""
sp = PyodideLockSpec.from_json(in_lockfile)
sp.add_wheels(
wheels,
base_path=base_path,
base_url=wheel_url,
ignore_missing_dependencies=ignore_missing_dependencies,
)
sp.to_json(out_lockfile)
except ImportError:
pass
# no typer = no cli
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ classifiers = [
dynamic = ["version"]

[project.optional-dependencies]
cli = [
"typer",
]
wheel = [
"pkginfo",
"packaging",
Expand All @@ -30,6 +33,7 @@ dev = [
"pytest",
"pytest-cov",
"build",
"typer",
# from wheel
"pkginfo",
"packaging",
Expand Down

0 comments on commit 44a80bb

Please sign in to comment.