Compare commits

...

16 Commits

Author SHA1 Message Date
Arne Morten Kvarving
c4023f7299
Merge pull request #3521 from akva2/backport_PR_3520
Backport #3520 fixed: build pypi packages using static boost libs
2023-05-12 09:20:15 +02:00
Arne Morten Kvarving
86d1fbe521 fixed: build pypi packages using static boost libs 2023-05-12 09:19:31 +02:00
Arne Morten Kvarving
71b1c36ca3 bup version to 2023.04 final 2023-05-02 14:15:16 +02:00
Arne Morten Kvarving
382c624f10
Merge pull request #3500 from akva2/backport_PR_3499
fixed: conditionally use Development.XXX in python find module
2023-05-02 09:27:05 +02:00
Arne Morten Kvarving
d903c61166 fixed: conditionally use Development.XXX in python find module
the split into Development.Module and Development.Embed was is introduced in cmake 3.18
2023-05-02 09:26:16 +02:00
Arne Morten Kvarving
acc1a5145a bump version to 2023.04-rc2 2023-04-27 13:38:25 +02:00
Arne Morten Kvarving
e892d17f74
Merge pull request #3492 from akva2/backport_PR_3489
Backport #3489: Python: avoid searching from Development.Embed unless required
2023-04-27 13:36:30 +02:00
Arne Morten Kvarving
7cd35f4477 fixed: setuptools are no longer required to build the python bindings
only required if building packages for pypi, which is done separately
from the main buildsystem.
2023-04-27 13:35:42 +02:00
Arne Morten Kvarving
fb5f40339b changed: only search for Development.Module if not building embedded python
the embedding headers are not available on the manylinux2014 containers
used to build the pypi packages. since this is anyways more correct
fix it this way
2023-04-27 13:35:35 +02:00
Arne Morten Kvarving
0f25bb7386
Merge pull request #3491 from akva2/backport_PR_3490
Backport #3490: changed: build python wheels using skbuild
2023-04-27 13:31:01 +02:00
Arne Morten Kvarving
4952be6990 changed: build python wheels using skbuild
the vanilla setup-tools doesn't get the triplet correctly for some
reason. also use cmake from pip as cmake 3.16 in the image has a bug
in the python find rule
2023-04-27 13:30:23 +02:00
Arne Morten Kvarving
3f3a0c307d
Merge pull request #3486 from akva2/backport_PR_3484
Backport #3484: fixed: missing serialization of tokens in UDQDefine
2023-04-26 12:57:13 +02:00
Arne Morten Kvarving
63002dd1a5 fixed: missing serialization of tokens in UDQDefine
this went unnoticed since there are no UDQDefines in the pre-simulation
Schedule broadcast for parallel. however it causes issues for serialized
restarts
2023-04-26 12:56:19 +02:00
Arne Morten Kvarving
95f62fbf58
Merge pull request #3483 from akva2/backport_PR_3478
Backport #3478: Always search for Development component of Python.
2023-04-24 08:47:30 +02:00
Markus Blatt
f28b6ed05d Always search for Development component of Python.
It is needed as we will call pybind11_add_module which calls
python3_add_library (in recent pybind11 versions). That
function is only there if the development component is searched for
and found.
2023-04-24 08:46:38 +02:00
Arne Morten Kvarving
c0616be20e bump version to 2023.04-rc1 2023-04-13 14:30:31 +02:00
11 changed files with 62 additions and 23 deletions

View File

@ -216,26 +216,25 @@ if (OPM_ENABLE_PYTHON)
if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE) if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE)
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
endif() endif()
if (OPM_ENABLE_EMBEDDED_PYTHON) # We always need to search for Development as we use
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) # pybind11_add_module even if don't embed Python
if (NOT OPM_ENABLE_EMBEDDED_PYTHON)
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
endif()
else()
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Embed Development.Module)
endif()
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION) get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
set(PYTHON_LIBRARY ${_lib_path}) set(PYTHON_LIBRARY ${_lib_path})
set(PYTHON_LIBRARIES {PYTHON_LIBRARY}) set(PYTHON_LIBRARIES {PYTHON_LIBRARY})
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY}) list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
endif()
# Make sure we fail gracefully here without setuptool
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import setuptools"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
ERROR_VARIABLE SETUPTOOL_ERROR OUTPUT_VARIABLE SETUPTOOL_OUT
RESULT_VARIABLE SETUPTOOL_RESULT)
if(SETUPTOOL_RESULT GREATER 0)
message(WARNING "Trying to test setuptools resulted in error message: ${SETUPTOOL_ERROR}")
message(SEND_ERROR "To build the python bindings you need to install setuptool. "
"Either use \"apt-get install python3-setuptools\" (on Debian/Ubuntu) "
"or \"pip install setuptools\"")
endif() endif()
if(Python3_VERSION_MINOR LESS 3) if(Python3_VERSION_MINOR LESS 3)
# Python native namespace packages requires python >= 3.3 # Python native namespace packages requires python >= 3.3

View File

@ -5,8 +5,8 @@
Module: opm-common Module: opm-common
Description: Open Porous Media Initiative shared infrastructure Description: Open Porous Media Initiative shared infrastructure
Version: 2023.04-pre Version: 2023.04
Label: 2023.04-pre Label: 2023.04
Maintainer: opm@opm-project.org Maintainer: opm@opm-project.org
MaintainerName: OPM community MaintainerName: OPM community
Url: http://opm-project.org Url: http://opm-project.org

