forked from equinor/xtgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
130 lines (113 loc) · 4.17 KB
/
setup.py
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
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python3
"""Setup for XTGeo - subsurface reservoir tool for maps, 3D grids etc."""
import os
import sys
import pip
MINIMUMPIP = 20
if int(pip.__version__.split(".")[0]) < MINIMUMPIP:
print("Too old pip: ", pip.__version__)
print("Need at least version ", MINIMUMPIP)
try:
import setuptools
from setuptools import setup as setuptools_setup
except ImportError:
print("\n*** Some requirements are missing, please run:")
print("\n*** pip install -r requirements/requirements_setup.txt\n\n")
raise
try:
import skbuild
except ImportError:
print("\n*** Some requirements are missing, please run:")
print("\n*** pip install -r requirements/requirements_setup.txt\n")
raise
from scripts import setup_utilities as setuputils
CMD = sys.argv[1]
README = setuputils.readmestuff("README.md")
HISTORY = setuputils.readmestuff("HISTORY.md")
setuputils.check_swig() # Detect if swig is present and if case not, try a tmp install
REQUIREMENTS = setuputils.parse_requirements("requirements/requirements.txt")
TEST_REQUIREMENTS = setuputils.parse_requirements("requirements/requirements_test.txt")
SETUP_REQUIREMENTS = setuputils.parse_requirements(
"requirements/requirements_setup.txt"
)
DOCS_REQUIREMENTS = setuputils.parse_requirements("requirements/requirements_docs.txt")
EXTRAS_REQUIRE = {"tests": TEST_REQUIREMENTS, "docs": DOCS_REQUIREMENTS}
CMDCLASS = {"clean": setuputils.CleanUp}
def src(anypath):
root = os.path.dirname(__file__)
return os.path.abspath(os.path.join(root, anypath))
skbuild.setup(
name="xtgeo",
description="XTGeo is a Python library for 3D grids, surfaces, wells, etc",
use_scm_version={
"root": src(""),
"write_to": src("src/xtgeo/_theversion.py"),
},
long_description=README + "\n\n" + HISTORY,
long_description_content_type="text/markdown",
author="Equinor R&T",
url="https://github.com/equinor/xtgeo",
project_urls={
"Documentation": "https://xtgeo.readthedocs.io/",
"Issue Tracker": "https://github.com/equinor/xtgeo/issues",
},
license="LGPL-3.0",
cmake_args=["-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"],
packages=setuptools.find_packages(where="src"),
package_dir={"": "src"},
cmdclass=CMDCLASS,
zip_safe=False,
keywords="xtgeo",
command_options=setuputils.CMDSPHINX,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Lesser General Public "
"License v3 or later (LGPLv3+)",
"Operating System :: POSIX :: Linux",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
],
test_suite="tests",
install_requires=REQUIREMENTS,
setup_requires=SETUP_REQUIREMENTS,
tests_require=TEST_REQUIREMENTS,
extras_require=EXTRAS_REQUIRE,
)
# Below is a hack to make "python setup.py develop" or "pip install -e ." to work.
# Without this, the xtgeo.egg-link file will be wrong, e.g.:
# /home/jan/work/git/xtg/xtgeo
# .
#
# instead of the correct:
# /home/jan/work/git/xtg/xtgeo/src
# ../
#
# The wrong egg-link comes when find_packages(where="src") finds a list of packages in
# scikit-build version of setup(). No clue why...
if CMD == "develop":
print("Run in DEVELOP mode")
setuptools_setup( # use setuptools version of setup
name="xtgeo",
use_scm_version={
"root": src(""),
"write_to": src("src/xtgeo/_theversion.py"),
},
packages=setuptools.find_packages(where="src"),
package_dir={"": "src"},
zip_safe=False,
test_suite="tests",
install_requires=REQUIREMENTS,
setup_requires=SETUP_REQUIREMENTS,
tests_require=TEST_REQUIREMENTS,
extras_require=EXTRAS_REQUIRE,
)