Skip to content

Commit

Permalink
enable conda build capability
Browse files Browse the repository at this point in the history
  • Loading branch information
yumengch committed Jan 5, 2024
1 parent 2301ba3 commit bb2b8e0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 24 deletions.
6 changes: 6 additions & 0 deletions conda.recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ex

# 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
5 changes: 5 additions & 0 deletions conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python:
- 3.8
- 3.9
- 3.10
- 3.11
40 changes: 40 additions & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% set version = "0.02" %}

package:
name: pypdaf
version: 0.0.2

source:
noarch: python
path: ..

build:
preserve_egg_dir: True

requirements:
host:
- python {{python}}
- cython
- pip
- setuptools
- numpy
- blas-devel
- liblapack
- mpi4py
build:
- make # [not win]
- {{ compiler('c') }}
- {{ compiler('fortran') }} # [not win]
run:
- python
- {{ pin_compatible('numpy') }}
- mpi4py

about:
home: https://github.com/yumengch/pyPDAF
summary: A Python interface to PDAF
description: |
pyPDAF is a python interface to the Fortran-based PDAF library
license: GPL
doc_url: https://github.com/BoldingBruggeman/eat/wiki
dev_url: https://github.com/BoldingBruggeman/eat
24 changes: 23 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
[build-system]
requires = ["setuptools", "wheel", "cython", "numpy"]
requires = ["setuptools", "wheel", "cython", "numpy"]

[project]
name = "pyPDAF"
authors = [
{name = "Yumeng Chen", email = "yumeng.chen@reading.ac.uk"},
]
version = "0.0.2"
description = "A Python interface to PDAF"
readme = "README.md"
requires-python = ">=3.8"
keywords = ["data assimilation", "PDAF"]
license = {text = "GPL License"}
classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"numpy",
]

[tool.setuptools.packages.find]
where = ["pyPDAF"]
namespaces = false
15 changes: 1 addition & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
[metadata]
name = pyPDAF
version = 0.0.2
description = A Python interface to Fortran-written PDAF data assimilation library
long_description = file: README.md, LICENSE
keywords = data assimilation, PDAF
license = GPL V3
classifiers =
License :: GPL V3
Programming Language :: Python :: 3

[options]
include_package_data = True
install_requires =
Expand All @@ -25,7 +14,7 @@ FC = mpif90
LD = mpif90
AR = ar
RANLIB = ranlib
CPP = /usr/bin/cpp
CPP = cpp
OPT = -O3 -fdefault-real-8 -fPIC
OPT_LNK =
INC = -IPDAF_V2.1/include
Expand All @@ -35,7 +24,5 @@ CPP_DEFS = -DUSE_PDAF
[pyPDAF]
pwd = /home/runner/work/pyPDAF/pyPDAF/
CC = mpicc
MPI_PATH=/usr/lib/x86_64-linux-gnu/openmpi/lib/fortran/gfortran
MPI_Flag=mpi_usempif08,mpi_mpifh,mpi
LAPACK_PATH=
LAPACK_Flag=lapack,blas
21 changes: 12 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,20 @@
# multiple-definition is thus necessary
extra_link_args=['-Wl,--allow-multiple-definition']
# setup library to MPI-fortran
MPI_PATH=dist.get_option_dict('pyPDAF')['MPI_PATH'][1]
LAPACK_PATH=dist.get_option_dict('pyPDAF')['LAPACK_PATH'][1]
print ('MPI_PATH', MPI_PATH)
print ('LAPACK_PATH', LAPACK_PATH)
library_dirs=['/usr/lib', *MPI_PATH.split(','), *LAPACK_PATH.split(',')]
library_dirs=['/usr/lib', ]
if LAPACK_PATH != '': library_dirs += LAPACK_PATH.split(',')
result = subprocess.run(['mpifort', '-show'], stdout=subprocess.PIPE)
result = result.stdout.decode()[:-1].split(' ')
s = [l[2:] for l in result if l[:2] == '-L']
if len(s) > 0: library_dirs += s
print ('library_dirs', library_dirs)
MPI_Flag=dist.get_option_dict('pyPDAF')['MPI_Flag'][1]
LAPACK_Flag=dist.get_option_dict('pyPDAF')['LAPACK_Flag'][1]
print ('MPI_Flag', MPI_Flag)
print ('LAPACK_Flag', LAPACK_Flag)
libraries=['gfortran', 'm', *MPI_Flag.split(','), *LAPACK_Flag.split(',')]
libraries=['gfortran', 'm', *LAPACK_Flag.split(',')]
s = [l[2:] for l in result if l[:2] == '-l']
if len(s) > 0: libraries += s
print ('libraries', libraries)

def compilePDAFLibraryInterface():
Expand Down Expand Up @@ -140,11 +143,11 @@ def run(self):


ext_modules = [Extension('PDAFc',
[f'pyPDAF/fortran/PDAFc.pyx']),
['pyPDAF/fortran/PDAFc.pyx']),
Extension('*',
[f'pyPDAF/UserFunc.pyx']),
['pyPDAF/UserFunc.pyx']),
Extension('*',
[f'pyPDAF/PDAF.pyx'],
['pyPDAF/PDAF.pyx'],
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
extra_link_args=extra_link_args,
Expand Down

0 comments on commit bb2b8e0

Please sign in to comment.