Skip to content

Commit

Permalink
Move from setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
philippeVerney committed Nov 15, 2024
1 parent 0c61b35 commit df89e45
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 84 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,6 @@ if (WITH_PYTHON_WRAPPING)
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/python/fetpapi/
)
ENDIF (WIN32)
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/python/setup.py bdist_wheel
install(CODE "execute_process(COMMAND \"${Python3_EXECUTABLE}\" -m build --wheel
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python)")
endif (WITH_PYTHON_WRAPPING)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Download (build and install if necessary) third party libraries:
- BOOST : All versions from version 1.66 should be ok but you may experience some [min/max build issues](https://github.com/boostorg/beast/issues/1980) using version 1.72 or 1.73.
- AVRO : https://avro.apache.org/releases.html#Download (starting from version 1.9.0 [except 1.11.1](https://issues.apache.org/jira/browse/AVRO-3601), build it with the above boost library.)
- (OPTIONALLY) OpenSSL : version 1.1 is known to work.
- (OPTIONALLY) [FESAPI](https://github.com/F2I-Consulting/fesapi/releases) : All versions from version 2.7.0.0 should be ok.
- (OPTIONALLY) [FESAPI](https://github.com/F2I-Consulting/fesapi/releases) : All versions from version 2.7.0.0 should be ok but a minimal version of 2.11.0.0 is recommended to automatically recognize FESAPI CMake Variables using CMake find Module and build silently the EtpClient example.

# Configure the build
FETPAPI uses cmake as its build tool. A 3.12 version or later of cmake is required https://cmake.org/download/. We also recommend using cmake-gui (already included in the bin folder of the binary releases of cmake) which provides a graphical user interface on top of cmake. If you want to use cmake in command line, you would find example in [Github Actions file](./.github/workflows/github-actions.yml). Follow the below instructions :
Expand Down
62 changes: 62 additions & 0 deletions cmake/pyproject.toml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = 'fetpapi'
version = '${Fetpapi_PYTHON_VERSION}'
authors = [
{name = "F2I-CONSULTING"},
]
maintainers = [
{name = "F2I-CONSULTING"},
]
description = "An API for the Energistics Transfer Protocol"
readme = "README.md"
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Application Frameworks ',
'Topic :: File Formats',
]
keywords = [
"energistics",
"resqml",
"eml",
"witsml",
"prodml",
"osdu",
"rddms",
]
requires-python = ">=3.8"
dependencies = [
'fesapi==2.11.0',
]

[project.urls]
source = "https://github.com/F2I-Consulting/fetpapi/issues"
releasenotes = "https://github.com/F2I-Consulting/fetpapi/releases"
documentation = "https://www.f2i-consulting.com/fetpapi/doxygen/"
issues = "https://github.com/F2I-Consulting/fetpapi/issues"

[tool.setuptools]
packages=['fetpapi']
package-dir={"fetpapi" = "fetpapi"}
ext-modules = [
{name='_fetpapi', 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}}
]

[tool.setuptools.package-data]
fetpapi = ["*.dll", "*.so", "*.so.*"]
63 changes: 0 additions & 63 deletions cmake/setup_etp.py.in

This file was deleted.

6 changes: 3 additions & 3 deletions example/withFesapi/etpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
else if (commandTokens[0] == "List") {
std::cout << "*** START LISTING ***" << std::endl;
for (const auto& entryPair : repo.getDataObjects()) {
for (const auto* obj : entryPair.second) {
for (std::unique_ptr<COMMON_NS::AbstractObject> const& obj : entryPair.second) {
if (!obj->isPartial()) {
std::cout << "******************" << entryPair.first << " : " << obj->getTitle() << "******************" << std::endl;
std::cout << "*** SOURCE REL ***" << std::endl;
for (auto srcObj : obj->getRepository()->getSourceObjects(obj)) {
for (auto srcObj : obj->getRepository()->getSourceObjects(obj.get())) {
std::cout << srcObj->getUuid() << " : " << srcObj->getXmlTag() << std::endl;
}
std::cout << "*** TARGET REL ***" << std::endl;
for (auto targetObj : obj->getRepository()->getTargetObjects(obj)) {
for (auto targetObj : obj->getRepository()->getTargetObjects(obj.get())) {
std::cout << targetObj->getUuid() << " : " << targetObj->getXmlTag() << std::endl;
}
std::cout << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ignore cmake and swig auto generated files
setup.py
pyproject.toml
swigGeneratedPythonWrapper.cpp
swigGeneratedPythonWrapper.h

Expand Down
3 changes: 3 additions & 0 deletions python/BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enable CMake boolean variable SWIG_PYTHON_BUILTIN if you want more performance : read [SWIG documentation](http://swig.org/Doc4.0/SWIGDocumentation.html#Python_nn28) for more information about this "builtin" parameter. The main drawback of using such a parameter is that it will be harder/impossible for your Python IDE to enable autocompletion for your FETPAPI python extension. The recommendation is to use SWIG_PYTHON_BUILTIN only in production.

Please disable the SWIG_LINKED_TO_RELEASE cmake variable if you build FETPAPI in Debug mode.
6 changes: 3 additions & 3 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ if (WITH_FESAPI)
set (FESAPI_LIBRARY_RELEASE_WLE ",'${FESAPI_LIBRARY_RELEASE_WLE}'")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set (EXTRA_COMPILE_ARGS "extra_compile_args=['/DSWIG_TYPE_TABLE=FESTAPI']")
set (EXTRA_COMPILE_ARGS "extra-compile-args=['/DSWIG_TYPE_TABLE=FESTAPI']")
else ()
set (EXTRA_COMPILE_ARGS "extra_compile_args=['-DSWIG_TYPE_TABLE=FESTAPI', '-std=c++11']")
set (EXTRA_COMPILE_ARGS "extra-compile-args=['-DSWIG_TYPE_TABLE=FESTAPI', '-std=c++11']")
endif()
configure_file(${CMAKE_SOURCE_DIR}/cmake/setup_etp.py.in ${CMAKE_SOURCE_DIR}/python/setup.py) # Overwrite if different
configure_file(${CMAKE_SOURCE_DIR}/cmake/pyproject.toml.in ${CMAKE_SOURCE_DIR}/python/pyproject.toml) # Overwrite if different

# SWIG execution
message("Generating SWIG Python files...")
Expand Down
12 changes: 10 additions & 2 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Enable CMake boolean variable SWIG_PYTHON_BUILTIN if you want more performance : read [SWIG documentation](http://swig.org/Doc4.0/SWIGDocumentation.html#Python_nn28) for more information about this "builtin" parameter. The main drawback of using such a parameter is that it will be harder/impossible for your Python IDE to enable autocompletion for your FETPAPI python extension. The recommendation is to use SWIG_PYTHON_BUILTIN only in production.
**FETPAPI** is an API for Energistics Transfer Protocol (aka ETP™)
ETP is the default standard to interact with the OSDU RDDMS.

Please disable the SWIG_LINKED_TO_RELEASE cmake variable if you build FETPAPI in Debug mode.
### Examples

A Python script and a Jupyter Notebook are available [here](https://github.com/F2I-Consulting/fetpapi/tree/main/python/example).

### Credits
FETPAPI Product incorporates ETP™ technology/standards provided by the Energistics Consortium, Inc.

ETP is trademark or registered trademark of Energistics Consortium, Inc.
3 changes: 0 additions & 3 deletions python/pyproject.toml

This file was deleted.

6 changes: 6 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from setuptools import setup

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
# If compatibility with legacy builds or versions of tools that don’t support certain packaging standards (e.g. PEP 517 or PEP 660),
# a simple setup.py script can be added to your project (while keeping the configuration in pyproject.toml):
setup()
14 changes: 7 additions & 7 deletions src/etp/ProtocolHandlers/GetFullDataArrayHandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@ namespace ETP_NS
auto dataArray = msg.dataArrays.begin()->second;
if (dataArray.data.item.idx() == 0) {
Energistics::Etp::v12::Datatypes::ArrayOfBoolean& avroArray = dataArray.data.item.get_ArrayOfBoolean();
for (auto i = 0; i < avroArray.values.size(); ++i) {
for (size_t i = 0; i < avroArray.values.size(); ++i) {
values[i] = avroArray.values[i];
}
}
else if (dataArray.data.item.idx() == 1) {
Energistics::Etp::v12::Datatypes::ArrayOfInt& avroArray = dataArray.data.item.get_ArrayOfInt();
for (auto i = 0; i < avroArray.values.size(); ++i) {
for (size_t i = 0; i < avroArray.values.size(); ++i) {
values[i] = avroArray.values[i];
}
}
else if (dataArray.data.item.idx() == 2) {
Energistics::Etp::v12::Datatypes::ArrayOfLong& avroArray = dataArray.data.item.get_ArrayOfLong();
for (auto i = 0; i < avroArray.values.size(); ++i) {
for (size_t i = 0; i < avroArray.values.size(); ++i) {
values[i] = avroArray.values[i];
}
}
else if (dataArray.data.item.idx() == 3) {
Energistics::Etp::v12::Datatypes::ArrayOfFloat& avroArray = dataArray.data.item.get_ArrayOfFloat();
for (auto i = 0; i < avroArray.values.size(); ++i) {
for (size_t i = 0; i < avroArray.values.size(); ++i) {
values[i] = avroArray.values[i];
}
}
else if (dataArray.data.item.idx() == 4) {
Energistics::Etp::v12::Datatypes::ArrayOfDouble& avroArray = dataArray.data.item.get_ArrayOfDouble();
for (auto i = 0; i < avroArray.values.size(); ++i) {
for (size_t i = 0; i < avroArray.values.size(); ++i) {
values[i] = avroArray.values[i];
}
}
Expand All @@ -123,7 +123,7 @@ namespace ETP_NS
*/
else if (dataArray.data.item.idx() == 6) {
std::string& avroValues = dataArray.data.item.get_bytes();
for (auto i = 0; i < avroValues.size(); ++i) {
for (size_t i = 0; i < avroValues.size(); ++i) {
values[i] = avroValues[i];
}
}
Expand All @@ -143,7 +143,7 @@ namespace ETP_NS

auto dataArray = receivedKeyValue.second;
size_t dataArrayValueCount = iterator->second.counts[0];
for (int dimIndex = 1; dimIndex < iterator->second.counts.size(); ++dimIndex) {
for (size_t dimIndex = 1; dimIndex < iterator->second.counts.size(); ++dimIndex) {
dataArrayValueCount *= iterator->second.counts[dimIndex];
}
auto currentStarts = iterator->second.starts;
Expand Down

0 comments on commit df89e45

Please sign in to comment.