Skip to content

Commit

Permalink
Fix Python build and example
Browse files Browse the repository at this point in the history
  • Loading branch information
philippeVerney committed Jul 11, 2024
1 parent d909167 commit 655be82
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 100 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cd ${{ github.workspace }}/..
mkdir build
cd build
cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DBoost_INCLUDE_DIR=${{ runner.temp }}\boost-install -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DWITH_ETP_SSL=FALSE ${{ github.workspace }}
cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DBoost_INCLUDE_DIR=${{ runner.temp }}\boost-install -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DAVRO_USE_STATIC_LIBS=TRUE -DWITH_ETP_SSL=FALSE ${{ github.workspace }}
cmake --build . --config Release -j2
windows-2019-with-fesapi:
runs-on: windows-2019
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
cd ${{ github.workspace }}/..
mkdir build
cd build
cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DBoost_INCLUDE_DIR=${{ runner.temp }}\boost-install -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DWITH_FESAPI=TRUE -DFESAPI_ROOT=${{ runner.temp }}/fesapi-install -DWITH_ETP_SSL=FALSE ${{ github.workspace }}
cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DBoost_INCLUDE_DIR=${{ runner.temp }}\boost-install -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DAVRO_USE_STATIC_LIBS=TRUE -DWITH_FESAPI=TRUE -DFESAPI_ROOT=${{ runner.temp }}/fesapi-install -DWITH_ETP_SSL=FALSE ${{ github.workspace }}
cmake --build . --config Release -j2
ubuntu-20:
runs-on: ubuntu-20.04
Expand All @@ -105,7 +105,7 @@ jobs:
cd ${{ github.workspace }}/..
mkdir build
cd build
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install ${{ github.workspace }}
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -AVRO_USE_STATIC_LIBS=TRUE ${{ github.workspace }}
cmake --build . --config Release -j2
ubuntu-20-java8:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
cd ${{ github.workspace }}/..
mkdir build
cd build
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DWITH_JAVA_WRAPPING=TRUE ${{ github.workspace }}
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DAVRO_USE_STATIC_LIBS=TRUE -DWITH_JAVA_WRAPPING=TRUE ${{ github.workspace }}
cmake --build . --config Release -j2
ubuntu-20-java8-with-fesapi:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -191,5 +191,5 @@ jobs:
cd ${{ github.workspace }}/..
mkdir build
cd build
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DWITH_FESAPI=TRUE -DFESAPI_ROOT=${{ runner.temp }}/fesapi-install -DFESAPI_JAR=${{ runner.temp }}/fesapi-install/lib/fesapiJava-2.9.0.1.jar -DWITH_JAVA_WRAPPING=TRUE ${{ github.workspace }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
cmake -DAVRO_ROOT=${{ runner.temp }}/avro-cpp-1.11.3-install -DAVRO_USE_STATIC_LIBS=TRUE -DWITH_FESAPI=TRUE -DFESAPI_ROOT=${{ runner.temp }}/fesapi-install -DFESAPI_JAR=${{ runner.temp }}/fesapi-install/lib/fesapiJava-2.9.0.1.jar -DWITH_JAVA_WRAPPING=TRUE ${{ github.workspace }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
cmake --build . --config Release -j2
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
/swig/swigGeneratedJavaWrapper.cpp
/swig/swigGeneratedJavaWrapper.h

## Ignore python swig generated files
/swig/swigGeneratedPythonWrapper.cpp
/swig/swigGeneratedPythonWrapper.h

## Ignore Visual Studio Code files
##
## Get latest from https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
Expand Down
32 changes: 29 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.21)

project(Fetpapi)

Expand Down Expand Up @@ -146,7 +146,7 @@ if (WITH_ETP_SSL)
if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
find_package(OpenSSL REQUIRED)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto OpenSSL::applink)
endif ()

if (WITH_FESAPI)
Expand Down Expand Up @@ -339,4 +339,30 @@ if (WITH_FESAPI)
endif (WITH_FESAPI)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetpapiConfig.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Fetpapi")
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Fetpapi")

