Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pyodide support by trying --version if -E fails #717

Merged
merged 1 commit into from Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
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
@@ -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
Expand Up @@ -79,17 +79,40 @@
"""
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(

Check warning on line 92 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L88-L92

Added lines #L88 - L92 were not covered by tests
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(

Check warning on line 98 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L95-L98

Added lines #L95 - L98 were not covered by tests
"Could not determine CMake version via --version, got {!r}",
result.stdout,
)
except subprocess.CalledProcessError:
logger.warning(

Check warning on line 103 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L102-L103

Added lines #L102 - L103 were not covered by tests
"Could not determine CMake version via --version, got {!r} {!r}",
result.stdout,
result.stderr,
)
except PermissionError:
logger.warning(

Check warning on line 109 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L108-L109

Added lines #L108 - L109 were not covered by tests
"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