Created
July 20, 2015 01:28
-
-
Save johntut/1d8edea1fd0f5f1c057c to your computer and use it in GitHub Desktop.
f2py setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
class NoNumpy(Exception): | |
pass | |
try: | |
from numpy.distutils.core import Extension | |
from numpy.distutils.core import setup | |
except ImportError: | |
raise NoNumpy('Numpy Needs to be installed ' | |
'for extensions to be compiled.') | |
def setup_package(src_files): | |
""" | |
Get source files and create a list of options for compilation. | |
""" | |
fext = [Extension(name=os.path.splitext(os.path.basename(f))[0], | |
sources=[f], | |
extra_compile_args=["-O3", | |
"-ffast-math", | |
"-fopenmp"], | |
extra_link_args=["-lgomp", | |
"-llapack", | |
"-lblas"]) | |
for f in glob.glob(src_files)] | |
setup(setup_requires=['nose'], | |
name='python-fortran', | |
description="Example setup.py for fortran modules.", | |
ext_modules=fext) | |
if __name__ == '__main__': | |
setup_package('./src/*.f90') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment