Skip to content

Commit

Permalink
Customize install with EASTEREIG_USE_FPOLY.
Browse files Browse the repository at this point in the history
  - The default not use fortran compiler
  • Loading branch information
nennigb committed Mar 12, 2024
1 parent aac3818 commit d331674
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# -*- coding: utf-8 -*-
import setuptools
import os
# Usefull to build f90 files
from numpy.distutils.core import Extension, setup

with open("README.md", "r") as fh:
long_description = fh.read()

# Define f90 module to include
ext_fpoly = Extension(name='eastereig.fpoly.fpolyval',
sources=['eastereig/fpoly/fpolyval.f90'])
# Use env var to activate fpoly, defaut is false
USE_FPOLY = os.getenv('EASTEREIG_USE_FPOLY', 'False').lower() in ('true', '1', 't')
if USE_FPOLY:
# Define f90 module to include
ext_fpoly = Extension(name='eastereig.fpoly._fpolyval',
sources=['eastereig/fpoly/fpolyval.f90'])
ext_modules = [ext_fpoly]
print('Use fortran fpoly submodule.', 'Set environnement variable:',
'`EASTEREIG_USE_FPOLY=False` to activate full python version.')
else:
ext_modules = []
print('Use full python version. Set environnement variable:',
'`EASTEREIG_USE_FPOLY=True` to activate fortran version.')


def _getversion():
""" Get version from VERSION."""
Expand Down Expand Up @@ -37,7 +49,7 @@ def _getversion():
# we can use find_packages() to automatically discover all subpackages
packages=setuptools.find_packages(),
# build f90 module
ext_modules=[ext_fpoly],
ext_modules=ext_modules,
install_requires=['numpy',
'scipy',
'matplotlib'],
Expand Down

0 comments on commit d331674

Please sign in to comment.