Skip to content

Commit

Permalink
Attempt to fix shared lib problem, mesonbuild/meson-python#700
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Dec 3, 2024
1 parent 44de7a8 commit 3936518
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ jobs:
path-type: minimal
release: false

# - name: Set Windows env
# if: matrix.os == 'windows-latest'
# shell: bash
# run: |
# set -e
# # Add MSYS2 paths
# echo "C:/msys64/mingw64/bin" >> $GITHUB_PATH
# # Set library and include paths for meson
# echo "LIBRARY_PATH=C:/msys64/mingw64/lib" >> $GITHUB_ENV
# echo "CPATH=C:/msys64/mingw64/include" >> $GITHUB_ENV
# echo "PKG_CONFIG_PATH=C:/msys64/mingw64/lib/pkgconfig" >> $GITHUB_ENV
# echo "OPENBLAS_NUM_THREADS=1" >> $GITHUB_ENV

# NOTE: No MacOS specific install.
# We'll use the Accelerate framework instead of installing BLAS/LAPACK

Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ libpfapack = shared_library('pfapack',
fortran_sources,
dependencies: [lapack_dep, blas_dep, thread_dep, m_dep],
install: true,
install_dir: py.get_install_dir() / 'pfapack', # Install in package directory
)

# Include directories
Expand All @@ -159,6 +160,7 @@ libcpfapack = shared_library('cpfapack',
link_with: libpfapack,
dependencies: [lapack_dep, blas_dep, thread_dep, m_dep],
install: true,
install_dir: py.get_install_dir() / 'pfapack', # Install in package directory
)

# Python module
Expand Down
17 changes: 17 additions & 0 deletions pfapack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# pfapack Python package
import os
import sys
from pathlib import Path

from pfapack._version import __version__


def _enable_sharedlib_loading():
"""Enable loading of shared libraries from the package directory."""
if sys.platform == "win32":
# Get the directory containing the shared libraries
pkg_dir = Path(__file__).parent
if hasattr(os, "add_dll_directory"):
os.add_dll_directory(str(pkg_dir))


# Call this before loading the shared libraries
_enable_sharedlib_loading()

__all__ = ["__version__"]

0 comments on commit 3936518

Please sign in to comment.