if (WITH_PYTHON_WRAPPING)
IF (WIN32)
install(
TARGETS ${PROJECT_NAME}
RUNTIME_DEPENDENCY_SET dep-set
)
cmake_path(GET SSL_EAY_RELEASE PARENT_PATH openSslLibPath)
cmake_path(GET openSslLibPath PARENT_PATH openSslPath)
cmake_path(APPEND openSslPath "bin" OUTPUT_VARIABLE openSslBinPath)
install(
RUNTIME_DEPENDENCY_SET dep-set
PRE_EXCLUDE_REGEXES "api-ms-.*" "ext-ms-.*" "[Ff]esapi[Cc]pp.*\\.dll"
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
DIRECTORIES ${openSslBinPath}
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/python/fetpapi/
)
ELSE ()
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/python/fetpapi/
)
ENDIF (WIN32)
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/python/setup.py bdist_wheel
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python)")
endif (WITH_PYTHON_WRAPPING)
9 changes: 7 additions & 2 deletions cmake/modules/FindAVRO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ set(_AVRO_SEARCH_NORMAL
unset(_AVRO_x86)
list(APPEND _AVRO_SEARCHES _AVRO_SEARCH_NORMAL)

set(AVRO_NAMES avrocpp avrocpp_s)
set(AVRO_NAMES_DEBUG avrod avrocpp_d avrocpp_s_d)
if(AVRO_USE_STATIC_LIBS)
set(AVRO_NAMES avrocpp_s)
set(AVRO_NAMES_DEBUG avrocpp_s_d)
else()
set(AVRO_NAMES avrocpp)
set(AVRO_NAMES_DEBUG avrod avrocpp_d)
endif()

# Try each search configuration.
foreach(search ${_AVRO_SEARCHES})
Expand Down
58 changes: 37 additions & 21 deletions cmake/setup_etp.py.in
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension

fetpapi_module = Extension('_fetpapi',
sources=['swigGeneratedPythonWrapper.cpp'],
include_dirs=[
'${Boost_INCLUDE_DIR}',
'${AVRO_INCLUDE_DIR}'
],
library_dirs=[
'${CMAKE_INSTALL_PREFIX}/lib',
'${Boost_LIBRARY_DIR_RELEASE}',
'${AVRO_LIBRARY_DIR_RELEASE}'
],
libraries=[
'${ASSEMBLY_NAME}',
'${AVRO_LIBRARY_RELEASE_WLE}'
],
extra_compile_args=['-std=c++11'],
sources=['swigGeneratedPythonWrapper.cpp'],
include_dirs=['${Boost_INCLUDE_DIR}','${AVRO_INCLUDE_DIR}'${FESAPI_INCLUDE_DIR_FOR_SETUP_PY}],
library_dirs=['${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}'${AVRO_LIBRARY_DIR_RELEASE}${Boost_LIBRARY_DIR_RELEASE}${FESAPI_LIBRARY_DIR_RELEASE}],
libraries=['${ASSEMBLY_NAME}'${AVRO_LIBRARY_RELEASE_WLE}${Boost_LIBRARY_RELEASE_WLE}${FESAPI_LIBRARY_RELEASE_WLE}],
${EXTRA_COMPILE_ARGS},
)

setup (name = 'fetpapi',
version = '1.0',
author = "F2I-CONSULTING",
description = """An API for the Energistics Transfert Protocol""",
ext_modules = [fetpapi_module],
py_modules = ["fetpapi"],
version = '${Fetpapi_PYTHON_VERSION}',
author = 'F2I-CONSULTING',
maintainer = 'F2I-CONSULTING',
url = 'https://github.com/F2I-Consulting/fetpapi',
description = 'An API for the Energistics Transfer Protocol',
license = 'Apache 2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',

'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',

'License :: OSI Approved :: Apache Software License',

'Natural Language :: English',

'Programming Language :: Python :: 3',
],
keywords='energistics resqml witsml prodml etp rddms osdu development',
project_urls={
'Discourse': 'https://discourse.f2i-consulting.com/',
'Tracker': 'https://github.com/F2I-Consulting/fetpapi/issues',
},
python_requires='>=3',
include_package_data=True,
packages=['fetpapi'],
package_dir={'fetpapi': 'fetpapi'},
package_data={'fetpapi': ['*.dll', '*.so', '*.so.*']},
ext_package='fetpapi',
ext_modules = [fetpapi_module],
install_requires=['fesapi==2.10.0',],
)
54 changes: 32 additions & 22 deletions cmake/swigEtp1_2Include.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-----------------------------------------------------------------------*/
%module(directors="1") fetpapi
%module(directors="1", "threads"=1) fetpapi
%feature("autodoc", "1");
%feature("python:annotations", "c");
%catches(Swig::DirectorException);

%{
Expand All @@ -28,9 +30,10 @@ under the License.
%}

#ifdef WITH_FESAPI
%import "${FESAPI_INCLUDE_DIR}/fesapi/common/DataObjectReference.h"
%import "${FESAPI_INCLUDE_DIR}/fesapi/common/HdfProxyFactory.h"
%import "${FESAPI_INCLUDE_DIR}/fesapi/common/AbstractObject.h"
%include "${FESAPI_INCLUDE_DIR}/fesapi/nsDefinitions.h"
%import(module="fesapi") "${FESAPI_INCLUDE_DIR}/fesapi/common/DataObjectReference.h"
%import(module="fesapi") "${FESAPI_INCLUDE_DIR}/fesapi/common/HdfProxyFactory.h"
%import(module="fesapi") "${FESAPI_INCLUDE_DIR}/fesapi/common/AbstractObject.h"
#endif