View File

@ -94,6 +94,7 @@ public:
void serializeOp(Serializer& serializer) void serializeOp(Serializer& serializer)
{ {
serializer(m_keyword); serializer(m_keyword);
serializer(m_tokens);
serializer(ast); serializer(ast);
serializer(m_var_type); serializer(m_var_type);
serializer(m_location); serializer(m_location);

View File

@ -30,15 +30,29 @@ namespace Opm {
class UDQToken { class UDQToken {
public: public:
UDQToken() = default;
UDQToken(const std::string& string_token, UDQTokenType token_type); UDQToken(const std::string& string_token, UDQTokenType token_type);
UDQToken(const std::string& string_token, const std::vector<std::string>& selector); UDQToken(const std::string& string_token, const std::vector<std::string>& selector);
static UDQToken serializationTestObject();
const std::vector<std::string>& selector() const; const std::vector<std::string>& selector() const;
const std::variant<std::string, double>& value() const; const std::variant<std::string, double>& value() const;
UDQTokenType type() const; UDQTokenType type() const;
std::string str() const; std::string str() const;
bool operator==(const UDQToken&) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(token_type);
serializer(m_value);
serializer(m_selector);
}
private: private:
UDQTokenType token_type; UDQTokenType token_type{UDQTokenType::error};
std::variant<std::string,double> m_value; std::variant<std::string,double> m_value;
std::vector<std::string> m_selector; std::vector<std::string> m_selector;
}; };

5
python/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
project(install_python_binding)
cmake_minimum_required(VERSION 3.15)
install(CODE "message(\"Dummy install\")")

View File

@ -25,7 +25,7 @@ do
rm -rf $tag rm -rf $tag
fi fi
mkdir $tag && pushd $tag mkdir $tag && pushd $tag
cmake3 -DPYTHON_EXECUTABLE=${python_versions[$tag]} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 -DWITH_NATIVE=0 \ cmake -DPYTHON_EXECUTABLE=${python_versions[$tag]} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 -DWITH_NATIVE=0 -DBoost_USE_STATIC_LIBS=1 \
-DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} .. -DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} ..
# make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step # make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step

7
python/pyproject.toml Normal file
View File

@ -0,0 +1,7 @@
[build-system]
requires= [
"setuptools>=42",
"scikit-build>=0.13",
"cmake>=3.15",
"ninja"
]

View File

@ -8,11 +8,11 @@
yum-config-manager --add-repo \ yum-config-manager --add-repo \
https://www.opm-project.org/package/opm.repo https://www.opm-project.org/package/opm.repo
yum install -y cmake3 ccache boost169-devel boost169-static tbb-devel yum install -y ccache boost169-devel boost169-static tbb-devel
yum install -y blas-devel suitesparse-devel dune-common-devel yum install -y blas-devel suitesparse-devel dune-common-devel
for python_bin in ${python_versions[*]} for python_bin in ${python_versions[*]}
do do
${python_bin} -m pip install pip --upgrade ${python_bin} -m pip install pip --upgrade
${python_bin} -m pip install wheel setuptools twine pytest-runner auditwheel ${python_bin} -m pip install wheel setuptools twine pytest-runner auditwheel scikit-build cmake
done done

View File

@ -1,4 +1,4 @@
from setuptools import setup from skbuild import setup
import os import os
@ -32,7 +32,6 @@ setup(
package_data={'opm' : ['$<TARGET_FILE_NAME:opmcommon_python>']}, package_data={'opm' : ['$<TARGET_FILE_NAME:opmcommon_python>']},
include_package_data=True, include_package_data=True,
license='Open Source', license='Open Source',
zip_safe=False,
test_suite='tests', test_suite='tests',
setup_requires=["pytest-runner", 'setuptools_scm'], setup_requires=["pytest-runner", 'setuptools_scm'],
python_requires='>=3.6', python_requires='>=3.6',

View File

@ -279,6 +279,7 @@ UDQDefine UDQDefine::serializationTestObject()
{ {
UDQDefine result; UDQDefine result;
result.m_keyword = "test1"; result.m_keyword = "test1";
result.m_tokens = {UDQToken::serializationTestObject()};
result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializationTestObject()); result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializationTestObject());
result.m_var_type = UDQVarType::SEGMENT_VAR; result.m_var_type = UDQVarType::SEGMENT_VAR;
result.string_data = "test2"; result.string_data = "test2";
@ -404,6 +405,7 @@ bool UDQDefine::operator==(const UDQDefine& data) const
} }
return (this->keyword() == data.keyword()) return (this->keyword() == data.keyword())
&& (this->m_tokens == data.m_tokens)
&& (this->m_location == data.location()) && (this->m_location == data.location())
&& (this->var_type() == data.var_type()) && (this->var_type() == data.var_type())
&& (this->status() == data.status()) && (this->status() == data.status())

View File

@ -89,4 +89,16 @@ std::string UDQToken::str() const
} }
} }
UDQToken UDQToken::serializationTestObject()
{
return UDQToken{"test1", {"test2", "test3"}};
}
bool UDQToken::operator==(const UDQToken& rhs) const
{
return this->token_type == rhs.token_type &&
this->m_value == rhs.m_value &&
this->m_selector == rhs.m_selector;
}
} // namespace Opm } // namespace Opm