From 046736e45d3d4637b1fcf3ff19d268c7efa6375e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Tue, 7 Jun 2022 08:19:15 +0200 Subject: [PATCH] Make Python opm package a namespace package Convert the Python opm package from a regular package to a namespace package such that opm-simulators can contribute to the package from a different filesystem path. In this way, the two packages opm.simulators and opm.io (for example) can have a different parent filesystem path. --- CMakeLists.txt | 6 ++++++ python/opm/__init__.py | 0 python/opm/simulators/__init__.py | 15 --------------- 3 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 python/opm/__init__.py delete mode 100644 python/opm/simulators/__init__.py diff --git a/CMakeLists.txt b/CMakeLists.txt index d7ad834da..9cfe41712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,8 @@ if (OPM_ENABLE_PYTHON) endif() set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) set(Python3_LIBRARIES ${PYTHON_LIBRARIES}) + set(Python3_VERSION "${PYTHON_VERSION_STRING}"}) + set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR}) else() # Be backwards compatible. if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE) @@ -210,6 +212,10 @@ if (OPM_ENABLE_PYTHON) "Either use \"apt-get install python3-setuptools\" (on Debian/Ubuntu) " "or \"pip install setuptools\"") endif() + if(Python3_VERSION_MINOR LESS 3) + # Python native namespace packages requires python >= 3.3 + message(SEND_ERROR "OPM requires python >= 3.3 but only version ${Python3_VERSION} was found") + endif() # Compatibility settings for PythonInterp and PythonLibs # used e.g. in FindCwrap, pybind11 diff --git a/python/opm/__init__.py b/python/opm/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/python/opm/simulators/__init__.py b/python/opm/simulators/__init__.py deleted file mode 100644 index 66220f553..000000000 --- a/python/opm/simulators/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# When using opm-simulators in combination with opm-common, the -# opm-simulators pybind11 module is placed in a package opm2, i.e. opm2.simulators. -# This is done to avoid conflict with the opm-common package prefix opm. -# The following is hack to avoid having to write -# -# from opm2.simulators import BlackOilSimulator -# from opm.io.parser import Parser -# #.... -# -# when it would be more natural to use the "opm" prefix instead of "opm2" -# to import the BlackOilSimulator also. It assumes that PYTHONPATH includes -# the install directory for the pybind11 python module for opm2.simulators - -from opm2.simulators import BlackOilSimulator -