|
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 | """The setup script.""" |
4 | 4 |
|
| 5 | +import numpy |
| 6 | + |
5 | 7 | from glob import glob |
6 | 8 | from os.path import basename |
7 | 9 | from os.path import splitext |
8 | | -from setuptools import setup, find_packages |
| 10 | +from setuptools import setup, find_packages, Extension |
| 11 | +from distutils.command.build import build as _build |
9 | 12 | import versioneer |
10 | 13 |
|
11 | 14 | with open('README.rst') as readme_file: |
|
26 | 29 | # 'segyio', |
27 | 30 | ] |
28 | 31 |
|
| 32 | + |
| 33 | +class build(_build): |
| 34 | + # different order: build_ext *before* build_py |
| 35 | + sub_commands = [('build_ext', _build.has_ext_modules), |
| 36 | + ('build_py', _build.has_pure_modules), |
| 37 | + ('build_clib', _build.has_c_libraries), |
| 38 | + ('build_scripts', _build.has_scripts)] |
| 39 | + |
| 40 | + |
| 41 | +# get all C sources |
| 42 | +sources = ['src/xtgeo/cxtgeo/cxtgeo.i'] |
| 43 | + |
| 44 | +# Obtain the numpy include directory. This logic works across numpy versions. |
| 45 | +try: |
| 46 | + numpy_include = numpy.get_include() |
| 47 | +except AttributeError: |
| 48 | + numpy_include = numpy.get_numpy_include() |
| 49 | + |
| 50 | +# cxtgeo extension module |
| 51 | +_cxtgeo = Extension('xtgeo.cxtgeo._cxtgeo', |
| 52 | + sources=sources, |
| 53 | + include_dirs=['src/xtgeo/cxtgeo/clib/src', numpy_include], |
| 54 | + library_dirs=['src/xtgeo/cxtgeo/clib/lib'], |
| 55 | + libraries=['cxtgeo'], |
| 56 | + swig_opts=['-modern'], |
| 57 | +) |
| 58 | + |
| 59 | + |
| 60 | + |
29 | 61 | setup( |
30 | 62 | name='xtgeo', |
31 | 63 | version=versioneer.get_version(), |
|
38 | 70 | packages=find_packages('src'), |
39 | 71 | package_dir={'': 'src'}, |
40 | 72 | py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], |
| 73 | + ext_modules=[_cxtgeo], |
41 | 74 | # packages=find_packages('xtgeo'), |
42 | 75 | include_package_data=True, |
43 | 76 | install_requires=requirements, |
|
0 commit comments