From 36c7a9cf9e51bd6d3f903204d5ea6e90901a8378 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Tue, 30 May 2023 16:45:12 -0700 Subject: [PATCH] fix: add support for AIX (#988) * fix: add support for AIX * fix: Update README.rst with known issue on AIX AIX support requires a version of CMake newer than the 3.22.0 version that IBM supplies in their AIX Toolbox for Open Source Software. IBM is aware of the issue and will be providing a newer build soon, but for now we should note that users will need to build their own copy of a newer CMake on AIX at this time. --- README.rst | 3 ++ docs/skbuild.platform_specifics.rst | 8 ++++++ skbuild/platform_specifics/aix.py | 28 +++++++++++++++++++ .../platform_specifics/platform_factory.py | 5 ++++ tests/test_platform.py | 3 +- 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 skbuild/platform_specifics/aix.py diff --git a/README.rst b/README.rst index 91b3b30c..89631766 100644 --- a/README.rst +++ b/README.rst @@ -83,6 +83,9 @@ already addressed in `scikit-build-core`_. currently. * The cache directory (``_skbuild``) may need to be deleted between builds in some cases (like rebuilding with a different Python interpreter). +* AIX requires a newer version of CMake than the IBM-supplied CMake 3.22.0 + from the AIX Toolbox for Open Source Software. We currently recommend + building CMake from source on AIX. We are also working on improving scikit-build, so there are some upcoming changes and deprecations: diff --git a/docs/skbuild.platform_specifics.rst b/docs/skbuild.platform_specifics.rst index de00c284..ac4af0fe 100644 --- a/docs/skbuild.platform_specifics.rst +++ b/docs/skbuild.platform_specifics.rst @@ -49,6 +49,14 @@ skbuild.platform\_specifics.osx module :undoc-members: :show-inheritance: +skbuild.platform\_specifics.aix module +---------------------------------------- + +.. automodule:: skbuild.platform_specifics.aix + :members: + :undoc-members: + :show-inheritance: + skbuild.platform\_specifics.platform\_factory module ---------------------------------------------------- diff --git a/skbuild/platform_specifics/aix.py b/skbuild/platform_specifics/aix.py new file mode 100644 index 00000000..1d4ee1a2 --- /dev/null +++ b/skbuild/platform_specifics/aix.py @@ -0,0 +1,28 @@ +"""This module defines object specific to AIX platform.""" + +from __future__ import annotations + +import sys +import textwrap + +from . import unix + + +class AIXPlatform(unix.UnixPlatform): + """AIX 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 AIX wheels for Python {pyver} requires IBM XL C/C++. + Get it here: + + https://www.ibm.com/products/xl-c-aix-compiler-power + """ + ) + .format(pyver=".".join(str(v) for v in sys.version_info[:2])) + .strip() + ) diff --git a/skbuild/platform_specifics/platform_factory.py b/skbuild/platform_specifics/platform_factory.py index 9242cf70..d0740c06 100644 --- a/skbuild/platform_specifics/platform_factory.py +++ b/skbuild/platform_specifics/platform_factory.py @@ -45,5 +45,10 @@ def get_platform() -> abstract.CMakePlatform: return sunos.SunOSPlatform() + if this_platform == "aix": + from . import aix + + return aix.AIXPlatform() + msg = f"Unsupported platform: {this_platform:s}. Please contact the scikit-build team." raise RuntimeError(msg) diff --git a/tests/test_platform.py b/tests/test_platform.py index 3a35085f..5554a960 100644 --- a/tests/test_platform.py +++ b/tests/test_platform.py @@ -83,7 +83,7 @@ def test_generator_cleanup(): @pytest.mark.parametrize( - "supported_platform", ["darwin", "freebsd", "openbsd", "linux", "windows", "os400", "cygwin", "sunos"] + "supported_platform", ["darwin", "freebsd", "openbsd", "linux", "windows", "os400", "cygwin", "sunos", "aix"] ) def test_known_platform(supported_platform, mocker): mocker.patch("platform.system", return_value=supported_platform) @@ -96,6 +96,7 @@ def test_known_platform(supported_platform, mocker): "os400": "BSD", "cygwin": "Cygwin", "sunos": "SunOS", + "aix": "AIX", } expected_platform_classname = f"{platforms[supported_platform]}Platform" assert get_platform().__class__.__name__ == expected_platform_classname