%include "stdint.i"
Expand Down Expand Up @@ -353,42 +356,42 @@ namespace Energistics {
double get_double();
void set_double(const double& v);

std::string get_string();
std::string get_string();
void set_string(const std::string& v);

Energistics::Etp::v12::Datatypes::ArrayOfBoolean get_ArrayOfBoolean();
Energistics::Etp::v12::Datatypes::ArrayOfBoolean get_ArrayOfBoolean();
void set_ArrayOfBoolean(const Energistics::Etp::v12::Datatypes::ArrayOfBoolean& v);

Energistics::Etp::v12::Datatypes::ArrayOfInt get_ArrayOfInt();
Energistics::Etp::v12::Datatypes::ArrayOfInt get_ArrayOfInt();
void set_ArrayOfInt(const Energistics::Etp::v12::Datatypes::ArrayOfInt& v);

Energistics::Etp::v12::Datatypes::ArrayOfLong get_ArrayOfLong();
void set_ArrayOfLong(const Energistics::Etp::v12::Datatypes::ArrayOfLong& v);
void set_ArrayOfLong(const Energistics::Etp::v12::Datatypes::ArrayOfLong& v);

Energistics::Etp::v12::Datatypes::ArrayOfFloat get_ArrayOfFloat();
Energistics::Etp::v12::Datatypes::ArrayOfFloat get_ArrayOfFloat();
void set_ArrayOfFloat(const Energistics::Etp::v12::Datatypes::ArrayOfFloat& v);

Energistics::Etp::v12::Datatypes::ArrayOfDouble get_ArrayOfDouble();
Energistics::Etp::v12::Datatypes::ArrayOfDouble get_ArrayOfDouble();
void set_ArrayOfDouble(const Energistics::Etp::v12::Datatypes::ArrayOfDouble& v);

Energistics::Etp::v12::Datatypes::ArrayOfString get_ArrayOfString();
void set_ArrayOfString(const Energistics::Etp::v12::Datatypes::ArrayOfString& v);
Energistics::Etp::v12::Datatypes::ArrayOfString get_ArrayOfString();
void set_ArrayOfString(const Energistics::Etp::v12::Datatypes::ArrayOfString& v);

std::string get_bytes();
void set_bytes(const std::string& v);
std::string get_bytes();
void set_bytes(const std::string& v);
};

struct DataValue{
struct DataValue{
Energistics::Etp::v12::Datatypes::DataValueitem_t item;
};

struct ErrorInfo{
struct ErrorInfo{
std::string message;
int32_t code;
};

struct AnyArrayitem_t {
public:
public:
size_t idx() const;

Energistics::Etp::v12::Datatypes::ArrayOfBoolean get_ArrayOfBoolean();
Expand Down Expand Up @@ -417,15 +420,15 @@ namespace Energistics {
Energistics::Etp::v12::Datatypes::AnyArrayitem_t item;
};

enum AnyArrayType {
enum class AnyArrayType {
arrayOfBoolean=0,
arrayOfInt=1,
arrayOfLong=2,
arrayOfFloat=3,
arrayOfDouble=4,
arrayOfString=5,
bytes=6
};
};

enum class AnyLogicalArrayType {
arrayOfBoolean=0,
Expand All @@ -449,7 +452,7 @@ namespace Energistics {
arrayOfDouble64BE=18,
arrayOfString=19,
arrayOfCustom=20
};
};
}
}
}
Expand Down Expand Up @@ -477,7 +480,7 @@ namespace Energistics {
std::vector<std::string> dataObjectTypes;
};

enum ContextScopeKind {
enum class ContextScopeKind {
self=0,
sources=1,
targets=2,
Expand Down Expand Up @@ -528,7 +531,7 @@ namespace Energistics {
std::map<std::string, Energistics::Etp::v12::Datatypes::DataValue> customData;
};

enum RelationshipKind {
enum class RelationshipKind {
Primary=0,
Secondary=1,
Both=2
Expand Down Expand Up @@ -793,6 +796,9 @@ namespace Energistics {
static const int messageTypeId=4;
};

#if defined(SWIGPYTHON)
%rename(Store_Chunk) Chunk;
#endif
struct Chunk{
Energistics::Etp::v12::Datatypes::Uuid blobId;
std::string data;
Expand Down Expand Up @@ -991,6 +997,10 @@ namespace Energistics {
std::map<std::string, std::string> success;
static const int messageTypeId=10;
};

#if defined(SWIGPYTHON)
%rename(StoreNotification_Chunk) Chunk;
#endif
struct Chunk{
Energistics::Etp::v12::Datatypes::Uuid blobId;
std::string data;
Expand Down
13 changes: 13 additions & 0 deletions example/withFesapi/etpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ under the License.
#include "etp/fesapi/FesapiHdfProxy.h"
#include "etp/fesapi/FesapiHelpers.h"

namespace {
std::vector<std::string> tokenize(const std::string& str, char delimiter) {
std::vector<std::string> tokens;
std::stringstream ss(str);
std::string token;
while (getline(ss, token, delimiter)) {
tokens.push_back(token);
}

return tokens;
}
}

void printHelp()
{
std::cout << "List of available commands :" << std::endl;
Expand Down
11 changes: 11 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ignore cmake and swig auto generated files
setup.py
swigGeneratedPythonWrapper.cpp
swigGeneratedPythonWrapper.h

# Ignore everything in these directories
build/*
dist/*
*.egg-info/*
example/*.epc
example/*.h5
Loading

0 comments on commit 655be82

Please sign in to comment.