diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index eb5bd7a..c9b298f 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Build on: @@ -12,22 +9,29 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ '3.11', '3.12' ] - os: [ macos-15, macos-15-intel, windows-2025 ] - - runs-on: ${{ matrix.os }} + cfg: + - { os: windows-2025, python-version: '3.11', architecture: x64 } + - { os: windows-2025, python-version: '3.12', architecture: x64 } + - { os: windows-11-arm, python-version: '3.11', architecture: arm64 } + - { os: windows-11-arm, python-version: '3.12', architecture: arm64 } + - { os: macos-15, python-version: '3.11', architecture: arm64 } + - { os: macos-15, python-version: '3.12', architecture: arm64 } + + runs-on: ${{ matrix.cfg.os }} + timeout-minutes: 45 defaults: run: shell: bash steps: - name: Clone - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.cfg.python-version }} + architecture: ${{ matrix.cfg.architecture }} - name: Setup cmake uses: jwlawson/actions-setup-cmake@v2 diff --git a/.github/workflows/python-stylecheck.yml b/.github/workflows/python-stylecheck.yml index b2a92a1..a326557 100644 --- a/.github/workflows/python-stylecheck.yml +++ b/.github/workflows/python-stylecheck.yml @@ -1,33 +1,27 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Stylecheck on: push: branches: - - master - - main - '[0-9]+.[0-9]+' - '[0-9]+.[0-9]+.[0-9]+' pull_request: jobs: stylecheck: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest steps: - name: Clone - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: 3.12 + python-version: '3.12' - name: Install dependencies run: | - python -m pip install --upgrade pip pip install black - name: run stylecheck diff --git a/.github/workflows/python-unittests.yml b/.github/workflows/python-unittests.yml index bc265ea..8c46d62 100644 --- a/.github/workflows/python-unittests.yml +++ b/.github/workflows/python-unittests.yml @@ -1,13 +1,8 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Unittests on: push: branches: - - master - - main - '[0-9]+.[0-9]+' - '[0-9]+.[0-9]+.[0-9]+' pull_request: @@ -17,10 +12,19 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ '3.11', '3.12' ] - os: [ macos-15, macos-15-intel, windows-2025, ubuntu-24.04 ] + cfg: + - { os: windows-2025, python-version: '3.11', architecture: x64 } + - { os: windows-2025, python-version: '3.12', architecture: x64 } + - { os: windows-11-arm, python-version: '3.11', architecture: arm64 } + - { os: windows-11-arm, python-version: '3.12', architecture: arm64 } + - { os: macos-15-intel, python-version: '3.11', architecture: x64 } + - { os: macos-15-intel, python-version: '3.12', architecture: x64 } + - { os: macos-15, python-version: '3.11', architecture: arm64 } + - { os: macos-15, python-version: '3.12', architecture: arm64 } + - { os: ubuntu-24.04, python-version: '3.11', architecture: x64 } + - { os: ubuntu-24.04, python-version: '3.12', architecture: x64 } - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.cfg.os }} timeout-minutes: 45 defaults: run: @@ -28,19 +32,20 @@ jobs: steps: - name: Clone - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.cfg.python-version }} + architecture: ${{ matrix.cfg.architecture }} - name: Setup cmake uses: jwlawson/actions-setup-cmake@v2 - name: Build run: | - pip install -v .[dev] + pip install . - name: Test with unittest run: python -m unittest discover -v -s tests diff --git a/setup.py b/setup.py index 9d3ddee..5b3844b 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import platform from tempfile import TemporaryDirectory from typing import TypeAlias, TYPE_CHECKING, Mapping +import sysconfig from setuptools import setup, Extension, Command from setuptools.command.build_ext import build_ext @@ -39,10 +40,14 @@ def build_extension(self, ext: Extension) -> None: platform_args = [] if sys.platform == "win32": platform_args.extend(["-G", "Visual Studio 17 2022"]) - if sys.maxsize > 2**32: + if sysconfig.get_platform() == "win-amd64": platform_args.extend(["-A", "x64"]) - else: + elif sysconfig.get_platform() == "win32": platform_args.extend(["-A", "Win32"]) + elif sysconfig.get_platform() == "win-arm64": + platform_args.extend(["-A", "ARM64"]) + else: + raise RuntimeError(f"Unsupported platform: {sysconfig.get_platform()}") platform_args.extend(["-T", "v143"]) elif sys.platform == "darwin": if platform.machine() == "arm64": @@ -57,7 +62,7 @@ def build_extension(self, ext: Extension) -> None: [ "cmake", *platform_args, - f"-DPython3_ROOT_DIR={sys.base_prefix}", + f"-DPython3_EXECUTABLE={fix_path(sys.executable)}", f"-Dpybind11_DIR={fix_path(pybind11.get_cmake_dir())}", f"-Damulet_pybind11_extensions_DIR={fix_path(amulet.pybind11_extensions.__path__[0])}", f"-Damulet_rocksdb_DIR={fix_path(rocksdb_src_dir)}", diff --git a/tools/cmake_generate.py b/tools/cmake_generate.py index e001ceb..33c39bd 100644 --- a/tools/cmake_generate.py +++ b/tools/cmake_generate.py @@ -2,6 +2,7 @@ import subprocess import os import shutil +import sysconfig import pybind11 import amulet.pybind11_extensions @@ -18,10 +19,14 @@ def main() -> None: platform_args = [] if sys.platform == "win32": platform_args.extend(["-G", "Visual Studio 17 2022"]) - if sys.maxsize > 2**32: + if sysconfig.get_platform() == "win-amd64": platform_args.extend(["-A", "x64"]) - else: + elif sysconfig.get_platform() == "win32": platform_args.extend(["-A", "Win32"]) + elif sysconfig.get_platform() == "win-arm64": + platform_args.extend(["-A", "ARM64"]) + else: + raise RuntimeError(f"Unsupported platform: {sysconfig.get_platform()}") platform_args.extend(["-T", "v143"]) os.chdir(RootDir) @@ -33,7 +38,7 @@ def main() -> None: [ "cmake", *platform_args, - f"-DPython3_ROOT_DIR={sys.base_prefix}", + f"-DPython3_EXECUTABLE={fix_path(sys.executable)}", f"-Dpybind11_DIR={fix_path(pybind11.get_cmake_dir())}", f"-Damulet_pybind11_extensions_DIR={fix_path(amulet.pybind11_extensions.__path__[0])}", f"-Damulet_rocksdb_DIR={fix_path(os.path.join(RootDir, 'src', 'amulet', 'rocksdb'))}",