Skip to content

Commit 9b65d5f

Browse files
Do not require downloading xbuildenv when updating package recipes (#30)
## 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]>
1 parent ca7c0e2 commit 9b65d5f

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

pyodide_build/build_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def search_pyodide_root(curdir: str | Path, *, max_depth: int = 10) -> Path | No
9696
"""
9797
Recursively search for the root of the Pyodide repository,
9898
by looking for the pyproject.toml file in the parent directories
99-
which contains [tool.pyodide] section.
99+
which contains the [tool._pyodide] section.
100100
"""
101101
pyproject_path, pyproject_file = search_pyproject_toml(curdir, max_depth)
102102

pyodide_build/cli/skeleton.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,25 @@ def new_recipe_pypi(
4848
),
4949
) -> None:
5050
"""
51-
Create a new package from PyPI.
51+
Create a new package recipe from PyPI or update an existing recipe.
5252
"""
5353

54+
# Determine the recipe directory. If it is specified by the user, we use that;
55+
# otherwise, we assume that the recipe directory is the ``packages`` directory
56+
# in the root of the Pyodide tree, without the need to initialize the
57+
# cross-build environment.
58+
#
59+
# It is unlikely that a user will run this command outside of the Pyodide
60+
# tree, so we do not need to initialize the environment at this stage.
61+
5462
if recipe_dir:
5563
recipe_dir_ = Path(recipe_dir)
5664
else:
5765
cwd = Path.cwd()
66+
root = build_env.search_pyodide_root(curdir=cwd)
5867

59-
if build_env.in_xbuildenv():
68+
if not root:
6069
root = cwd
61-
else:
62-
root = build_env.search_pyodide_root(cwd) or cwd
6370

6471
recipe_dir_ = root / "packages"
6572

@@ -76,7 +83,7 @@ def new_recipe_pypi(
7683
logger.error(f"{name} update failed: {e}")
7784
sys.exit(1)
7885
except mkpkg.MkpkgSkipped as e:
79-
logger.warn(f"{name} update skipped: {e}")
86+
logger.warning(f"{name} update skipped: {e}")
8087
except Exception:
8188
print(name)
8289
raise

pyodide_build/mkpkg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def update_package(
227227
meta_path = root / package / "meta.yaml"
228228
if not meta_path.exists():
229229
logger.error(f"{meta_path} does not exist")
230-
exit(1)
230+
raise MkpkgFailedException(f"{package} recipe not found at {meta_path}")
231231

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

0 commit comments

Comments
 (0)