Skip to content

Commit

Permalink
conda package for Win done
Browse files Browse the repository at this point in the history
  • Loading branch information
yumengch committed Jan 25, 2024
1 parent e5f8875 commit c887982
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
3 changes: 3 additions & 0 deletions conda.recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2022

%PYTHON -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv
3 changes: 3 additions & 0 deletions conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ python:
- 3.10
- 3.11

c_compiler:
- vs2022 # [win]

mpi:
- mpich # [not win]
- msmpi # [win]
37 changes: 19 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,35 @@
extra_objects+=['-Wl,--whole-archive', f'{PDAFdir}/lib/libpdaf-var.a',
f'{pwd}/lib/libPDAFc.a', '-Wl,--no-whole-archive']

# add mpi library path
if os.name == 'nt':
# always use external msmpi as msmpi from conda cannot be linked
MPI_LIB_PATH=dist.get_option_dict('pyPDAF')['MPI_LIB_PATH'][1]
if MPI_LIB_PATH != '': library_dirs += MPI_LIB_PATH.split(',')
libraries += ['msmpi', 'msmpifec']
else:
mpifortran = 'mpiifort' if compiler == 'intel' else 'mpifort'
result = subprocess.run([mpifortran, '-show'], stdout=subprocess.PIPE)
result = result.stdout.decode()[:-1].split(' ')
s = [l[2:].replace('"', '') for l in result if l[:2] == '-L']
if len(s) > 0: library_dirs += s
s = [l[2:] for l in result if l[:2] == '-l']
if len(s) > 0: libraries += s

# linking BLAS/LAPACK
use_MKL=dist.get_option_dict('pyPDAF')['use_MKL'][1]
if use_MKL == 'True':
condaBuild = dist.get_option_dict('pyPDAF')['condaBuild'][1]
if condaBuild == 'True':
MKLROOT = os.path.join(os.environ['PREFIX'], 'lib')
MKLROOT = os.environ['LIBRARY_LIB'] if os.name == 'nt' else \
os.path.join(os.environ['PREFIX'], 'lib')
else:
MKLROOT = dist.get_option_dict('pyPDAF')['MKLROOT'][1]

assert MKLROOT != '', 'MKLROOT must not be empty, check setup.cfg file'
if os.name == 'nt':
library_dirs+=[MKLROOT,]
libraries = ['mkl_core', 'mkl_sequential', 'mkl_intel_lp64']
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',
Expand All @@ -119,20 +134,6 @@
print ('LAPACK_Flag', LAPACK_Flag)
if LAPACK_Flag != '': libraries += LAPACK_Flag.split(',')

# add mpi library path
if os.name == 'nt':
MPI_LIB_PATH=dist.get_option_dict('pyPDAF')['MPI_LIB_PATH'][1]
library_dirs+=[MPI_LIB_PATH,]
libraries += ['msmpi', 'msmpifec']
else:
mpifortran = 'mpiifort' if compiler == 'intel' else 'mpifort'
result = subprocess.run([mpifortran, '-show'], stdout=subprocess.PIPE)
result = result.stdout.decode()[:-1].split(' ')
s = [l[2:].replace('"', '') for l in result if l[:2] == '-L']
if len(s) > 0: library_dirs += s
s = [l[2:] for l in result if l[:2] == '-l']
if len(s) > 0: libraries += s

# add fortran library to the linking
if os.name != 'nt':
suffix = 'dylib' if sys.platform == 'darwin' else 'so'
Expand Down

0 comments on commit c887982

Please sign in to comment.