Skip to content

Commit

Permalink
Add update-pinned option to override
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jan 25, 2025
1 parent 32661ee commit f73b20f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 8 additions & 2 deletions pyodide_build/cli/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def new_recipe_pypi(
"--update-patched",
help="Force update the package even if it contains patches.",
),
update_pinned: bool = typer.Option(
False,
"--update-pinner",
help="Force update the package even if is pinned.",
),
version: str = typer.Option(
None,
help="The version of the package, if not specified, latest version will be used.",
Expand Down Expand Up @@ -71,14 +76,15 @@ def new_recipe_pypi(

recipe_dir_ = root / "packages"

if update or update_patched:
if update or update_patched or update_pinned:
try:
skeleton.update_package(
recipe_dir_,
name,
version,
version=version,
source_fmt=source_format, # type: ignore[arg-type]
update_patched=update_patched,
update_pinned=update_pinned,
)
except skeleton.MkpkgFailedException as e:
logger.error("%s update failed: %s", name, e)
Expand Down
6 changes: 4 additions & 2 deletions pyodide_build/recipe/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ def make_package(
def update_package(
root: Path,
package: str,
*,
version: str | None = None,
update_patched: bool = True,
update_patched: bool = False,
update_pinned: bool = False,
source_fmt: Literal["wheel", "sdist"] | None = None,
) -> None:
yaml = YAML()
Expand All @@ -237,7 +239,7 @@ def update_package(
if "url" not in yaml_content["source"]:
raise MkpkgSkipped(f"{package} is a local package!")

if yaml_content["package"].get("pinned", False):
if (not update_pinned) and yaml_content["package"].get("pinned", False):
raise MkpkgSkipped(f"{package} is pinned!")

if yaml_content["source"]["url"].endswith("whl"):
Expand Down
5 changes: 3 additions & 2 deletions pyodide_build/tests/recipe/test_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_mkpkg_update(tmpdir, old_dist_type, new_dist_type):
source_fmt = new_dist_type
if new_dist_type == "same":
source_fmt = None
skeleton.update_package(base_dir, "idna", None, False, source_fmt)
skeleton.update_package(base_dir, "idna", source_fmt=source_fmt)

db = MetaConfig.from_yaml(meta_path)
assert version.parse(db.package.version) > version.parse(db_init.package.version)
Expand Down Expand Up @@ -87,4 +87,5 @@ def test_mkpkg_update_pinned(tmpdir):
meta_path = package_dir / "meta.yaml"
db_init.to_yaml(meta_path)
with pytest.raises(skeleton.MkpkgSkipped, match="pinned"):
skeleton.update_package(base_dir, "idna", None, False, None)
skeleton.update_package(base_dir, "idna")
skeleton.update_package(base_dir, "idna", update_pinned=True)

0 comments on commit f73b20f

Please sign in to comment.