Repository navigation
MKL build updates - #28
Merged
Merged
Conversation
This commit enables `pydiso` to be built and installed successfully against Intel MKL
packages sourced directly from PyPI. Previously, building with PyPI-distributed MKL
was challenging due to difficulties in locating build components and runtime libraries.
Key changes address these issues:
* **Build system (Meson):** Automatically configures `pkg_config_path` to locate
`mkl-devel` and `mkl-include` files when installed by pip.
* **Runtime linking:** Implements platform-specific fixes to ensure the compiled
extension can find MKL shared libraries on Windows (via `add_dll_directory`)
and Linux/macOS (via `RPATH`).
* **CI updates:** Introduces dedicated CI jobs to validate the PyPI MKL build and
test path, alongside existing conda-based tests.
* **Dependencies:** Adds `mkl`, `mkl-devel`, `mkl-include`, and `pkgconf` to
`pyproject.toml`, allowing pip to resolve these MKL components.
* **Documentation:** Updates `README.md` to provide clear instructions for building
against PyPI MKL.
These changes significantly broaden `pydiso`'s accessibility for users who prefer
installing with pip in standard virtual environments.
Moves the `os.add_dll_directory` logic for MKL runtime libraries into a dedicated `_init_helper.py` module, mirroring the approach used by `mkl-service`. This ensures reliable discovery of MKL DLLs in standard Python virtual environments on Windows (e.g., `venv`, `virtualenv`) while avoiding conflicts with conda environments. Adds pytest configuration to use `--import-mode=importlib`. This prevents pytest from shadowing the installed `pydiso` package with the source tree, ensuring tests accurately validate the compiled extensions and MKL runtime path resolution.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
==========================================
- Coverage 89.66% 85.46% -4.21%
==========================================
Files 3 4 +1
Lines 571 619 +48
Branches 69 78 +9
==========================================
+ Hits 512 529 +17
- Misses 32 62 +30
- Partials 27 28 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The previous `pkg_config_path` heuristic, based on `sysconfig.get_path("data")`, was unreliable for `mkl-devel` packages installed by pip, particularly in isolated build environments. `sysconfig` reflects the build interpreter's prefix, not the actual installation path of `mkl-devel`'s pkg-config files, which might be in an overlaid directory.
This update uses `importlib.metadata` to query the `mkl-devel` package directly for the location of its `.pc` files, ensuring accurate discovery irrespective of the build environment's specifics.
Meson's default CMake search heuristics fail to find `MKLConfig.cmake` from pip-installed `mkl-devel` in certain virtual environments, especially on Windows. This change explicitly configures `cmake_prefix_path` using `importlib.metadata` to guarantee correct MKL location. Additionally, the `mkl-devel` PyPI wheel for macOS (frozen at 2023.2) is missing a symlink needed by CMake, causing MKL import failures. macOS builds are now excluded from CI, with documentation clarifying the issue and recommending conda-forge for macOS users.
… DLL discovery Introduce `mkl-link` as a new build option, enabling static or per-component dynamic MKL linking. Static linking allows for building a fully self-contained extension, removing the runtime `mkl` dependency when using sequential threading. Enhance Windows MKL DLL discovery to prioritize `MKLROOT` and package metadata, ensuring robustness across various MKL installation methods (e.g., oneAPI toolkit, pip/conda `mkl` package).
| with: | ||
| verbose: true # optional (default = false) | ||
| token: ${{ secrets.CODECOV_TOKEN }} # required | ||
| - uses: actions/checkout@v5 |
There was a problem hiding this comment.
A minor tip, since it fits the context of GitHub Actions: it might be good to update versions of different actions to remove the warnings about Node.js 20 deprecation. E.g., actions/checkout@v4 -> actions/checkout@v5 or v6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accomplishes a few things,