Skip to content

Commit

Permalink
fix: pyodide support by trying --version if -E fails (#717)
Browse files Browse the repository at this point in the history
Fix #715. Fix #716 (dup).

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Apr 20, 2024
1 parent f844088 commit c3e8c06
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ strict-config = true
experimental = false

# If set, this will provide a method for backward compatibility.
minimum-version = "0.8" # current version
minimum-version = "0.9" # current version

# The build directory. Defaults to a temporary directory, but can be set.
build-dir = ""
Expand Down
12 changes: 10 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Changelog

## Version 0.9.1

Quick fix for Pyodide (WebAssembly) builds.

Fixes:

- Try `--version` if `-E capabilities` fails by @henryiii in #717

## 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
Original file line number Diff line number Diff line change
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 c3e8c06

Please sign in to comment.