Skip to content

use scikit-build-core as build backend #1019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dcd6e19
remove setuptools
TonyXiang8787 Jun 15, 2025
1d37498
try first build
TonyXiang8787 Jun 15, 2025
1a9454c
don't know if header works
TonyXiang8787 Jun 15, 2025
95988d5
export cmake
TonyXiang8787 Jun 15, 2025
e41af08
try python
TonyXiang8787 Jun 15, 2025
4d382d1
seperate build dir
TonyXiang8787 Jun 15, 2025
817d105
try editable
TonyXiang8787 Jun 15, 2025
5487ab9
editable works
TonyXiang8787 Jun 15, 2025
120b8f3
add conda
TonyXiang8787 Jun 15, 2025
b023809
change PYPI version
TonyXiang8787 Jun 15, 2025
3bec816
start msvc
TonyXiang8787 Jun 15, 2025
b81346f
modify ci
TonyXiang8787 Jun 15, 2025
86cb044
action.yml
TonyXiang8787 Jun 15, 2025
be22c13
if windows
TonyXiang8787 Jun 15, 2025
b370f90
if windows
TonyXiang8787 Jun 15, 2025
e8a8576
[skip ci] version invalid for cmake
TonyXiang8787 Jun 15, 2025
9d03e9f
strip version for cmake
TonyXiang8787 Jun 15, 2025
989f10b
add lib64
TonyXiang8787 Jun 15, 2025
87205ed
Merge branch 'main' into feature/scikit-build-core
TonyXiang8787 Jun 16, 2025
20747f1
move get dll path
TonyXiang8787 Jun 16, 2025
994eedf
[skip ci] well known labels
TonyXiang8787 Jun 16, 2025
c77fd52
markdown
TonyXiang8787 Jun 16, 2025
54fddc2
downmerge ruff
TonyXiang8787 Jun 17, 2025
4e5b965
default parallel, force single thread in CI
TonyXiang8787 Jun 18, 2025
cf71df3
sdist include by default
TonyXiang8787 Jun 18, 2025
89aad17
Merge branch 'main' into feature/scikit-build-core
TonyXiang8787 Jun 23, 2025
419f774
Merge branch 'main' into feature/scikit-build-core
TonyXiang8787 Jun 24, 2025
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
23 changes: 23 additions & 0 deletions .github/actions/enable-msvc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: 'Enable MSVC'
description: 'Sets up Microsoft Visual C++ Build Tools on the runner'

runs:
using: "composite"
steps:
- name: Setup MSVC Build Tools
shell: pwsh
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'

Add-Content $env:GITHUB_ENV "VCINSTALLDIR=$env:VCINSTALLDIR"
Add-Content $env:GITHUB_ENV "PATH=$env:PATH"
Add-Content $env:GITHUB_ENV "INCLUDE=$env:INCLUDE"
Add-Content $env:GITHUB_ENV "LIB=$env:LIB"
Add-Content $env:GITHUB_ENV "LIBPATH=$env:LIBPATH"

3 changes: 1 addition & 2 deletions .github/conda_pgm_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ dependencies:
# build env
- python=3.12
- pip
- wheel
- setuptools
- scikit-build-core
# build deps
- libboost-headers
- eigen
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ jobs:

- name: Build SDist
run: |
cat PYPI_VERSION
cp PYPI_VERSION VERSION
cat VERSION
pip install build
python -m build --sdist --outdir wheelhouse .

- name: Keep version file
uses: actions/upload-artifact@v4
with:
name: version
path: PYPI_VERSION
path: VERSION

- name: Keep SDist
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -122,13 +123,12 @@ jobs:
- name: Install conda environment
run: |
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest


- uses: ./.github/actions/enable-msvc
if: runner.os == 'Windows'

- name: Build and test
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'

# Resolve dirty PATH environment
# TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'
Expand All @@ -150,7 +150,7 @@ jobs:
install\${{ env.PRESET }}\bin\power_grid_model_package_test; if(!$?) { Exit $LASTEXITCODE }

build-cpp-test-macos:
runs-on: macos-14
runs-on: macos-15
strategy:
matrix:
build-option: [ debug, release ]
Expand Down Expand Up @@ -202,6 +202,9 @@ jobs:
name: version
path: .

- uses: ./.github/actions/enable-msvc
if: runner.os == 'Windows'

- name: Set up XCode
if: matrix.os == 'macos-15'
uses: maxim-lobanov/setup-xcode@v1
Expand Down Expand Up @@ -257,12 +260,12 @@ jobs:
conda info
conda list

- uses: ./.github/actions/enable-msvc
if: runner.os == 'Windows'

- name: Build and install cmake target for Windows
if: matrix.os == 'windows'
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S .
cmake --build build/ --verbose -j1
cmake --install build/ --prefix ${env:CONDA_PREFIX}/Library
Expand All @@ -275,7 +278,7 @@ jobs:
cmake --install build/

