Skip to content

Commit 5c9cfe5

Browse files
merge main and fix conflicts
Signed-off-by: Laurynas Jagutis <[email protected]>
2 parents d39f43c + dfcc11f commit 5c9cfe5

File tree

13 files changed

+162
-307
lines changed

13 files changed

+162
-307
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
name: 'Enable MSVC'
6+
description: 'Sets up Microsoft Visual C++ Build Tools on the runner'
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Setup MSVC Build Tools
12+
shell: pwsh
13+
run: |
14+
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
15+
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
16+
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
17+
18+
Add-Content $env:GITHUB_ENV "VCINSTALLDIR=$env:VCINSTALLDIR"
19+
Add-Content $env:GITHUB_ENV "PATH=$env:PATH"
20+
Add-Content $env:GITHUB_ENV "INCLUDE=$env:INCLUDE"
21+
Add-Content $env:GITHUB_ENV "LIB=$env:LIB"
22+
Add-Content $env:GITHUB_ENV "LIBPATH=$env:LIBPATH"

.github/conda_pgm_env.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ dependencies:
77
# build env
88
- python=3.12
99
- pip
10-
- wheel
11-
- setuptools
10+
- scikit-build-core
1211
# build deps
1312
- libboost-headers
1413
- eigen

.github/workflows/build-test-release.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ jobs:
4444

4545
- name: Build SDist
4646
run: |
47-
cat PYPI_VERSION
47+
cp PYPI_VERSION VERSION
48+
cat VERSION
4849
pip install build
4950
python -m build --sdist --outdir wheelhouse .
5051
5152
- name: Keep version file
5253
uses: actions/upload-artifact@v4
5354
with:
5455
name: version
55-
path: PYPI_VERSION
56+
path: VERSION
5657

5758
- name: Keep SDist
5859
uses: actions/upload-artifact@v4
@@ -122,13 +123,12 @@ jobs:
122123
- name: Install conda environment
123124
run: |
124125
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest
125-
126+
127+
- uses: ./.github/actions/enable-msvc
128+
if: runner.os == 'Windows'
129+
126130
- name: Build and test
127131
run: |
128-
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
129-
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
130-
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
131-
132132
# Resolve dirty PATH environment
133133
# TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved
134134
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'
@@ -202,6 +202,9 @@ jobs:
202202
name: version
203203
path: .
204204

205+
- uses: ./.github/actions/enable-msvc
206+
if: runner.os == 'Windows'
207+
205208
- name: Set up XCode
206209
if: matrix.os == 'macos-15'
207210
uses: maxim-lobanov/setup-xcode@v1
@@ -257,12 +260,12 @@ jobs:
257260
conda info
258261
conda list
259262
263+
- uses: ./.github/actions/enable-msvc
264+
if: runner.os == 'Windows'
265+
260266
- name: Build and install cmake target for Windows
261267
if: matrix.os == 'windows'
262268
run: |
263-
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
264-
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
265-
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
266269
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/ -S .
267270
cmake --build build/ --verbose -j1
268271
cmake --install build/ --prefix ${env:CONDA_PREFIX}/Library
@@ -275,7 +278,7 @@ jobs:
275278
cmake --install build/
276279
277280
- name: Build python
278-
run: python -m pip install . -vv --no-build-isolation --no-deps
281+
run: python -m pip install . --no-build-isolation --no-deps -C wheel.cmake=false
279282

280283
- name: Test
281284
run: pytest
@@ -319,7 +322,7 @@ jobs:
319322

320323
- name: Get tag
321324
id: tag
322-
run: echo "tag=v$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
325+
run: echo "tag=v$(cat VERSION)" >> $GITHUB_OUTPUT
323326

324327
- name: Display tag
325328
run: echo "${{ steps.tag.outputs.tag }}"

MANIFEST.in

Lines changed: 0 additions & 11 deletions
This file was deleted.

cmake/pgm_version.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
cmake_minimum_required (VERSION 3.23)
66

77
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" _PGM_VERSION)
8-
string(STRIP ${_PGM_VERSION} PGM_VERSION)
8+
string(STRIP ${_PGM_VERSION} _PGM_VERSION_STRIPPED)
9+
string(REGEX REPLACE "^([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" PGM_VERSION "${_PGM_VERSION_STRIPPED}")

docs/advanced_documentation/build-guide.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ The table below shows the C++ build dependencies
8989

9090
The table below shows the Python dependencies
9191

