Skip to content

Commit 191571d

Browse files
authored
Merge pull request #9 from jcrivenaes/integrate-cxtgeo
Integrated cxtgeo in xtgeo source tree
2 parents 2a19d1e + 502fe52 commit 191571d

File tree

351 files changed

+58385
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+58385
-44
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# > make siteinstall TARGET=$RESTARGET
1717
# =============================================================================
1818

19-
xt.PHONY: clean clean-test clean-pyc clean-build docs help pyver examples
19+
xt.PHONY: clean clean-test clean-pyc clean-build clean-cc docs help pyver examples
2020
.DEFAULT_GOAL := help
2121

2222
define PRINT_HELP_PYSCRIPT
@@ -62,7 +62,7 @@ help:
6262
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
6363

6464

65-
clean: clean-build clean-pyc clean-test clean-examples ## remove all build, test, coverage...
65+
clean: clean-build clean-pyc clean-test clean-examples clean-cc ## remove all build, test, coverage...
6666

6767

6868
clean-build: ## remove build artifacts
@@ -89,6 +89,13 @@ clean-test: ## remove test and coverage artifacts
8989
clean-examples:
9090
find examples ! -name "*.py" -type f -exec rm -f {} +
9191

92+
clean-cc:
93+
rm -fr src/xtgeo/cxtgeo/clib/build
94+
95+
cc:
96+
mkdir -p src/xtgeo/cxtgeo/clib/build
97+
cd src/xtgeo/cxtgeo/clib/build; cmake ..; make; make install
98+
9299

93100
lint: ## check style with flake8
94101
flake8 ${APPLICATION} tests

setup.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
# -*- coding: utf-8 -*-
33
"""The setup script."""
44

5+
import numpy
6+
57
from glob import glob
68
from os.path import basename
79
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
912
import versioneer
1013

1114
with open('README.rst') as readme_file:
@@ -26,6 +29,35 @@
2629
# 'segyio',
2730
]
2831

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+
2961
setup(
3062
name='xtgeo',
3163
version=versioneer.get_version(),
@@ -38,6 +70,7 @@
3870
packages=find_packages('src'),
3971
package_dir={'': 'src'},
4072
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
73+
ext_modules=[_cxtgeo],
4174
# packages=find_packages('xtgeo'),
4275
include_package_data=True,
4376
install_requires=requirements,

src/xtgeo/common/_fileutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os.path
33
import logging
44

5-
import cxtgeo.cxtgeo as _cxtgeo
5+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
66

77
logger = logging.getLogger(__name__)
88
logger.addHandler(logging.NullHandler())

src/xtgeo/common/calc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Some common XTGEO calculation routines."""
22

33
import numpy as np
4-
import cxtgeo.cxtgeo as _cxtgeo
4+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
55

66
from xtgeo.common import XTGeoDialog
77

src/xtgeo/common/constants.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""Module for basic XTGeo constants"""
33

4-
import cxtgeo
4+
import xtgeo.cxtgeo
55

6-
UNDEF = cxtgeo.cxtgeo.UNDEF
7-
UNDEF_LIMIT = cxtgeo.cxtgeo.UNDEF_LIMIT
8-
VERYLARGENEGATIVE = cxtgeo.cxtgeo.VERYLARGENEGATIVE
9-
VERYLARGEPOSITIVE = cxtgeo.cxtgeo.VERYLARGEPOSITIVE
6+
UNDEF = xtgeo.cxtgeo.cxtgeo.UNDEF
7+
UNDEF_LIMIT = xtgeo.cxtgeo.cxtgeo.UNDEF_LIMIT
8+
VERYLARGENEGATIVE = xtgeo.cxtgeo.cxtgeo.VERYLARGENEGATIVE
9+
VERYLARGEPOSITIVE = xtgeo.cxtgeo.cxtgeo.VERYLARGEPOSITIVE

src/xtgeo/common/xtgeo_dialog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
import inspect
3434
import logging
3535
import xtgeo
36-
import cxtgeo
37-
import cxtgeo.cxtgeo as _cxtgeo
36+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
3837
import timeit
3938

4039
UNDEF = _cxtgeo.UNDEF
@@ -248,7 +247,7 @@ def print_xtgeo_header(appname, appversion):
248247
print('#{}#'.format(app.center(77)))
249248
print('#' * 79)
250249
ver = 'XTGeo4Python version ' + xtgeo.__version__
251-
ver = ver + ' (CXTGeo v. ' + cxtgeo.__version__ + ')'
250+
ver = ver + ' (CXTGeo v. ' + xtgeo.__version__ + ')'
252251
print('#{}#'.format(ver.center(77)))
253252
print('#{}#'.format(cur_version.center(77)))
254253
print('#' * 79)

src/xtgeo/cube/_cube_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import segyio
66

7-
import cxtgeo.cxtgeo as _cxtgeo
7+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
88
from xtgeo.common import XTGeoDialog
99

1010
xtg = XTGeoDialog()

src/xtgeo/cube/_cube_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
import segyio
6-
import cxtgeo.cxtgeo as _cxtgeo
6+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
77
import xtgeo.common.calc as xcalc
88
from xtgeo.common import XTGeoDialog
99

src/xtgeo/cube/_cube_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66

7-
import cxtgeo.cxtgeo as _cxtgeo
7+
import xtgeo.cxtgeo.cxtgeo as _cxtgeo
88
from xtgeo.common import XTGeoDialog
99

1010
xtg = XTGeoDialog()

src/xtgeo/cxtgeo/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.o
2+
*.a
3+
*~
4+
*#
5+
*.bak
6+
/TMP
7+
/build/
8+
/bak/
9+
.exists
10+
cxtgeo.py
11+
_cxtgeo.so
12+
cxtgeo_wrap.c
13+
Makefile.old
14+
Makefile

0 commit comments

Comments
 (0)