Skip to content

Commit

Permalink
fix: add support for sunos (scikit-build#983)
Browse files Browse the repository at this point in the history
* fix: add support for sunos

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
mtelka and pre-commit-ci[bot] authored May 17, 2023
1 parent b53bd6b commit f2d253e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
5 changes: 5 additions & 0 deletions skbuild/platform_specifics/platform_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ def get_platform() -> abstract.CMakePlatform:

return bsd.BSDPlatform()

if this_platform == "sunos":
from . import sunos

return sunos.SunOSPlatform()

msg = f"Unsupported platform: {this_platform:s}. Please contact the scikit-build team."
raise RuntimeError(msg)
28 changes: 28 additions & 0 deletions skbuild/platform_specifics/sunos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""This module defines object specific to SunOS platform."""

from __future__ import annotations

import sys
import textwrap

from . import unix


class SunOSPlatform(unix.UnixPlatform):
"""SunOS implementation of :class:`.abstract.CMakePlatform`."""

@property
def generator_installation_help(self) -> str:
"""Return message guiding the user for installing a valid toolchain."""
return (
textwrap.dedent(
"""
Building SunOS wheels for Python {pyver} requires build toolchain.
It can be installed using:
pkg install build-essential
"""
)
.format(pyver=".".join(str(v) for v in sys.version_info[:2]))
.strip()
)
12 changes: 9 additions & 3 deletions skbuild/resources/cmake/FindPythonExtensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,15 @@ function(_set_python_extension_symbol_visibility _target)
"{global: ${_modinit_prefix}${_target}; local: *;};"
)
endif()
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script=\"${_script_path}\""
)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script=\"${_script_path}\""
)
else()
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,-M \"${_script_path}\""
)
endif()
endif()
endfunction()

Expand Down
5 changes: 4 additions & 1 deletion tests/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def test_generator_cleanup():
assert not os.path.exists(test_folder)


@pytest.mark.parametrize("supported_platform", ["darwin", "freebsd", "openbsd", "linux", "windows", "os400", "cygwin"])
@pytest.mark.parametrize(
"supported_platform", ["darwin", "freebsd", "openbsd", "linux", "windows", "os400", "cygwin", "sunos"]
)
def test_known_platform(supported_platform, mocker):
mocker.patch("platform.system", return_value=supported_platform)
platforms = {
Expand All @@ -93,6 +95,7 @@ def test_known_platform(supported_platform, mocker):
"windows": "Windows",
"os400": "BSD",
"cygwin": "Cygwin",
"sunos": "SunOS",
}
expected_platform_classname = f"{platforms[supported_platform]}Platform"
assert get_platform().__class__.__name__ == expected_platform_classname
Expand Down

0 comments on commit f2d253e

Please sign in to comment.