Compare commits
16 Commits
master
...
release/20
Author | SHA1 | Date | |
---|---|---|---|
|
c4023f7299 | ||
|
86d1fbe521 | ||
|
71b1c36ca3 | ||
|
382c624f10 | ||
|
d903c61166 | ||
|
acc1a5145a | ||
|
e892d17f74 | ||
|
7cd35f4477 | ||
|
fb5f40339b | ||
|
0f25bb7386 | ||
|
4952be6990 | ||
|
3f3a0c307d | ||
|
63002dd1a5 | ||
|
95f62fbf58 | ||
|
f28b6ed05d | ||
|
c0616be20e |
@ -216,26 +216,25 @@ if (OPM_ENABLE_PYTHON)
|
||||
if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE)
|
||||
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
endif()
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||
# We always need to search for Development as we use
|
||||
# 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)
|
||||
set(PYTHON_LIBRARY ${_lib_path})
|
||||
set(PYTHON_LIBRARIES {PYTHON_LIBRARY})
|
||||
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
|
||||
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()
|
||||
if(Python3_VERSION_MINOR LESS 3)
|
||||
# Python native namespace packages requires python >= 3.3
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
Module: opm-common
|
||||
Description: Open Porous Media Initiative shared infrastructure
|
||||
Version: 2023.04-pre
|
||||
Label: 2023.04-pre
|
||||
Version: 2023.04
|
||||
Label: 2023.04
|
||||
Maintainer: opm@opm-project.org
|
||||
MaintainerName: OPM community
|
||||
Url: http://opm-project.org
|
||||
|
@ -94,6 +94,7 @@ public:
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(m_keyword);
|
||||
serializer(m_tokens);
|
||||
serializer(ast);
|
||||
serializer(m_var_type);
|
||||
serializer(m_location);
|
||||
|
@ -30,15 +30,29 @@ namespace Opm {
|
||||
|
||||
class UDQToken {
|
||||
public:
|
||||
UDQToken() = default;
|
||||
UDQToken(const std::string& string_token, UDQTokenType token_type);
|
||||
UDQToken(const std::string& string_token, const std::vector<std::string>& selector);
|
||||
|
||||
static UDQToken serializationTestObject();
|
||||
|
||||
const std::vector<std::string>& selector() const;
|
||||
const std::variant<std::string, double>& value() const;
|
||||
UDQTokenType type() 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:
|
||||
UDQTokenType token_type;
|
||||
UDQTokenType token_type{UDQTokenType::error};
|
||||
std::variant<std::string,double> m_value;
|
||||
std::vector<std::string> m_selector;
|
||||
};
|
||||
|
5
python/CMakeLists.txt
Normal file
5
python/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
project(install_python_binding)
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
install(CODE "message(\"Dummy install\")")
|
@ -25,7 +25,7 @@ do
|
||||
rm -rf $tag
|
||||
fi
|
||||
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} ..
|
||||
|
||||
# make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step
|
||||
|
7
python/pyproject.toml
Normal file
7
python/pyproject.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[build-system]
|
||||
requires= [
|
||||
"setuptools>=42",
|
||||
"scikit-build>=0.13",
|
||||
"cmake>=3.15",
|
||||
"ninja"
|
||||
]
|
@ -8,11 +8,11 @@
|
||||
|
||||
yum-config-manager --add-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
|
||||
|
||||
for python_bin in ${python_versions[*]}
|
||||
do
|
||||
${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
|
||||
|
@ -1,4 +1,4 @@
|
||||
from setuptools import setup
|
||||
from skbuild import setup
|
||||
|
||||
import os
|
||||
|
||||
@ -32,7 +32,6 @@ setup(
|
||||
package_data={'opm' : ['$<TARGET_FILE_NAME:opmcommon_python>']},
|
||||
include_package_data=True,
|
||||
license='Open Source',
|
||||
zip_safe=False,
|
||||
test_suite='tests',
|
||||
setup_requires=["pytest-runner", 'setuptools_scm'],
|
||||
python_requires='>=3.6',
|
||||
|
@ -279,6 +279,7 @@ UDQDefine UDQDefine::serializationTestObject()
|
||||
{
|
||||
UDQDefine result;
|
||||
result.m_keyword = "test1";
|
||||
result.m_tokens = {UDQToken::serializationTestObject()};
|
||||
result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializationTestObject());
|
||||
result.m_var_type = UDQVarType::SEGMENT_VAR;
|
||||
result.string_data = "test2";
|
||||
@ -404,6 +405,7 @@ bool UDQDefine::operator==(const UDQDefine& data) const
|
||||
}
|
||||
|
||||
return (this->keyword() == data.keyword())
|
||||
&& (this->m_tokens == data.m_tokens)
|
||||
&& (this->m_location == data.location())
|
||||
&& (this->var_type() == data.var_type())
|
||||
&& (this->status() == data.status())
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user