Skip to content

Commit

Permalink
Do not require downloading xbuildenv when updating package recipes (#30)
Browse files Browse the repository at this point in the history
## Description

Closes #25. This PR improves the xbuildenv search logic to not require
downloads of the xbuildenv if a package update fails (for any reason).
This means that the Pyodide root is searched in the current directory,
and if it doesn't exist, we simply assume that the current working
directory is the Pyodide root (and the `packages/` directory one level
down hosts the recipes).

I confirmed that this does not currently cause issues with the existing
setup in the Pyodide repository.

---------

Co-authored-by: Gyeongjae Choi <[email protected]>
  • Loading branch information
agriyakhetarpal and ryanking13 authored Sep 18, 2024
1 parent ca7c0e2 commit 9b65d5f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyodide_build/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def search_pyodide_root(curdir: str | Path, *, max_depth: int = 10) -> Path | No
"""
Recursively search for the root of the Pyodide repository,
by looking for the pyproject.toml file in the parent directories
which contains [tool.pyodide] section.
which contains the [tool._pyodide] section.
"""
pyproject_path, pyproject_file = search_pyproject_toml(curdir, max_depth)

Expand Down
17 changes: 12 additions & 5 deletions pyodide_build/cli/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,25 @@ def new_recipe_pypi(
),
) -> None:
"""
Create a new package from PyPI.
Create a new package recipe from PyPI or update an existing recipe.
"""

# Determine the recipe directory. If it is specified by the user, we use that;
# otherwise, we assume that the recipe directory is the ``packages`` directory
# in the root of the Pyodide tree, without the need to initialize the
# cross-build environment.
#
# It is unlikely that a user will run this command outside of the Pyodide
# tree, so we do not need to initialize the environment at this stage.

if recipe_dir:
recipe_dir_ = Path(recipe_dir)
else:
cwd = Path.cwd()
root = build_env.search_pyodide_root(curdir=cwd)

if build_env.in_xbuildenv():
if not root:
root = cwd
else:
root = build_env.search_pyodide_root(cwd) or cwd

recipe_dir_ = root / "packages"

Expand All @@ -76,7 +83,7 @@ def new_recipe_pypi(
logger.error(f"{name} update failed: {e}")
sys.exit(1)
except mkpkg.MkpkgSkipped as e:
logger.warn(f"{name} update skipped: {e}")
logger.warning(f"{name} update skipped: {e}")
except Exception:
print(name)
raise
Expand Down
2 changes: 1 addition & 1 deletion pyodide_build/mkpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def update_package(
meta_path = root / package / "meta.yaml"
if not meta_path.exists():
logger.error(f"{meta_path} does not exist")
exit(1)
raise MkpkgFailedException(f"{package} recipe not found at {meta_path}")

yaml_content = yaml.load(meta_path.read_bytes())

Expand Down

0 comments on commit 9b65d5f

Please sign in to comment.