92-
| Library name | Remark | License |
93-
| --------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------ |
94-
| [pybuild-header-dependency](https://github.com/TonyXiang8787/pybuild-header-dependency) | build dependency | [BSD-3](https://github.com/TonyXiang8787/pybuild-header-dependency/blob/main/LICENSE) |
95-
| [numpy](https://numpy.org/) | build/runtime dependency | [BSD-3](https://github.com/numpy/numpy/blob/main/LICENSE.txt) |
96-
| [wheel](https://github.com/pypa/wheel) | build dependency | [MIT](https://github.com/pypa/wheel/blob/main/LICENSE.txt) |
97-
| [pytest](https://github.com/pytest-dev/pytest) | Development dependency | [MIT](https://github.com/pytest-dev/pytest/blob/main/LICENSE) |
98-
| [pytest-cov](https://github.com/pytest-dev/pytest-cov) | Development dependency | [MIT](https://github.com/pytest-dev/pytest-cov/blob/master/LICENSE) |
99-
| [msgpack-python](https://github.com/msgpack/msgpack-python) | Development dependency | [Apache License, Version 2.0](https://github.com/msgpack/msgpack-python/blob/main/COPYING) |
92+
| Library name | Remark | License |
93+
| ---------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------ |
94+
| [numpy](https://numpy.org/) | runtime dependency | [BSD-3](https://github.com/numpy/numpy/blob/main/LICENSE.txt) |
95+
| [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) |
96+
| [pytest](https://github.com/pytest-dev/pytest) | Development dependency | [MIT](https://github.com/pytest-dev/pytest/blob/main/LICENSE) |
97+
| [pytest-cov](https://github.com/pytest-dev/pytest-cov) | Development dependency | [MIT](https://github.com/pytest-dev/pytest-cov/blob/master/LICENSE) |
98+
| [msgpack-python](https://github.com/msgpack/msgpack-python) | Development dependency | [Apache License, Version 2.0](https://github.com/msgpack/msgpack-python/blob/main/COPYING) |
10099

101100
## Build Python Package
102101

docs/user_manual/components.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,11 @@ See the documentation on [state estimation calculation methods](calculations.md#
985985
per method on how the variances are taken into account for both the global and local angle measurement types and for the
986986
individual phases.
987987

988+
```{note}
989+
The combination of `i_measured=0` and `i_angle_measured=nπ/2` renders the current sensor invalid for PGM.
990+
See [State estimate sensor transformations](calculations.md#state-estimate-sensor-transformations).
991+
```
992+
988993
##### Steady state output
989994

990995
```{note}
@@ -1016,7 +1021,9 @@ Global angle current measurements require at least one voltage angle measurement
10161021
As a sign convention, the angle is the phase shift of the current relative to the reference angle, i.e.,
10171022

10181023
$$
1019-
\underline{I} = \text{i_measured} \cdot e^{j \text{i_angle_measured}} \text{ .}
1024+
\begin{eqnarray}
1025+
\underline{I} = \text{i}_{\text{measured}} \cdot e^{j \text{i}_{\text{angle,measured}}} \text{ .}
1026+
\end{eqnarray}
10201027
$$
10211028

10221029
```{warning}
@@ -1033,8 +1040,8 @@ As a result, the global current phasor depends on the local voltage phase offset
10331040
formula.
10341041

10351042
$$
1036-
\underline{I} = \underline{I}_{\text{local}}^{*} \frac{\underline{U}}{|\underline{U}|}
1037-
= \text{i_measured} \cdot e^{\mathrm{j} \left(\theta_{U} - \text{i_angle_measured}\right)}
1043+
\underline{I} = \underline{I}_{\text{local}}^{*} \frac{\underline{U}}{|\underline{U}|}
1044+
= \text{i}_{\text{measured}} \cdot e^{\mathrm{j} \left(\theta_{U} - \text{i}_{\text{angle,measured}}\right)}
10381045
$$
10391046

10401047
```{note}

pyproject.toml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44

55
[build-system]
66
requires = [
7-
"setuptools",
8-
"wheel",
9-
"pybuild-header-dependency",
10-
"msgpack-cxx",
11-
"nlohmann-json",
12-
"libboost-headers"
7+
"scikit-build-core",
8+
"pgm-build-dependencies@https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl"
139
]
14-
build-backend = "setuptools.build_meta"
10+
build-backend = "scikit_build_core.build"
1511

1612
[project]
1713
name = "power-grid-model"
@@ -61,15 +57,38 @@ Documentation = "https://power-grid-model.readthedocs.io/en/stable/"
6157
Mailing-list = "https://lists.lfenergy.org/g/powergridmodel"
6258
Discussion = "https://github.com/orgs/PowerGridModel/discussions"
6359

64-
[tool.setuptools.packages.find]
65-
where = ["src"]
66-
namespaces = false
60+
[project.entry-points."cmake.root"]
61+
power_grid_model = "power_grid_model._core.power_grid_model_c"
6762

68-
[tool.setuptools.dynamic]
69-
version = { file = "PYPI_VERSION" }
63+
[tool.scikit-build]
64+
logging.level = "INFO"
7065

71-
[tool.setuptools.package-data]
72-
"power_grid_model" = ["py.typed"]
66+
cmake.version = ">=3.23"
67+
cmake.build-type = "Release"
68+
cmake.args = ["-GNinja"]
69+
70+
build-dir = "build"
71+
72+
search.site-packages = false
73+
74+
ninja.version = ">=1.10"
75+
ninja.make-fallback = false
76+
77+
wheel.install-dir = "power_grid_model/_core/power_grid_model_c"
78+
wheel.py-api = "py3"
79+
80+
[tool.scikit-build.metadata.version]
81+
provider = "scikit_build_core.metadata.regex"
82+
input = "VERSION"
83+
regex = "^\\s*(?P<version>[^\\s]+)\\s*$"
84+
result = "{version}"
85+
86+
# when build in CI, force single thread to avoid out of memory errors
87+
[[tool.scikit-build.overrides]]
88+
if.any.env.CIBUILDWHEEL = true
89+
if.any.env.GITHUB_ACTIONS = true
90+
if.any.env.READTHEDOCS = true
91+
build.tool-args = ["-j1"]
7392

7493
[tool.pytest.ini_options]
7594
testpaths = ["tests/unit"]
@@ -162,7 +181,8 @@ test-command = "pytest {package}/tests"
162181
# we do not support
163182
# PyPy
164183
# musllinux in aarch64
165-
skip = ["pp*", "*-musllinux_aarch64"]
184+
# disable Python 3.14 for now until it is released
185+
skip = ["pp*", "*-musllinux_aarch64", "cp314*"]
166186

167187
[tool.cibuildwheel.linux]
168188
archs = ["x86_64", "aarch64"]

0 commit comments

Comments
 (0)