Skip to content
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
35 changes: 19 additions & 16 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,25 +25,30 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
with:
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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-stylecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 16 additions & 19 deletions .github/workflows/python-unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,20 +28,21 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
with:
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/*
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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}"
2 changes: 1 addition & 1 deletion requirements.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
16 changes: 3 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
3 changes: 1 addition & 2 deletions src/amulet/rocksdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import logging as _logging

from . import _version
Expand All @@ -19,3 +17,4 @@ def _init() -> None:


_init()
del _init
2 changes: 0 additions & 2 deletions src/amulet/rocksdb/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,5 @@ class WriteOptions:
sync: bool
def __init__(self) -> None: ...

def _init() -> None: ...

__version__: str
compiler_config: dict
4 changes: 2 additions & 2 deletions tools/cmake_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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)
Expand Down