File: setup.py.in

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (117 lines) | stat: -rw-r--r-- 3,468 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
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 )

cc = "@CMAKE_CXX_COMPILER@"
# setuptools will use the first path as the linker.
# This should not be ccache as this will fail.
# CXX is used for linking and CC for compilation
os.environ['CXX'] = cc

try:
    subprocess.call(['ccache', '--version'])
    os.environ['CC'] = 'ccache {}'.format(cc)
    print("Using 'ccache {}' as compiler".format(cc))
except OSError as e:
    os.environ['CC'] = cc
    print('\nNOTE: please install ccache for faster compilation of python bindings.\n')

# 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')

if 'build' in sys.argv:
    if not 'build_ext' in sys.argv:
        raise TypeError("Missing option 'build_ext'.")

ext_modules = [
    Extension(
        'opm.libopmcommon_python',
        [
                'cxx/unit_system.cpp',
                'cxx/connection.cpp',
                'cxx/converters.cpp',
                'cxx/deck.cpp',
                'cxx/deck_keyword.cpp',
                'cxx/eclipse_io.cpp',
                'cxx/field_props.cpp',
                'cxx/eclipse_config.cpp',
                'cxx/eclipse_grid.cpp',
                'cxx/eclipse_state.cpp',
                'cxx/group.cpp',
                'cxx/log.cpp',
                'cxx/parsecontext.cpp',
                'cxx/parser.cpp',
                'cxx/schedule.cpp',
                'cxx/summary_state.cpp',
                'cxx/table_manager.cpp',
                'cxx/well.cpp',
                'cxx/emodel_util.cpp',
                'cxx/builtin_pybind11.cpp',
                'cxx/export.cpp'
        ],
        libraries=libs,
        language='c++',
        undef_macros=["NDEBUG"],
        include_dirs=[@SETUP_PY_INCLUDE_DIRS@],
        extra_compile_args=[@SETUP_PY_FLAGS@],
        extra_link_args=[@SETUP_PY_LINKAGE@]
    )
]

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

setup(
    name='opm',
    version = '@opm-common_VERSION@' + '@opm-common_PYTHON_PACKAGE_VERSION@',
    url='http://www.opm-project.org',
    author='The Open Porous Media Project',
    author_email='opmuser@gmail.com',
    description='OPM-Common Python bindings',
    long_description=long_description,
    long_description_content_type="text/markdown",
    packages=[
                'opm',
                'opm.io',
                'opm.io.deck',
                'opm.io.ecl_state',
                'opm.io.parser',
                'opm.io.schedule',
                'opm.io.ecl',
                'opm.tools',
                'opm.util'
            ],
    ext_modules=ext_modules,
    include_package_data=True,
    license='Open Source',
    zip_safe=False,
    test_suite='tests',
    setup_requires=["pytest-runner", 'setuptools_scm'],
    python_requires='>=3.5',
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
    ],
)