diff --git a/pyodide_build/cli/skeleton.py b/pyodide_build/cli/skeleton.py index 2c053a9b..3935dd3f 100644 --- a/pyodide_build/cli/skeleton.py +++ b/pyodide_build/cli/skeleton.py @@ -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.", @@ -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) diff --git a/pyodide_build/recipe/skeleton.py b/pyodide_build/recipe/skeleton.py index b3012892..922a6008 100755 --- a/pyodide_build/recipe/skeleton.py +++ b/pyodide_build/recipe/skeleton.py @@ -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() @@ -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"): diff --git a/pyodide_build/tests/recipe/test_skeleton.py b/pyodide_build/tests/recipe/test_skeleton.py index 6235886a..0e96e1e6 100644 --- a/pyodide_build/tests/recipe/test_skeleton.py +++ b/pyodide_build/tests/recipe/test_skeleton.py @@ -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) @@ -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)