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: min version logic issue #853

Merged
merged 1 commit into from
Aug 7, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/scikit_build_core/settings/skbuild_read_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def _handle_minimum_version(

# Check for minimum_version < 0.8 and the modern version setting
if (
dc.version != version_default
dc.version is not None
and dc.version != version_default
and minimum_version is not None
and minimum_version < Version("0.8")
):
Expand All @@ -74,13 +75,16 @@ def _handle_minimum_version(
elif minimum_version >= Version("0.8"):
rich_error(msg)

if dc.version != version_default:
if dc.version is not None and dc.version != version_default:
rich_error(
f"Cannot set both {name}.minimum_version and {name}.version; use version only for scikit-build-core >= 0.8."
)

dc.version = SpecifierSet(f">={dc.minimum_version}")

if dc.version is None:
dc.version = SpecifierSet(f">={default}")


def _handle_move(
before_name: str,
Expand Down Expand Up @@ -226,16 +230,15 @@ def __init__(
if self.settings.install.strip is None:
self.settings.install.strip = install_policy

# Before 0.10, we hard-coded 3.15+ as the minimum CMake version
# If we noted earlier that auto-cmake was requested, handle it now
if (
self.settings.cmake.version is None
and self.settings.minimum_version is not None
and self.settings.minimum_version < Version("0.10")
and self.settings.cmake.minimum_version is None
and (
self.settings.minimum_version is None
or self.settings.minimum_version >= Version("0.10")
)
):
self.settings.cmake.version = SpecifierSet(">=3.15")

# If we noted earlier that auto-cmake was requested, handle it now
if self.settings.cmake.version is None:
cmake_path = self.settings.cmake.source_dir / "CMakeLists.txt"
try:
with cmake_path.open(encoding="utf-8-sig") as f:
Expand Down
8 changes: 7 additions & 1 deletion tests/test_skbuild_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,19 @@ def test_skbuild_settings_min_version_versions(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.setattr(
scikit_build_core.settings.skbuild_read_settings, "__version__", "0.8.0"
scikit_build_core.settings.skbuild_read_settings, "__version__", "0.10.0"
)

pyproject_toml = tmp_path / "pyproject.toml"
pyproject_toml.write_text(
"tool.scikit-build.cmake.minimum-version = '3.21'", encoding="utf-8"
)
cmakelists = tmp_path / "CMakeLists.txt"
cmakelists.write_text("cmake_minimum_required(VERSION 3.20)", encoding="utf-8")

settings_reader = SettingsReader.from_file(pyproject_toml, {})
settings = settings_reader.settings
assert settings.cmake.version == SpecifierSet(">=3.21")

settings_reader = SettingsReader.from_file(
pyproject_toml, {"minimum-version": "0.7"}
Expand Down
Loading