| 1 | from distutils.core import setup |
|---|
| 2 | import os.path, sys |
|---|
| 3 | |
|---|
| 4 | build_gauss = False |
|---|
| 5 | |
|---|
| 6 | setup_path = os.path.split(os.path.abspath(__file__))[0] |
|---|
| 7 | sys.path.append(os.path.join(setup_path, 'metpy')) |
|---|
| 8 | import version |
|---|
| 9 | version.write_svn_version() |
|---|
| 10 | ver = version.get_version() |
|---|
| 11 | sys.path.pop() |
|---|
| 12 | |
|---|
| 13 | # Optionally build the gaussian filter code |
|---|
| 14 | if build_gauss: |
|---|
| 15 | from numpy.distutils.misc_util import get_numpy_include_dirs |
|---|
| 16 | include_dirs = get_numpy_include_dirs() |
|---|
| 17 | from distutils.extension import Extension |
|---|
| 18 | |
|---|
| 19 | # If we find Cython, build from the pyx file, otherwise just build the |
|---|
| 20 | # C file |
|---|
| 21 | try: |
|---|
| 22 | from Cython.Distutils import build_ext |
|---|
| 23 | files = ["src/gauss.pyx"] |
|---|
| 24 | except ImportError: |
|---|
| 25 | from distutils.command.build_ext import build_ext |
|---|
| 26 | files = ["src/gauss.c"] |
|---|
| 27 | |
|---|
| 28 | ext_modules = [Extension("metpy.tools._gauss_filt", files, |
|---|
| 29 | extra_compile_args=['-O2 -fomit-frame-pointer'])] |
|---|
| 30 | else: |
|---|
| 31 | ext_modules = [] |
|---|
| 32 | include_dirs = None |
|---|
| 33 | build_ext = None |
|---|
| 34 | |
|---|
| 35 | setup(name = 'MetPy', |
|---|
| 36 | version = ver, |
|---|
| 37 | packages = ['metpy', 'metpy.bl', 'metpy.readers', 'metpy.tools', |
|---|
| 38 | 'metpy.vis'], |
|---|
| 39 | ext_modules = ext_modules, |
|---|
| 40 | include_dirs = include_dirs, |
|---|
| 41 | cmdclass = {'build_ext':build_ext}, |
|---|
| 42 | platforms = ['Linux'], |
|---|
| 43 | description = 'Collection of tools for reading, visualizing and' |
|---|
| 44 | 'performing calculations with weather data.', |
|---|
| 45 | url = 'http://code.forwarn.org/metpy', |
|---|
| 46 | ) |
|---|
| 47 | |
|---|
| 48 | if not version.release: |
|---|
| 49 | # Remove __svn_version__ so that if we run from local, an outdated version |
|---|
| 50 | # won't be found |
|---|
| 51 | os.remove(version._svn_file_path) |
|---|
| 52 | os.remove(version._svn_file_path + 'c') #The .pyc file |
|---|