- name: Build python
run: python -m pip install . -vv --no-build-isolation --no-deps
run: python -m pip install . --no-build-isolation --no-deps -C wheel.cmake=false

- name: Test
run: pytest
Expand Down Expand Up @@ -319,7 +322,7 @@ jobs:

- name: Get tag
id: tag
run: echo "tag=v$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
run: echo "tag=v$(cat VERSION)" >> $GITHUB_OUTPUT

- name: Display tag
run: echo "${{ steps.tag.outputs.tag }}"
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

3 changes: 2 additions & 1 deletion cmake/pgm_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
cmake_minimum_required (VERSION 3.23)

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" _PGM_VERSION)
string(STRIP ${_PGM_VERSION} PGM_VERSION)
string(STRIP ${_PGM_VERSION} _PGM_VERSION_STRIPPED)
string(REGEX REPLACE "^([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" PGM_VERSION "${_PGM_VERSION_STRIPPED}")
5 changes: 2 additions & 3 deletions docs/advanced_documentation/build-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ The table below shows the Python dependencies

| Library name | Remark | License |
| --------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------ |
| [pybuild-header-dependency](https://github.com/TonyXiang8787/pybuild-header-dependency) | build dependency | [BSD-3](https://github.com/TonyXiang8787/pybuild-header-dependency/blob/main/LICENSE) |
| [numpy](https://numpy.org/) | build/runtime dependency | [BSD-3](https://github.com/numpy/numpy/blob/main/LICENSE.txt) |
| [wheel](https://github.com/pypa/wheel) | build dependency | [MIT](https://github.com/pypa/wheel/blob/main/LICENSE.txt) |
| [numpy](https://numpy.org/) | runtime dependency | [BSD-3](https://github.com/numpy/numpy/blob/main/LICENSE.txt) |
| [scikit-build-core](https://github.com/scikit-build/scikit-build-core) | build dependency | [Apache](https://github.com/scikit-build/scikit-build-core/blob/main/LICENSE) |
| [pytest](https://github.com/pytest-dev/pytest) | Development dependency | [MIT](https://github.com/pytest-dev/pytest/blob/main/LICENSE) |
| [pytest-cov](https://github.com/pytest-dev/pytest-cov) | Development dependency | [MIT](https://github.com/pytest-dev/pytest-cov/blob/master/LICENSE) |
| [msgpack-python](https://github.com/msgpack/msgpack-python) | Development dependency | [Apache License, Version 2.0](https://github.com/msgpack/msgpack-python/blob/main/COPYING) |
Expand Down
54 changes: 35 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

[build-system]
requires = [
"setuptools",
"wheel",
"pybuild-header-dependency",
"msgpack-cxx",
"nlohmann-json",
"libboost-headers"
"scikit-build-core",
"pgm-build-dependencies@git+https://github.com/PowerGridModel/pgm-build-dependencies.git"
]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"

[project]
name = "power-grid-model"
Expand Down Expand Up @@ -55,21 +51,41 @@ doc = [
]

[project.urls]
Home-page = "https://lfenergy.org/projects/power-grid-model/"
GitHub = "https://github.com/PowerGridModel/power-grid-model"
Documentation = "https://power-grid-model.readthedocs.io/en/stable/"
Mailing-list = "https://lists.lfenergy.org/g/powergridmodel"
Discussion = "https://github.com/orgs/PowerGridModel/discussions"
homepage = "https://lfenergy.org/projects/power-grid-model/"
github = "https://github.com/PowerGridModel/power-grid-model"
documentation = "https://power-grid-model.readthedocs.io/en/stable/"
mailing-list = "https://lists.lfenergy.org/g/powergridmodel"
discussion = "https://github.com/orgs/PowerGridModel/discussions"

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false
[project.entry-points."cmake.root"]
power_grid_model = "power_grid_model.power_grid_model_c"

[tool.setuptools.dynamic]
version = { file = "PYPI_VERSION" }
[tool.scikit-build]
logging.level = "INFO"

cmake.version = ">=3.23"
cmake.build-type = "Release"
cmake.args = ["-GNinja"]

build-dir = "build"
build.tool-args = ["-j1"]

search.site-packages = false

ninja.version = ">=1.10"
ninja.make-fallback = false

sdist.include = ["CMakeLists.txt", "power_grid_model_c/", "cmake/", "VERSION"]

wheel.install-dir = "power_grid_model/power_grid_model_c"
wheel.py-api = "py3"

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "VERSION"
regex = "^\\s*(?P<version>[^\\s]+)\\s*$"
result = "{version}"

[tool.setuptools.package-data]
"power_grid_model" = ["py.typed"]

[tool.pytest.ini_options]
testpaths = ["tests/unit"]
Expand Down
Loading
Loading