Skip to content

Commit

Permalink
🏗️ Switch the pyfiction build system from raw setuptools to `scik…
Browse files Browse the repository at this point in the history
…it-build-core` (#592)

* 🏗️ Switch to `scikit-build` for *pyfiction*. Works almost. Still need to figure out how to deal with Z3.

* 🏗️ Add `__init__.py` file content for inclusion of symbols

* 💚 Fixed Z3 detection and inclusion with scikit-build

* ✅ Use explicit includes for all tests

* 💚 Add missing `try_z3.cpp` file

* 🔥 Remove `python-dotenv` dependency

* 💚 Fix sdist build

* 💚 Fix compile target

* 🔧 Added `uv.lock` file

* 💚 Attempt to fix CI and CD

* 💚 Create `venv` before build

* 💚 Replace `_a` literals with `py::arg` function calls

* 🔥 Remove `FICTION_BENCHMARK` build toggle since it depends on `FICTION_TEST`, which is already set to `OFF`

* 🔧 Update CMake version compatibility list

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 💚 Fix `unittest` discovery by setting starting path

* 💚 Set up `nox` for testing the bindings

* 🔧 Exclude the newly added `try_z3.cpp` from `clang-tidy` checks

* 💚 Fix Z3 setup

* 💚 Remove Windows version flag in CMake

* 💚 Fixed paths in the pyfiction docstring generator

* 💚 Updated pyfiction docstrings and removed fragment left in the wrong location

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 📌 Sync the dependency versions with `main`

* 🎨 Incorporated pre-commit fixes

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🐛 Fixed remaining `pybind11_mkdoc_docstrings.hpp` paths

* 💚 Set up MSVC environment

* 💚 Fix type conversion issue

* ✅ Added missing import statements

* 📝 Update documentation on Python bindings (skip ci)

* 🎨 Adjusted `__init__.py` file for consistency

---------

Signed-off-by: GitHub Actions <actions@github.com>
Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 28, 2024
1 parent 0dffdc5 commit b7901a3
Show file tree
Hide file tree
Showing 214 changed files with 3,096 additions and 1,381 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CheckOptions:
- key: cppcoreguidelines-avoid-do-while.IgnoreMacros
value: "true"
- key: misc-include-cleaner.IgnoreHeaders
value: ".*/experiments.hpp;.*/fiction_experiments.hpp;.*/fmt/.*"
value: "cmake/try_z3.cpp;.*/experiments.hpp;.*/fiction_experiments.hpp;.*/fmt/.*"
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- '**/*.cpp'
- 'libs/**'
- '.github/workflows/clang-tidy-review.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- '**/*.py'
- 'libs/**'
- '.github/workflows/codeql-analysis.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -22,7 +22,7 @@ on:
- '**/*.py'
- 'libs/**'
- '.github/workflows/codeql-analysis.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:
schedule:
- cron: '30 5 * * 6'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/coverage.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -20,7 +20,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/coverage.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:

concurrency:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- '.github/workflows/docker-image.yml'
- 'Dockerfile'
- '.dockerignore'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -24,7 +24,7 @@ on:
- '.github/workflows/docker-image.yml'
- 'Dockerfile'
- '.dockerignore'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:
workflow_dispatch:
release:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/macos.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -20,7 +20,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/macos.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:

concurrency:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pyfiction-docstring-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ jobs:
run: >
python3
-m pybind11_mkdoc
-o ${{ github.workspace }}/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
-o ${{ github.workspace }}/bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
-D FICTION_Z3_SOLVER
`find ${{ github.workspace }}/include/fiction -name "*.hpp" -print`
- name: Upload docstrings as an artifact
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
path: ${{ github.workspace }}/bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
overwrite: true

- name: Commit docstrings
uses: EndBug/add-and-commit@v9
with:
add: 'bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
add: 'bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
commit: '--signoff'
message: ':memo: Update pyfiction docstrings'
author_name: GitHub Actions
Expand Down
60 changes: 24 additions & 36 deletions .github/workflows/pyfiction-pypi-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ concurrency:

env:
Z3_VERSION: 4.13.0
ENABLE_Z3: 'ON'

jobs:
build_wheels:
Expand All @@ -66,6 +65,9 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Set up MSVC development environment (Windows only)
uses: ilammy/msvc-dev-cmd@v1

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
Expand All @@ -84,24 +86,25 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "${{matrix.config.os}}-pyfiction"
save: true
max-size: 10G

- if: runner.os == 'Linux'
name: Setup mold
uses: rui314/setup-mold@v1

- if: ${{ matrix.config.arch == 'arm64' }}
name: Set Architecture to arm64 if necessary
run: echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true

- name: Build wheel
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BEFORE_ALL_LINUX: /opt/python/cp39-cp39/bin/pip install z3-solver==${{ env.Z3_VERSION }}
CIBW_BUILD: ${{ matrix.python }}-*
CIBW_ENVIRONMENT_MACOS: |
MACOSX_DEPLOYMENT_TARGET=11.0
SYSTEM_VERSION_COMPAT=0
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: 'python -m unittest discover --start-directory {project} --verbose'
- name: Build wheels
uses: pypa/cibuildwheel@v2.21

- name: Upload wheel as an artifact
uses: actions/upload-artifact@v4
Expand All @@ -120,32 +123,17 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: 'ubuntu-latest-pyfiction'
variant: ccache
save: true
max-size: 10G

- name: Setup Python
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.13.x'
cache: 'pip'

- name: Setup Z3 Solver
uses: cda-tum/setup-z3@v1
with:
version: ${{ env.Z3_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
enable-cache: true

- name: Build sdist
run: pipx run build --sdist
run: uv build --sdist

- name: Test sdist
run: z3=${{env.ENABLE_Z3}} pip install dist/*.tar.gz --verbose
- name: Check metadata
run: uvx twine check dist/*

- name: Upload sdist as an artifact
uses: actions/upload-artifact@v4
Expand Down
54 changes: 17 additions & 37 deletions .github/workflows/python-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,29 @@ defaults:

env:
Z3_VERSION: 4.13.0
ENABLE_Z3: 'ON'

jobs:
build_and_test:
python-tests:
name: 🐍 ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, macos-14, windows-2019 ]
python_version: [ '3.8.x', '3.13.x' ]
include:
- os: ubuntu-22.04
z3_platform: linux
architecture: x64
toolset: v142
- os: macos-14
z3_platform: macOS
architecture: arm64
- os: windows-2019
z3_platform: windows
architecture: x64

name: 🐍 on ${{matrix.os}} with Python ${{matrix.python_version}}
runs-on: ${{matrix.os}}

runs-on: [ ubuntu-latest, macos-13, macos-14, windows-latest ]
steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: '${{matrix.os}}-pyfiction'
variant: ccache
key: "${{matrix.runs-on}}-pyfiction"
save: true
max-size: 10G

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python_version}}
cache: 'pip'

- if: runner.os == 'Linux'
name: Setup mold
uses: rui314/setup-mold@v1
Expand All @@ -90,15 +70,15 @@ jobs:
uses: cda-tum/setup-z3@v1
with:
version: ${{env.Z3_VERSION}}
platform: ${{matrix.z3_platform}}
architecture: ${{matrix.architecture}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Build pyfiction
working-directory: ${{github.workspace}}
run: z3=${{env.ENABLE_Z3}} pip install '.[test]'
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true

- name: Setup nox
uses: wntrblm/nox@2024.10.09

- name: Test
working-directory: ${{github.workspace}}
run: python -m unittest discover --verbose
- name: 🐍 Test
run: nox -s tests --verbose
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/ubuntu.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -20,7 +20,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/ubuntu.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:

concurrency:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/windows.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
pull_request:
branches: [ 'main' ]
paths:
Expand All @@ -20,7 +20,7 @@ on:
- '**/CMakeLists.txt'
- 'libs/**'
- '.github/workflows/windows.yml'
- '!bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
- '!bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp'
merge_group:

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ci:
autoupdate_commit_msg: "⬆️ Bump pre-commit hooks"
autofix_commit_msg: "🎨 Incorporated pre-commit fixes"

exclude: "^libs/|^benchmarks/|bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"
exclude: "^libs/|^benchmarks/|bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp"

repos:
# Standard hooks
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Project (https://github.com/lefticus/cpp_starter_project) and CMake Template
# (https://github.com/cpp-best-practices/cmake_template)

cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.21...3.29)

# Only set the CMAKE_CXX_STANDARD if it is not set by someone else
if(NOT DEFINED CMAKE_CXX_STANDARD)
Expand Down
32 changes: 0 additions & 32 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(pyfiction)
add_subdirectory(mnt)
1 change: 1 addition & 0 deletions bindings/mnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(pyfiction)
2 changes: 1 addition & 1 deletion bindings/__init__.py → bindings/mnt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from pathlib import Path

if sys.platform == "win32" and sys.version_info > (3, 8, 0) and "Z3_ROOT" in os.environ:
if sys.platform == "win32" and "Z3_ROOT" in os.environ:
lib_path = Path(os.environ["Z3_ROOT"]) / "lib"
if lib_path.exists():
os.add_dll_directory(str(lib_path))
Expand Down
Loading

0 comments on commit b7901a3

Please sign in to comment.