From e5f8875152a382e45758a4e9d531f0d2045937cb Mon Sep 17 00:00:00 2001 From: Yumeng Chen Date: Wed, 24 Jan 2024 09:41:14 +0000 Subject: [PATCH] conda package for Linux done --- conda.recipe/build.sh | 6 +----- setup.cfg | 3 ++- setup.py | 14 +++++++++++--- setup_mac.cfg | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/conda.recipe/build.sh b/conda.recipe/build.sh index 089ec8e8..58262bca 100644 --- a/conda.recipe/build.sh +++ b/conda.recipe/build.sh @@ -1,11 +1,7 @@ #!/usr/bin/env bash set -ex -sed -i "s^use_MKL=^use_MKL=True^g" setup.cfg -sed -i "s^MKLROOT=^MKLROOT=${CONDA_PREFIX}/lib^g" setup.cfg - # Install the Python package, but without dependencies, # because Conda takes care of that -$PYTHON -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv -sed -i "s^MKLROOT=${CONDA_PREFIX}/lib^MKLROOT=^g" setup.cfg \ No newline at end of file +$PYTHON -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 31cc6cb3..f3d9f46d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,13 +24,14 @@ CPP_DEFS = -DUSE_PDAF [pyPDAF] pwd = /home/runner/work/pyPDAF/pyPDAF/ CC = mpicc +condaBuild = # if MKL is used, give the path to the static MKL library use_MKL= MKLROOT= # if dynamic/shared liblapack and libblas library is used, # give the library path and flags LAPACK_PATH= -LAPACK_Flag= +LAPACK_Flag=lapack,blas # GIVE MPI information MPI_INC_PATH= MPI_MOD_PATH= diff --git a/setup.py b/setup.py index 2c68e24e..bc0e3372 100644 --- a/setup.py +++ b/setup.py @@ -95,11 +95,17 @@ # linking BLAS/LAPACK use_MKL=dist.get_option_dict('pyPDAF')['use_MKL'][1] if use_MKL == 'True': - MKLROOT=dist.get_option_dict('pyPDAF')['MKLROOT'][1] + condaBuild = dist.get_option_dict('pyPDAF')['condaBuild'][1] + if condaBuild == 'True': + MKLROOT = os.path.join(os.environ['PREFIX'], 'lib') + else: + MKLROOT = dist.get_option_dict('pyPDAF')['MKLROOT'][1] + if os.name == 'nt': library_dirs+=[MKLROOT,] libraries = ['mkl_core', 'mkl_sequential', 'mkl_intel_lp64'] else: + extra_objects+=['-Wl,--start-group', f'{MKLROOT}/libmkl_intel_lp64.a', f'{MKLROOT}/libmkl_sequential.a', @@ -130,8 +136,10 @@ # add fortran library to the linking if os.name != 'nt': suffix = 'dylib' if sys.platform == 'darwin' else 'so' - result = subprocess.run(['gfortran', '--print-file', 'libgfortran.'+suffix], stdout=subprocess.PIPE) - result = result.stdout.decode()[:-18] if sys.platform == 'darwin' else result.stdout.decode()[:-15] + result = subprocess.run(['gfortran', '--print-file', + 'libgfortran.'+suffix], stdout=subprocess.PIPE) + result = result.stdout.decode() + result = result[:-18] if sys.platform == 'darwin' else result[:-15] library_dirs+=[result,] library_dirs+=['/usr/lib', ] # somehow gfortran is always necessary diff --git a/setup_mac.cfg b/setup_mac.cfg index 09d46f9b..ea6843e5 100644 --- a/setup_mac.cfg +++ b/setup_mac.cfg @@ -41,7 +41,7 @@ MKLROOT= # if dynamic/shared liblapack and libblas library is used, # give the library path and flags LAPACK_PATH= -LAPACK_Flag= +LAPACK_Flag=lapack,blas # GIVE MPI information MPI_INC_PATH= MPI_MOD_PATH=