1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 20:42:50 +01:00

Fix compilation issues for non-standard prefix

This commit is contained in:
q-posev 2022-05-04 17:26:38 +02:00
parent 7651d19f22
commit 0e3c325cce
2 changed files with 29 additions and 9 deletions

View File

@ -196,6 +196,8 @@ python-install: $(qmckl_h) $(qmckl_i) $(setup_py) $(qmckl_py) $(qmckl_wrap_c)
[[ ! -f pyproject.toml ]] && \ [[ ! -f pyproject.toml ]] && \
cp $(abs_srcdir)/python/{pyproject.toml,requirements.txt,README.md,setup.py} . ; \ cp $(abs_srcdir)/python/{pyproject.toml,requirements.txt,README.md,setup.py} . ; \
cp src/qmckl.py . ; \ cp src/qmckl.py . ; \
export QMCKL_INCLUDEDIR="$(prefix)/include" ; \
export QMCKL_LIBDIR="$(prefix)/lib" ; \
pip install . pip install .
python-test: $(test_py) python-test: $(test_py)

View File

@ -3,6 +3,7 @@
setup.py file for qmckl package setup.py file for qmckl package
""" """
import os, sys
from setuptools import setup, Extension from setuptools import setup, Extension
from os.path import join from os.path import join
@ -11,17 +12,34 @@ from os.path import join
with open("README.md", "r") as fh: with open("README.md", "r") as fh:
long_description = fh.read() long_description = fh.read()
# this was recommended to solve the problem of the missing numpy header files
try:
import numpy
except ImportError:
raise Exception("numpy Python package cannot be imported.")
numpy_includedir = numpy.get_include()
# Define the name of the Python package # Define the name of the Python package
MODULE_NAME = "qmckl" MODULE_NAME = "qmckl"
# derive the QMCkl libdir and includedir
QMCKL_LIBDIR = os.environ.get("QMCKL_LIBDIR", None)
QMCKL_INCLUDEDIR = os.environ.get("QMCKL_INCLUDEDIR", None)
libdir_undefined = QMCKL_LIBDIR is None or QMCKL_LIBDIR==""
includedir_undefined = QMCKL_INCLUDEDIR is None or QMCKL_INCLUDEDIR==""
# Define qmckl extension module based on SWIG interface file (requires qmckl.h) # Define qmckl extension module based on SWIG interface file (requires qmckl.h)
qmckl_module = Extension(name = "._" + MODULE_NAME, qmckl_module = Extension(name = "._" + MODULE_NAME,
sources = [ join("src", MODULE_NAME + "_wrap.c") ], sources = [ join("src", MODULE_NAME + "_wrap.c") ],
#include_dirs = [numpy_includedir], include_dirs = [numpy_includedir, QMCKL_INCLUDEDIR],
#library_dirs = [], #library_dirs = [QMCKL_LIBDIR],
runtime_library_dirs = [QMCKL_LIBDIR],
libraries = ["qmckl"], libraries = ["qmckl"],
extra_compile_args = ["-Wall"], extra_compile_args = ["-Wall"],
#extra_link_args = [h5_ldflags], extra_link_args = ["-L" + QMCKL_LIBDIR],
depends = [ join("src", "qmckl.h") ], depends = [ join("src", "qmckl.h") ],
language = "c" language = "c"
) )