Skip to content

Commit

Permalink
fix: pyodide support by trying --version if -E fails
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Apr 19, 2024
1 parent f844088 commit 983e99c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
12 changes: 10 additions & 2 deletions docs/changelog.md
@@ -1,10 +1,18 @@
# Changelog

## Version 0.9.1

Quick fix for Pyodide (WebAssembly) builds.

Fixes:

- Try `--version` if `-E capabilities` fails by @henryiii

## Version 0.9.0

This version adds the ability to `inherit` in override tables, matching a
similar feature added to cibuildwheel 2.17's overrides. You can now write out
extra metadata to `@{SKBUILD_METADATA_DIR}`. A new Hatchling plugin is provided
extra metadata to `${SKBUILD_METADATA_DIR}`. A new Hatchling plugin is provided
as an experimental feature (will likely be made a separate package in the future
like the setuptools plugin).

Expand All @@ -26,7 +34,7 @@ Fixes:

- Exclude installed files if listed in exclude by @henryiii in #652
- Make `.git_archival.txt` reproducible by @LecrisUT in #706
- Use `cmake -E` capabilities instead of `cmake --version` by @KyleFromNVIDIA in
- Use `cmake -E capabilities` instead of `cmake --version` by @KyleFromNVIDIA in
#675
- Ensure many/musl tags not selected by @henryiii in #698
- purelib should set py3 tag if unset by @henryiii in #661
Expand Down
45 changes: 34 additions & 11 deletions src/scikit_build_core/program_search.py
Expand Up @@ -79,17 +79,40 @@ def get_cmake_program(cmake_path: Path) -> Program:
"""
try:
result = Run().capture(cmake_path, "-E", "capabilities")
except (subprocess.CalledProcessError, PermissionError):
return Program(cmake_path, None)

try:
version = Version(json.loads(result.stdout)["version"]["string"])
except (json.decoder.JSONDecodeError, KeyError, InvalidVersion):
logger.warning("Could not determine CMake version, got {!r}", result.stdout)
return Program(cmake_path, None)

logger.info("CMake version: {}", version)
return Program(cmake_path, version)
try:
version = Version(json.loads(result.stdout)["version"]["string"])
logger.info("CMake version: {}", version)
return Program(cmake_path, version)
except (json.decoder.JSONDecodeError, KeyError, InvalidVersion):
logger.warning("Could not determine CMake version, got {!r}", result.stdout)
except subprocess.CalledProcessError:
try:
result = Run().capture(cmake_path, "--version")
try:
version = Version(
result.stdout.splitlines()[0].split()[-1].split("-")[0]
)
logger.info("CMake version via --version: {}", version)
return Program(cmake_path, version)
except (IndexError, InvalidVersion):
logger.warning(
"Could not determine CMake version via --version, got {!r}",
result.stdout,
)
except subprocess.CalledProcessError:
logger.warning(
"Could not determine CMake version via --version, got {!r} {!r}",
result.stdout,
result.stderr,
)
except PermissionError:
logger.warning(
"Permissions Error getting CMake's version, got {!r} {!r}",
result.stdout,
result.stderr,
)

return Program(cmake_path, None)


def get_cmake_programs(*, module: bool = True) -> Generator[Program, None, None]:
Expand Down

0 comments on commit 983e99c

Please sign in to comment.