Skip to content

Commit

Permalink
Fix handling cpython_module type recipe (#74)
Browse files Browse the repository at this point in the history
#36 had a bug not supporting `cpython_module` type recipes.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ryanking13 and pre-commit-ci[bot] authored Dec 23, 2024
1 parent 51fe634 commit af493ad
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions integration_tests/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This directory contains a few curated recipes to test the build process of pyodi
- orjson: Tests rust extension modules.
- zlib: Tests static libraries.
- geos: Tests shared libraries.
- pydoc_data: Unvendored cpython module

### For maintainers

Expand Down
19 changes: 19 additions & 0 deletions integration_tests/recipes/pydoc_data/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package:
name: pydoc_data
version: 1.0.0 # Nonsense
tag:
- always
top-level:
- pydoc_data
source:
path: src
build:
type: cpython_module
script: |
wget ${PYTHON_ARCHIVE_URL} -O Python-${PYVERSION}.tgz
tar -xf Python-${PYVERSION}.tgz
cd Python-${PYVERSION}/Lib
tar --exclude=__pycache__ -cf - pydoc_data | tar -C ${PKG_BUILD_DIR} -xf -
about:
license: PSF
23 changes: 23 additions & 0 deletions integration_tests/recipes/pydoc_data/src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "pydoc_data"
authors = [
{ name="Pyodide"},
]
description = "Unvendored pydoc_data for Pyodide"
version = "1.0.0"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
ignore-vcs = true

[tool.hatch.build.targets.wheel]
ignore-vcs = true
include = [
"pydoc_data/",
]
exclude = [
"Python-*",
]
6 changes: 2 additions & 4 deletions pyodide_build/buildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,14 @@ def get_builder(
recipe = Path(recipe).resolve()
_, config = _load_recipe(recipe)
match config.build.package_type:
case "package":
case "package" | "cpython_module":
builder = RecipeBuilderPackage
case "static_library":
builder = RecipeBuilderStaticLibrary
case "shared_library":
builder = RecipeBuilderSharedLibrary
case _:
raise ValueError(
f"Unknown package type: {config.build_metadata.package_type}"
)
raise ValueError(f"Unknown package type: {config.build.package_type}")

return builder(recipe, build_args, build_dir, force_rebuild, continue_)

Expand Down

0 comments on commit af493ad

Please sign in to comment.