Merge pull request #3040 from hakonhagland/python_nsp2

Make the Python `opm` package a namespace package
This commit is contained in:
Markus Blatt 2022-06-10 15:01:07 +02:00 committed by GitHub
commit b3eddb7061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 15 deletions

View File

@ -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

View File

View File

@ -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