diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 9a6baac..dacb376 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -10,14 +10,12 @@ jobs: fail-fast: false matrix: 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: windows-2025-vs2026, python-version: '3.11', architecture: x64, whl: 'cp311-win_amd64' } + - { os: windows-11-vs2026-arm, python-version: '3.11', architecture: arm64, whl: 'cp311-win_arm64' } + - { os: macos-15-intel, python-version: '3.11', architecture: x64, whl: 'cp311-macosx_x86_64' } + - { os: macos-15, python-version: '3.11', architecture: arm64, whl: 'cp311-macosx_arm64' } + - { os: ubuntu-24.04, python-version: '3.11', architecture: x64, whl: 'cp311-manylinux_x86_64' } + - { os: ubuntu-24.04, python-version: '3.13', architecture: x64, whl: 'cp313-manylinux_x86_64' } runs-on: ${{ matrix.cfg.os }} timeout-minutes: 45 @@ -27,7 +25,7 @@ jobs: steps: - name: Clone - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Python uses: actions/setup-python@v6 @@ -35,17 +33,22 @@ jobs: python-version: ${{ matrix.cfg.python-version }} architecture: ${{ matrix.cfg.architecture }} - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2 - - - name: Install dependencies - shell: bash + - name: Build sdist run: | - pip install build twine + pip install build + python -m build --sdist --outdir dist . - name: Build + env: + CIBW_TEST_COMMAND: "" + run: | + pip install cibuildwheel~=4.1 + cibuildwheel --only ${{ matrix.cfg.whl }} --output-dir dist . + + - name: Install twine + shell: bash run: | - python -m build . + pip install twine - name: Publish env: diff --git a/.github/workflows/python-stylecheck.yml b/.github/workflows/python-stylecheck.yml index a326557..fbdbce7 100644 --- a/.github/workflows/python-stylecheck.yml +++ b/.github/workflows/python-stylecheck.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Clone - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Python uses: actions/setup-python@v6 diff --git a/.github/workflows/python-unittests.yml b/.github/workflows/python-unittests.yml index 8c46d62..fbc4da1 100644 --- a/.github/workflows/python-unittests.yml +++ b/.github/workflows/python-unittests.yml @@ -13,16 +13,12 @@ jobs: fail-fast: false matrix: 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 } + - { os: windows-2025-vs2026, python-version: '3.11', architecture: x64, whl: 'cp311-win_amd64' } + - { os: windows-11-vs2026-arm, python-version: '3.11', architecture: arm64, whl: 'cp311-win_arm64' } + - { os: macos-15-intel, python-version: '3.11', architecture: x64, whl: 'cp311-macosx_x86_64' } + - { os: macos-15, python-version: '3.11', architecture: arm64, whl: 'cp311-macosx_arm64' } + - { os: ubuntu-24.04, python-version: '3.11', architecture: x64, whl: 'cp311-manylinux_x86_64' } + - { os: ubuntu-24.04, python-version: '3.13', architecture: x64, whl: 'cp313-manylinux_x86_64' } runs-on: ${{ matrix.cfg.os }} timeout-minutes: 45 @@ -32,7 +28,7 @@ jobs: steps: - name: Clone - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Python uses: actions/setup-python@v6 @@ -40,12 +36,13 @@ jobs: python-version: ${{ matrix.cfg.python-version }} architecture: ${{ matrix.cfg.architecture }} - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2 - - - name: Build + - name: Build and Test run: | - pip install . - - - name: Test with unittest - run: python -m unittest discover -v -s tests + pip install cibuildwheel~=4.1 + cibuildwheel --only ${{ matrix.cfg.whl }} --output-dir dist . + + - name: Upload artifacts + uses: actions/upload-artifact@v7 + with: + name: ${{ matrix.cfg.whl }} + path: dist/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f35d0c..f8ad645 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ if (MSVC) add_definitions("/MP") endif() -find_package(Python3 COMPONENTS Interpreter Development) +find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED) # Find libraries if (NOT TARGET pybind11::module) @@ -68,11 +68,12 @@ set(WITH_RUNTIME_DEBUG OFF CACHE BOOL "" FORCE) set(WITH_WINDOWS_UTF8_FILENAMES OFF CACHE BOOL "" FORCE) set(ROCKSDB_BUILD_SHARED OFF CACHE BOOL "" FORCE) set(ROCKSDB_INSTALL OFF CACHE BOOL "" FORCE) +set(FAIL_ON_WARNINGS OFF CACHE BOOL "" FORCE) FetchContent_Declare( rocksdb GIT_REPOSITORY https://github.com/Amulet-Team/rocksdb.git - GIT_TAG 15ca97a2dd2f9a067c9d3062d9319296555a0ce9 + GIT_TAG 4153aebf840920ce41dbc47896febbd3020b9d5f ) FetchContent_MakeAvailable(rocksdb) set_target_properties(rocksdb PROPERTIES FOLDER "ThirdParty") @@ -106,6 +107,7 @@ endforeach() # Add python extension pybind11_add_module(_rocksdb) +set_target_properties(_rocksdb PROPERTIES CXX_VISIBILITY_PRESET hidden) set_target_properties(_rocksdb PROPERTIES FOLDER "Python") target_link_libraries(_rocksdb PRIVATE amulet_pybind11_extensions) target_link_libraries(_rocksdb PRIVATE amulet_rocksdb) diff --git a/mypy.ini b/mypy.ini index 87dd001..2fb6385 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,7 +5,7 @@ warn_return_any = True python_version = 3.12 explicit_package_bases = True mypy_path = $MYPY_CONFIG_FILE_DIR/src/amulet,$MYPY_CONFIG_FILE_DIR/tests -files = +files = src, tests, tools, diff --git a/pyproject.toml b/pyproject.toml index 7c95edc..b153191 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ name = "amulet-rocksdb" authors = [ {name = "James Clare"}, ] -description = "A pybind11 wrapper for RocksDB." +description = "A pybind11 wrapper for Facebook's RocksDB." dynamic = ["version", "readme", "dependencies"] requires-python = ">=3.11" classifiers = [ @@ -67,3 +67,19 @@ versionfile_source = "src/amulet/rocksdb/_version.py" versionfile_build = "rocksdb/_version.py" tag_prefix = "" parentdir_prefix = "amulet_rocksdb-" + +[tool.cibuildwheel] +test-sources = ["tests"] +test-command = "python -m unittest discover -s tests" + +[tool.cibuildwheel.macos] +repair-wheel-command = """ +export MACOSX_DEPLOYMENT_TARGET=11.0 +delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} +""" + +[tool.cibuildwheel.linux] +before-all = "yum install -y cmake" + +[tool.cibuildwheel.windows] +repair-wheel-command = "delvewheel repair --ignore-existing --exclude msvcp140.dll -w {dest_dir} -v {wheel}" diff --git a/requirements.py b/requirements.py index 7d2f3d8..b16b999 100644 --- a/requirements.py +++ b/requirements.py @@ -1,7 +1,7 @@ import os from packaging.version import Version -PYBIND11_REQUIREMENT = "==3.0.1" +PYBIND11_REQUIREMENT = "==3.0.4" AMULET_PYBIND11_EXTENSIONS_REQUIREMENT = "~=1.2.0.0a2" if os.environ.get("AMULET_PYBIND11_EXTENSIONS_REQUIREMENT", None): diff --git a/setup.py b/setup.py index 5b3844b..9c80366 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from pathlib import Path import platform from tempfile import TemporaryDirectory -from typing import TypeAlias, TYPE_CHECKING, Mapping +from typing import TypeAlias, TYPE_CHECKING import sysconfig from setuptools import setup, Extension, Command @@ -39,7 +39,7 @@ def build_extension(self, ext: Extension) -> None: platform_args = [] if sys.platform == "win32": - platform_args.extend(["-G", "Visual Studio 17 2022"]) + platform_args.extend(["-G", "Visual Studio 18 2026"]) if sysconfig.get_platform() == "win-amd64": platform_args.extend(["-A", "x64"]) elif sysconfig.get_platform() == "win32": @@ -48,7 +48,7 @@ def build_extension(self, ext: Extension) -> None: platform_args.extend(["-A", "ARM64"]) else: raise RuntimeError(f"Unsupported platform: {sysconfig.get_platform()}") - platform_args.extend(["-T", "v143"]) + platform_args.extend(["-T", "v145"]) elif sys.platform == "darwin": if platform.machine() == "arm64": # rocksdb does not support universal builds @@ -86,20 +86,10 @@ def build_extension(self, ext: Extension) -> None: cmdclass["build_ext"] = CMakeBuild # type: ignore -options: Mapping[str, Mapping[str, str]] = {} - -if sys.platform == "darwin": - arch = platform.machine() - if arch not in ("arm64", "x86_64"): - raise RuntimeError(f"Unsupported architecture: {arch}") - options["bdist_wheel"] = {"plat_name": f"macosx_11_0_{arch}"} - - setup( version=versioneer.get_version(), cmdclass=cmdclass, ext_modules=[Extension("rocksdb._rocksdb", [])] * (not os.environ.get("AMULET_SKIP_COMPILE", None)), install_requires=requirements.get_runtime_dependencies(), - options=options, ) diff --git a/src/amulet/rocksdb/__init__.py b/src/amulet/rocksdb/__init__.py index c2f350d..dd3dafb 100644 --- a/src/amulet/rocksdb/__init__.py +++ b/src/amulet/rocksdb/__init__.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import logging as _logging from . import _version @@ -19,3 +17,4 @@ def _init() -> None: _init() +del _init diff --git a/src/amulet/rocksdb/__init__.pyi b/src/amulet/rocksdb/__init__.pyi index 007902b..33eb450 100644 --- a/src/amulet/rocksdb/__init__.pyi +++ b/src/amulet/rocksdb/__init__.pyi @@ -250,7 +250,5 @@ class WriteOptions: sync: bool def __init__(self) -> None: ... -def _init() -> None: ... - __version__: str compiler_config: dict diff --git a/tools/cmake_generate.py b/tools/cmake_generate.py index 33c39bd..bce96d3 100644 --- a/tools/cmake_generate.py +++ b/tools/cmake_generate.py @@ -18,7 +18,7 @@ def fix_path(path: str) -> str: def main() -> None: platform_args = [] if sys.platform == "win32": - platform_args.extend(["-G", "Visual Studio 17 2022"]) + platform_args.extend(["-G", "Visual Studio 18 2026"]) if sysconfig.get_platform() == "win-amd64": platform_args.extend(["-A", "x64"]) elif sysconfig.get_platform() == "win32": @@ -27,7 +27,7 @@ def main() -> None: platform_args.extend(["-A", "ARM64"]) else: raise RuntimeError(f"Unsupported platform: {sysconfig.get_platform()}") - platform_args.extend(["-T", "v143"]) + platform_args.extend(["-T", "v145"]) os.chdir(RootDir) shutil.rmtree(os.path.join(RootDir, "build", "CMakeFiles"), ignore_errors=True)