From 16bcd5046a65b40a6d78b20f6394adda3919c396 Mon Sep 17 00:00:00 2001 From: mferrera Date: Mon, 20 Nov 2023 14:39:15 +0100 Subject: [PATCH] CLN: Install `_cxtgeo` in the root module Previously the C module was installed in a public module of the same name due the difficulty of adjusting the installation location in the now previous scikit-build package. This makes it properly private. --- pyproject.toml | 2 +- src/xtgeo/__init__.py | 2 +- src/xtgeo/common/calc.py | 2 +- src/xtgeo/common/constants.py | 6 +++--- src/xtgeo/common/sys.py | 2 +- src/xtgeo/cube/_cube_export.py | 2 +- src/xtgeo/cube/_cube_import.py | 2 +- src/xtgeo/cube/_cube_utils.py | 2 +- src/xtgeo/cxtgeo/__init__.py | 1 - src/xtgeo/grid3d/_grid3d_fence.py | 2 +- src/xtgeo/grid3d/_grid3d_utils.py | 2 +- src/xtgeo/grid3d/_grid_etc1.py | 2 +- src/xtgeo/grid3d/_grid_hybrid.py | 2 +- src/xtgeo/grid3d/_grid_refine.py | 2 +- src/xtgeo/grid3d/_grid_roxapi.py | 2 +- src/xtgeo/grid3d/_gridprop_lowlevel.py | 2 +- src/xtgeo/grid3d/_gridprop_op1.py | 2 +- src/xtgeo/grid3d/_roff_grid.py | 2 +- src/xtgeo/surface/_regsurf_cube.py | 2 +- src/xtgeo/surface/_regsurf_cube_window_v2.py | 2 +- src/xtgeo/surface/_regsurf_export.py | 2 +- src/xtgeo/surface/_regsurf_grid3d.py | 2 +- src/xtgeo/surface/_regsurf_import.py | 2 +- src/xtgeo/surface/_regsurf_lowlevel.py | 2 +- src/xtgeo/surface/_regsurf_oper.py | 2 +- src/xtgeo/well/_well_oper.py | 2 +- src/xtgeo/well/_wellmarkers.py | 2 +- src/xtgeo/well/well1.py | 2 +- src/xtgeo/xyz/_xyz_data.py | 4 ++-- src/xtgeo/xyz/_xyz_lowlevel.py | 2 +- src/xtgeo/xyz/_xyz_oper.py | 2 +- tests/test_common/test_calc.py | 2 +- tests/test_common/test_cxtgeo_lowlevel.py | 2 +- tests/test_etc/test_clib_errors.py | 2 +- tests/test_grid3d/test_grid_roff.py | 2 +- tests/test_surface/test_surf_xyz_from_ij.py | 2 +- 36 files changed, 38 insertions(+), 39 deletions(-) delete mode 100644 src/xtgeo/cxtgeo/__init__.py diff --git a/pyproject.toml b/pyproject.toml index e34380ed1..eb88b05fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ cmake.minimum-version = "3.15.3" cmake.verbose = true metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" sdist.include = ["src/xtgeo/_theversion.py"] -wheel.install-dir = "xtgeo/cxtgeo" +wheel.install-dir = "xtgeo" [project] name = "xtgeo" diff --git a/src/xtgeo/__init__.py b/src/xtgeo/__init__.py index c2a092c46..8b37d7bb9 100644 --- a/src/xtgeo/__init__.py +++ b/src/xtgeo/__init__.py @@ -79,6 +79,7 @@ def _xprint(msg): # _xprint("Import matplotlib etc...DONE") +from xtgeo._cxtgeo import XTGeoCLibError from xtgeo.common import XTGeoDialog from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_INT_LIMIT, UNDEF_LIMIT from xtgeo.common.exceptions import ( @@ -90,7 +91,6 @@ def _xprint(msg): WellNotFoundError, ) from xtgeo.common.sys import _XTGeoFile -from xtgeo.cxtgeo._cxtgeo import XTGeoCLibError _xprint("Import common... done") diff --git a/src/xtgeo/common/calc.py b/src/xtgeo/common/calc.py index 9c3f9be82..f88137331 100644 --- a/src/xtgeo/common/calc.py +++ b/src/xtgeo/common/calc.py @@ -9,7 +9,7 @@ from xtgeo import XTGeoCLibError from xtgeo.common import XTGeoDialog, null_logger -from xtgeo.cxtgeo import _cxtgeo +from xtgeo import _cxtgeo xtg = XTGeoDialog() logger = null_logger(__name__) diff --git a/src/xtgeo/common/constants.py b/src/xtgeo/common/constants.py index f22df3d7b..751035b5c 100644 --- a/src/xtgeo/common/constants.py +++ b/src/xtgeo/common/constants.py @@ -2,7 +2,7 @@ """Module for basic XTGeo constants""" # align with cxtgeo libxtg.h! -import xtgeo.cxtgeo._cxtgeo as cx +from xtgeo import _cxtgeo M_PI = 3.14159265358979323846 PI = M_PI @@ -19,8 +19,8 @@ UNDEF_MAP_IRAPB = 1e30 UNDEF_MAP_IRAPA = 9999900.0000 -MAXKEYWORDS = cx.MAXKEYWORDS # maximum keywords for ECL and ROFF scanning -MAXDATES = cx.MAXDATES # maximum keywords for ECL scanning +MAXKEYWORDS = _cxtgeo.MAXKEYWORDS # maximum keywords for ECL and ROFF scanning +MAXDATES = _cxtgeo.MAXDATES # maximum keywords for ECL scanning # for XYZ data, restricted to float32 and int32 UNDEF_CONT = UNDEF diff --git a/src/xtgeo/common/sys.py b/src/xtgeo/common/sys.py index 7aefbc777..067081309 100644 --- a/src/xtgeo/common/sys.py +++ b/src/xtgeo/common/sys.py @@ -19,7 +19,7 @@ import h5py import numpy as np -from xtgeo.cxtgeo import _cxtgeo +from xtgeo import _cxtgeo from . import null_logger from ._xyz_enum import _AttrType diff --git a/src/xtgeo/cube/_cube_export.py b/src/xtgeo/cube/_cube_export.py index b0468c4bf..3cfa8e22d 100644 --- a/src/xtgeo/cube/_cube_export.py +++ b/src/xtgeo/cube/_cube_export.py @@ -7,7 +7,7 @@ import segyio import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo import XTGeoCLibError from xtgeo.common import XTGeoDialog, null_logger diff --git a/src/xtgeo/cube/_cube_import.py b/src/xtgeo/cube/_cube_import.py index 82d1aae5e..1a2576959 100644 --- a/src/xtgeo/cube/_cube_import.py +++ b/src/xtgeo/cube/_cube_import.py @@ -41,7 +41,7 @@ import xtgeo import xtgeo.common.calc as xcalc import xtgeo.common.sys as xsys -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import XTGeoDialog, null_logger xtg = XTGeoDialog() diff --git a/src/xtgeo/cube/_cube_utils.py b/src/xtgeo/cube/_cube_utils.py index 9e427e948..c515f177a 100644 --- a/src/xtgeo/cube/_cube_utils.py +++ b/src/xtgeo/cube/_cube_utils.py @@ -4,7 +4,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo import XTGeoCLibError from xtgeo.common import null_logger from xtgeo.common.calc import _swap_axes diff --git a/src/xtgeo/cxtgeo/__init__.py b/src/xtgeo/cxtgeo/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/src/xtgeo/cxtgeo/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/xtgeo/grid3d/_grid3d_fence.py b/src/xtgeo/grid3d/_grid3d_fence.py index 0fab64f22..b90de9488 100644 --- a/src/xtgeo/grid3d/_grid3d_fence.py +++ b/src/xtgeo/grid3d/_grid3d_fence.py @@ -4,7 +4,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger from xtgeo.grid3d import _gridprop_lowlevel as gl from xtgeo.surface import _regsurf_lowlevel as rl diff --git a/src/xtgeo/grid3d/_grid3d_utils.py b/src/xtgeo/grid3d/_grid3d_utils.py index 840794faf..004ba302b 100644 --- a/src/xtgeo/grid3d/_grid3d_utils.py +++ b/src/xtgeo/grid3d/_grid3d_utils.py @@ -7,7 +7,7 @@ import pandas as pd -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo import XTGeoCLibError from xtgeo.common import null_logger from xtgeo.common.constants import MAXDATES, MAXKEYWORDS diff --git a/src/xtgeo/grid3d/_grid_etc1.py b/src/xtgeo/grid3d/_grid_etc1.py index ba90a80c1..de4ae6b47 100644 --- a/src/xtgeo/grid3d/_grid_etc1.py +++ b/src/xtgeo/grid3d/_grid_etc1.py @@ -12,7 +12,7 @@ from packaging.version import parse as versionparse import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger from xtgeo.common.calc import find_flip from xtgeo.xyz.polygons import Polygons diff --git a/src/xtgeo/grid3d/_grid_hybrid.py b/src/xtgeo/grid3d/_grid_hybrid.py index 5a3b06ed7..6996d99ac 100644 --- a/src/xtgeo/grid3d/_grid_hybrid.py +++ b/src/xtgeo/grid3d/_grid_hybrid.py @@ -1,7 +1,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/grid3d/_grid_refine.py b/src/xtgeo/grid3d/_grid_refine.py index 6d1f060dd..44f396199 100644 --- a/src/xtgeo/grid3d/_grid_refine.py +++ b/src/xtgeo/grid3d/_grid_refine.py @@ -4,7 +4,7 @@ import numpy as np -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import XTGeoDialog, null_logger xtg = XTGeoDialog() diff --git a/src/xtgeo/grid3d/_grid_roxapi.py b/src/xtgeo/grid3d/_grid_roxapi.py index 9cb834f88..d21dec425 100644 --- a/src/xtgeo/grid3d/_grid_roxapi.py +++ b/src/xtgeo/grid3d/_grid_roxapi.py @@ -7,7 +7,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo import RoxUtils from xtgeo.common import XTGeoDialog, null_logger diff --git a/src/xtgeo/grid3d/_gridprop_lowlevel.py b/src/xtgeo/grid3d/_gridprop_lowlevel.py index a94c04166..b36d3ed43 100644 --- a/src/xtgeo/grid3d/_gridprop_lowlevel.py +++ b/src/xtgeo/grid3d/_gridprop_lowlevel.py @@ -5,7 +5,7 @@ import numpy.ma as ma import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/grid3d/_gridprop_op1.py b/src/xtgeo/grid3d/_gridprop_op1.py index 9db25e67d..c346ddf12 100644 --- a/src/xtgeo/grid3d/_gridprop_op1.py +++ b/src/xtgeo/grid3d/_gridprop_op1.py @@ -7,7 +7,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import XTGeoDialog, null_logger from xtgeo.grid3d import _gridprop_lowlevel as gl diff --git a/src/xtgeo/grid3d/_roff_grid.py b/src/xtgeo/grid3d/_roff_grid.py index 71f9bed68..089dd29f9 100644 --- a/src/xtgeo/grid3d/_roff_grid.py +++ b/src/xtgeo/grid3d/_roff_grid.py @@ -9,7 +9,7 @@ import numpy as np import roffio -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo if TYPE_CHECKING: from xtgeo.grid3d import Grid diff --git a/src/xtgeo/surface/_regsurf_cube.py b/src/xtgeo/surface/_regsurf_cube.py index 5c3d48ed7..4ad91b8e7 100644 --- a/src/xtgeo/surface/_regsurf_cube.py +++ b/src/xtgeo/surface/_regsurf_cube.py @@ -5,7 +5,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/surface/_regsurf_cube_window_v2.py b/src/xtgeo/surface/_regsurf_cube_window_v2.py index b6cdd413f..f0f6f27ba 100644 --- a/src/xtgeo/surface/_regsurf_cube_window_v2.py +++ b/src/xtgeo/surface/_regsurf_cube_window_v2.py @@ -5,7 +5,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/surface/_regsurf_export.py b/src/xtgeo/surface/_regsurf_export.py index e09cfac9d..d817db7a3 100644 --- a/src/xtgeo/surface/_regsurf_export.py +++ b/src/xtgeo/surface/_regsurf_export.py @@ -12,7 +12,7 @@ import numpy as np import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # pylint: disable=import-error +from xtgeo import _cxtgeo # pylint: disable=import-error from xtgeo.common import null_logger from xtgeo.common.constants import UNDEF_MAP_IRAPA, UNDEF_MAP_IRAPB diff --git a/src/xtgeo/surface/_regsurf_grid3d.py b/src/xtgeo/surface/_regsurf_grid3d.py index effd66b8a..502c29750 100644 --- a/src/xtgeo/surface/_regsurf_grid3d.py +++ b/src/xtgeo/surface/_regsurf_grid3d.py @@ -6,7 +6,7 @@ import numpy.ma as ma import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger from xtgeo.grid3d import _gridprop_lowlevel diff --git a/src/xtgeo/surface/_regsurf_import.py b/src/xtgeo/surface/_regsurf_import.py index 56caada9f..663631f10 100644 --- a/src/xtgeo/surface/_regsurf_import.py +++ b/src/xtgeo/surface/_regsurf_import.py @@ -11,7 +11,7 @@ import xtgeo import xtgeo.common.sys as xsys -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # pylint: disable=no-name-in-module +from xtgeo import _cxtgeo # pylint: disable=no-name-in-module from xtgeo.common import XTGeoDialog, null_logger from xtgeo.common.constants import UNDEF_MAP_IRAPA, UNDEF_MAP_IRAPB from xtgeo.surface._zmap_parser import parse_zmap diff --git a/src/xtgeo/surface/_regsurf_lowlevel.py b/src/xtgeo/surface/_regsurf_lowlevel.py index f25d3e423..311cc778a 100644 --- a/src/xtgeo/surface/_regsurf_lowlevel.py +++ b/src/xtgeo/surface/_regsurf_lowlevel.py @@ -1,6 +1,6 @@ """RegularSurface utilities (low level)""" -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import XTGeoDialog xtg = XTGeoDialog() diff --git a/src/xtgeo/surface/_regsurf_oper.py b/src/xtgeo/surface/_regsurf_oper.py index 76507b378..3b715fbd7 100644 --- a/src/xtgeo/surface/_regsurf_oper.py +++ b/src/xtgeo/surface/_regsurf_oper.py @@ -10,7 +10,7 @@ from matplotlib.path import Path as MPath import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo import _cxtgeo # type: ignore from xtgeo import XTGeoCLibError from xtgeo.common import XTGeoDialog, null_logger from xtgeo.xyz import Polygons diff --git a/src/xtgeo/well/_well_oper.py b/src/xtgeo/well/_well_oper.py index 704a3a2fe..48d8b61e2 100644 --- a/src/xtgeo/well/_well_oper.py +++ b/src/xtgeo/well/_well_oper.py @@ -6,7 +6,7 @@ import pandas as pd import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo import _cxtgeo # type: ignore from xtgeo.common import constants as const from xtgeo.common import null_logger from xtgeo.common._xyz_enum import _AttrType diff --git a/src/xtgeo/well/_wellmarkers.py b/src/xtgeo/well/_wellmarkers.py index 3fdb91c3f..33fdeba1f 100644 --- a/src/xtgeo/well/_wellmarkers.py +++ b/src/xtgeo/well/_wellmarkers.py @@ -9,7 +9,7 @@ import xtgeo import xtgeo.common.constants as const -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo import _cxtgeo # type: ignore from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/well/well1.py b/src/xtgeo/well/well1.py index a5f9b882d..59ac6e6a1 100644 --- a/src/xtgeo/well/well1.py +++ b/src/xtgeo/well/well1.py @@ -12,7 +12,7 @@ import xtgeo import xtgeo.common.constants as const -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo import _cxtgeo # type: ignore from xtgeo.common import _AttrType, null_logger from xtgeo.xyz import _xyz_data # type: ignore[attr-defined] diff --git a/src/xtgeo/xyz/_xyz_data.py b/src/xtgeo/xyz/_xyz_data.py index c0b6c46ef..48f9664e7 100644 --- a/src/xtgeo/xyz/_xyz_data.py +++ b/src/xtgeo/xyz/_xyz_data.py @@ -42,10 +42,10 @@ from joblib import hash as jhash import xtgeo.common.constants as const +from xtgeo import _cxtgeo +from xtgeo._cxtgeo import XTGeoCLibError # type: ignore[attr-defined] from xtgeo.common import null_logger from xtgeo.common.sys import _convert_carr_double_np, _get_carray -from xtgeo.cxtgeo import _cxtgeo -from xtgeo.cxtgeo._cxtgeo import XTGeoCLibError # type: ignore[attr-defined] from ..common._xyz_enum import _AttrName, _AttrType, _XYZType diff --git a/src/xtgeo/xyz/_xyz_lowlevel.py b/src/xtgeo/xyz/_xyz_lowlevel.py index 9b9b0cbed..ad1a81d68 100644 --- a/src/xtgeo/xyz/_xyz_lowlevel.py +++ b/src/xtgeo/xyz/_xyz_lowlevel.py @@ -4,7 +4,7 @@ import numpy as np -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/xyz/_xyz_oper.py b/src/xtgeo/xyz/_xyz_oper.py index 1fa879d48..1a68d020a 100644 --- a/src/xtgeo/xyz/_xyz_oper.py +++ b/src/xtgeo/xyz/_xyz_oper.py @@ -9,7 +9,7 @@ from scipy.interpolate import UnivariateSpline, interp1d import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.common import XTGeoDialog, null_logger xtg = XTGeoDialog() diff --git a/tests/test_common/test_calc.py b/tests/test_common/test_calc.py index 7afd4e8a8..fd804bccf 100644 --- a/tests/test_common/test_calc.py +++ b/tests/test_common/test_calc.py @@ -7,7 +7,7 @@ import xtgeo import xtgeo.common.calc as xcalc -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo xtg = xtgeo.XTGeoDialog() logger = xtg.basiclogger(__name__) diff --git a/tests/test_common/test_cxtgeo_lowlevel.py b/tests/test_common/test_cxtgeo_lowlevel.py index 7e81bf81e..82922e4cf 100644 --- a/tests/test_common/test_cxtgeo_lowlevel.py +++ b/tests/test_common/test_cxtgeo_lowlevel.py @@ -3,7 +3,7 @@ import pytest import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo xtg = xtgeo.XTGeoDialog() logger = xtg.basiclogger(__name__) diff --git a/tests/test_etc/test_clib_errors.py b/tests/test_etc/test_clib_errors.py index 03b659718..83fe071d7 100644 --- a/tests/test_etc/test_clib_errors.py +++ b/tests/test_etc/test_clib_errors.py @@ -6,7 +6,7 @@ import pytest import xtgeo -from xtgeo.cxtgeo import _cxtgeo +from xtgeo import _cxtgeo @pytest.fixture() diff --git a/tests/test_grid3d/test_grid_roff.py b/tests/test_grid3d/test_grid_roff.py index 019f540ed..80491c494 100644 --- a/tests/test_grid3d/test_grid_roff.py +++ b/tests/test_grid3d/test_grid_roff.py @@ -11,7 +11,7 @@ from hypothesis.extra.numpy import arrays from numpy.testing import assert_allclose -import xtgeo.cxtgeo._cxtgeo as _cxtgeo +from xtgeo import _cxtgeo from xtgeo.grid3d import Grid from xtgeo.grid3d._grid_import_roff import handle_deprecated_xtgeo_roff_file from xtgeo.grid3d._roff_grid import RoffGrid diff --git a/tests/test_surface/test_surf_xyz_from_ij.py b/tests/test_surface/test_surf_xyz_from_ij.py index 87183f708..3cfea91c0 100644 --- a/tests/test_surface/test_surf_xyz_from_ij.py +++ b/tests/test_surface/test_surf_xyz_from_ij.py @@ -2,7 +2,7 @@ import pytest import xtgeo -import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo import _cxtgeo # type: ignore class Surface: