Files
opm-common/python/setup.py

94 lines
2.6 KiB
Python
Raw Normal View History

2019-06-27 14:08:22 +02:00
from setuptools import setup, find_packages
from setuptools import Extension
from setuptools.command.build_ext import build_ext
import sys
import setuptools
import glob
import os
import re
2019-08-09 13:02:04 +02:00
import subprocess
try:
from importlib.machinery import EXTENSION_SUFFIXES
suffix = EXTENSION_SUFFIXES[0]
except ImportError:
suffix = ".so"
setupdir = os.path.dirname(__file__)
if setupdir != '':
os.chdir( setupdir )
2019-08-09 13:02:04 +02:00
cc = os.environ.get("CC", "c++")
2019-08-09 13:02:04 +02:00
try:
2019-09-17 14:16:55 +02:00
subprocess.call(['ccache', '--version'])
os.environ['CC'] = 'ccache {}'.format(cc)
print("Using 'ccache {}' as compiler".format(cc))
2019-08-09 13:02:04 +02:00
except OSError as e:
2019-09-17 14:16:55 +02:00
print('\nNOTE: please install ccache for faster compilation of python bindings.\n')
2019-06-27 14:08:22 +02:00
# This is very hacky but so is the entire setup.py buildsystem.
output=subprocess.check_output([cc, "--version"])
libs=['opmcommon', 'boost_system']
output=str(output)
if output.find('Free Software Foundation'):
libs.append('stdc++fs')
2019-06-27 14:08:22 +02:00
if 'build' in sys.argv:
2019-09-17 14:16:55 +02:00
if not 'build_ext' in sys.argv:
raise TypeError("Missing option 'build_ext'.")
2019-06-27 14:08:22 +02:00
ext_modules = [
Extension(
'libopmcommon_python',
2019-06-27 14:08:22 +02:00
[
2019-10-11 16:29:09 +02:00
'cxx/unit_system.cpp',
2019-06-27 14:08:22 +02:00
'cxx/connection.cpp',
2019-10-30 22:34:37 +01:00
'cxx/converters.cpp',
2019-06-27 14:08:22 +02:00
'cxx/deck.cpp',
'cxx/deck_keyword.cpp',
'cxx/eclipse_io.cpp',
'cxx/field_props.cpp',
2019-06-27 14:08:22 +02:00
'cxx/eclipse_config.cpp',
'cxx/eclipse_grid.cpp',
'cxx/eclipse_state.cpp',
'cxx/group.cpp',
2019-09-16 18:33:50 +02:00
'cxx/log.cpp',
'cxx/parsecontext.cpp',
2019-06-27 14:08:22 +02:00
'cxx/parser.cpp',
'cxx/schedule.cpp',
2019-12-27 10:08:46 +01:00
'cxx/summary_state.cpp',
2019-06-27 14:08:22 +02:00
'cxx/table_manager.cpp',
'cxx/well.cpp',
'cxx/export.cpp'
2019-06-27 14:08:22 +02:00
],
libraries=libs,
2019-06-27 14:08:22 +02:00
language='c++',
undef_macros=["NDEBUG"],
2020-02-10 11:01:39 +01:00
include_dirs=["pybind11/include"],
extra_compile_args=['-std=c++17']
2019-10-26 17:33:43 +02:00
)
2019-06-27 14:08:22 +02:00
]
setup(
name='Opm',
2019-06-27 14:08:22 +02:00
package_dir = {'': 'python'},
packages=[
'opm',
2019-08-23 10:25:54 +02:00
'opm.io',
'opm.io.deck',
'opm.io.ecl_state',
2019-08-23 11:44:41 +02:00
'opm.io.parser',
'opm.io.schedule',
2019-10-26 17:33:43 +02:00
'opm.io.ecl',
'opm.tools'
2019-06-27 14:08:22 +02:00
],
ext_modules=ext_modules,
2020-02-06 10:18:07 +01:00
package_data={'opm': ['libopmcommon_python{}'.format(suffix)]},
include_package_data=True,
2019-06-27 14:08:22 +02:00
license='Open Source',
zip_safe=False,
tests_suite='tests',
2019-06-27 14:08:22 +02:00
setup_requires=["pytest-runner", 'setuptools_scm'],
)