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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// cache pip installs
"mounts": ["type=volume,source=dev-pip-cache,target=/root/.cache/uv"],

"postCreateCommand": "uv sync && uv run pre-commit install || true && npm ci",
"postCreateCommand": "uv sync --frozen && uv run pre-commit install || true && npm ci",

"customizations": {
"vscode": {
Expand Down
21 changes: 20 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,23 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "cron"
cronjob: "0 4 * * 2" # Every Tuesday at 4:00 UTC
groups:
all-dependencies:
patterns:
- "*"
cooldown:
default-days: 7

- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "cron"
cronjob: "0 4 * * 2" # Every Tuesday at 4:00 UTC
groups:
all-dependencies:
patterns:
- "*"
cooldown:
default-days: 7
Comment thread
TonyXiang8787 marked this conversation as resolved.
16 changes: 8 additions & 8 deletions .github/workflows/check-code-quality.yml
Comment thread
figueroa1395 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ jobs:

- name: Install most linters from uv
run: |
CC=gcc-14 CXX=g++-14 uv sync --group lint
CC=gcc-14 CXX=g++-14 uv sync --locked --group lint

- name: Run mypy
run: |
uv run mypy .
uv run --frozen mypy .

- name: Run ruff
run: |
uv run ruff check .
uv run ruff format .
uv run --frozen ruff check .
uv run --frozen ruff format .
git restore README.md

- name: Run clang-format
run: |
git ls-files -z -- '*.h' '*.c' '*.cpp' '*.hpp' '*.cc' '*.cxx' | xargs -0 -r uv run clang-format -style=file -i
git ls-files -z -- '*.h' '*.c' '*.cpp' '*.hpp' '*.cc' '*.cxx' | xargs -0 -r uv run --frozen clang-format -style=file -i

- name: Run cmake-linter
run: |
uv run gersemi -i --warnings-as-errors src/ tests/ cmake/
uv run --frozen gersemi -i --warnings-as-errors src/ tests/ cmake/

- name: Install npm packages
run: |
Expand All @@ -77,8 +77,8 @@ jobs:
- name: Check generated code
if: success()
run: |
uv sync --group code-generation
uv run code_generation/code_gen.py
uv sync --locked --group code-generation
uv run --frozen code_generation/code_gen.py
if [ -n "$(git status --porcelain)" ]; then
echo
echo "The following files are outdated or were manually updated:"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-lock-and-linter-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Install linters from uv
run: |
uv sync --only-group lint
uv sync --locked --only-group lint
- name: retrieve uv package versions
id: versions_uv
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:

- name: Python test and coverage
run: |
CC=clang CXX=clang++ uv sync --no-default-groups --group test
uv run pytest
CC=clang CXX=clang++ uv sync --locked --no-default-groups --group test
uv run --frozen pytest
Comment thread
figueroa1395 marked this conversation as resolved.

- name: Run build-wrapper for C++
run: |
Expand Down
62 changes: 33 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,58 @@
# SPDX-License-Identifier: MPL-2.0

repos:
- repo: https://github.com/fsfe/reuse-tool # outside pypi
rev: v6.2.0
- repo: local
hooks:
- id: reuse
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.22
hooks:
# Run the linter.
- id: ruff-check
name: ruff-check
args: [ --fix ]
# Run the formatter.
name: reuse
entry: uv run --frozen reuse lint
Comment thread
mgovers marked this conversation as resolved.
Comment thread
mgovers marked this conversation as resolved.
language: system
pass_filenames: false
- id: pytest
name: pytest
entry: uv run --frozen pytest
language: system
pass_filenames: false
types_or: [ python, c++, c ]
- id: ruff-format
name: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.3.0
hooks:
entry: uv run --frozen ruff format
language: system
pass_filenames: false
types: [ python ]
- id: ruff-check
name: ruff-check
entry: uv run --frozen ruff check
language: system
pass_filenames: false
types: [ python ]
- id: mypy
additional_dependencies:
- numpy
- repo: local
hooks:
- id: pytest
name: pytest
entry: uv run pytest
name: mypy
entry: uv run --frozen mypy .
language: system
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
hooks:
types: [ python ]
- id: clang-format
name: clang-format
entry: uv run --frozen clang-format -style=file -i
language: system
pass_filenames: true
types_or: [ c++, c ]
- repo: https://github.com/BlankSpruce/gersemi-pre-commit
rev: 0.27.7
hooks:
- id: gersemi
name: cmake-linter
alias: cmake-linter
entry: uv run --frozen gersemi -i --warnings-as-errors
language: system
pass_filenames: true
types: [ cmake ]
- repo: https://github.com/igorshubovych/markdownlint-cli # outside pypi
rev: v0.49.1
hooks:
- id: markdownlint
args: ["--fix"]
# format .json and .jsonc files
- repo: https://github.com/biomejs/pre-commit # outside pypi
rev: v2.5.4
rev: v2.5.6
hooks:
# configuration is located in biome.jsonc
- id: biome-format
Expand Down
60 changes: 32 additions & 28 deletions .pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,50 @@
# SPDX-License-Identifier: MPL-2.0

repos:
- repo: https://github.com/fsfe/reuse-tool # outside pypi
rev: v6.2.0
- repo: local
hooks:
- id: reuse
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v{{ ruff }}
hooks:
# Run the linter.
- id: ruff-check
name: ruff-check
args: [ --fix ]
# Run the formatter.
name: reuse
entry: uv run --frozen reuse lint
language: system
pass_filenames: false
- id: pytest
name: pytest
entry: uv run --frozen pytest
language: system
pass_filenames: false
types_or: [ python, c++, c ]
- id: ruff-format
name: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v{{ mypy }}
hooks:
entry: uv run --frozen ruff format
language: system
pass_filenames: false
types: [ python ]
- id: ruff-check
name: ruff-check
entry: uv run --frozen ruff check
language: system
pass_filenames: false
types: [ python ]
- id: mypy
additional_dependencies:
- numpy
- repo: local
hooks:
- id: pytest
name: pytest
entry: uv run pytest
name: mypy
entry: uv run --frozen mypy .
language: system
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v{{ clang_format }}
hooks:
types: [ python ]
- id: clang-format
name: clang-format
entry: uv run --frozen clang-format -style=file -i
language: system
pass_filenames: true
types_or: [ c++, c ]
- repo: https://github.com/BlankSpruce/gersemi-pre-commit
rev: {{ gersemi }}
hooks:
- id: gersemi
name: cmake-linter
alias: cmake-linter
entry: uv run --frozen gersemi -i --warnings-as-errors
language: system
pass_filenames: true
types: [ cmake ]
- repo: https://github.com/igorshubovych/markdownlint-cli # outside pypi
rev: v{{ markdownlint_cli }}
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build:
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- CC=gcc-14 CXX=g++-14 UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group doc
- CC=gcc-14 CXX=g++-14 UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --locked --group doc
post_install:
# remove API DLL define in header
- find power_grid_model_c/power_grid_model_c/include -name *.h -exec sed -i -r "s/#define PGM.*//g" {} \;
Expand Down
15 changes: 13 additions & 2 deletions docs/advanced_documentation/build-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ These are handled automatically in CI. For local development, use your system's
* Latest XCode release tested in CI.

```{note}
Once your compiler of choice is installed, you need to define the environment variables `CC` and `CXX` to specify the compiler. For example `export CC=clang-18` and `export CXX=clang++-18` to select the `clang` compiler in Ubuntu.
Once your compiler of choice is installed, you need to define the environment variables `CC` and `CXX` to specify the
compiler.
For example `export CC=clang-18` and `export CXX=clang++-18` to select the `clang` compiler in Ubuntu.
```

### Build System for CMake Project
Expand All @@ -97,16 +99,20 @@ This repository uses [CMake](https://cmake.org/) (version 3.23 or later) as its
The table below shows the C++ build dependencies.

```{note}
The C++ dependencies below are **build-time only**. When building the Python package from source (via `uv sync`), they are automatically downloaded and used during the build — you do not need to install them manually. Manual installation is only required for standalone CMake builds.
The C++ dependencies below are **build-time only**. When building the Python package from source (via `uv sync`), they
are automatically downloaded and used during the build — you do not need to install them manually.
Manual installation is only required for standalone CMake builds.
```

<!-- pyml disable line-length-->
| Library name | Requirements to build Python package | Requirements to build CMake project | Remark | License |
| ------------------------------------------------------------------- | ------------------------------------ | ------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------ |
| [boost](https://www.boost.org/) | Installed automatically | CMake needs to be able find `boost` | header-only | [Boost Software License - Version 1.0](https://www.boost.org/LICENSE_1_0.txt) |
| [eigen3](https://eigen.tuxfamily.org/) | Installed automatically | CMake needs to be able find `eigen3` | header-only | [Mozilla Public License, version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) |
| [nlohmann-json](https://github.com/nlohmann/json) | Installed automatically | CMake needs to be able find `nlohmann_json` | header-only | [MIT](https://github.com/nlohmann/json/blob/develop/LICENSE.MIT) |
| [msgpack-cxx](https://github.com/msgpack/msgpack-c/tree/cpp_master) | Installed automatically | CMake needs to be able find `msgpack-cxx` | header-only | [Boost Software License - Version 1.0](https://github.com/msgpack/msgpack-c/blob/cpp_master/LICENSE_1_0.txt) |
| [doctest](https://github.com/doctest/doctest) | None | CMake needs to be able find `doctest` | header-only | [MIT](https://github.com/doctest/doctest/blob/master/LICENSE.txt) |
<!-- pyml enable line-length-->

To install the C++ dependencies for a CMake build, use your platform's package manager of choice.
In the platform-specific examples below, we will give some suggestions.
Expand All @@ -120,6 +126,7 @@ Set `CMAKE_PREFIX_PATH` to the installation prefix of your package manager so CM

The table below shows the Python dependencies.

<!-- pyml disable line-length-->
| Library name | Remark | License |
|------------------------------------------------------------------------|------------------------|--------------------------------------------------------------------------------------------|
| [numpy](https://numpy.org/) | Runtime dependency | [BSD-3](https://github.com/numpy/numpy/blob/main/LICENSE.txt) |
Expand All @@ -128,6 +135,7 @@ The table below shows the Python dependencies.
| [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) |
| [uv](https://github.com/astral-sh/uv) | Development dependency | [Apache License, Version 2.0](https://github.com/astral-sh/uv/blob/main/LICENSE-APACHE) |
<!-- pyml enable line-length-->

## Build Python Package

Expand Down Expand Up @@ -355,9 +363,11 @@ conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eig

Set `CMAKE_PREFIX_PATH` so CMake can locate the C++ libraries. In PowerShell:

<!-- pyml disable commands-show-output-->
```powershell
$env:CMAKE_PREFIX_PATH = C:\conda_envs\cpp_pkgs\Library
```
<!-- pyml enable commands-show-output-->

To make it persistent across sessions:

Expand Down Expand Up @@ -464,6 +474,7 @@ As a quick start, from the root of the repository:

```{note}
Test coverage is not supported on macOS.
```

## Package tests

Expand Down
Loading
Loading