Skip to content

Commit

Permalink
Collection of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
havogt committed Mar 21, 2024
1 parent 263183b commit b5732fd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
mkdir build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DPYTHON_EXECUTABLE=`which python3` \
-DPython3_EXECUTABLE=`which python3` \
-DSERIALBOX_TESTING=ON \
-DSERIALBOX_ENABLE_FORTRAN=${TEST_FORTRAN} \
-DSERIALBOX_TESTING_FORTRAN=${TEST_FORTRAN} \
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install" CACHE PATH "CMake install prefix")

cmake_policy(SET CMP0048 NEW)
project(Serialbox LANGUAGES C CXX VERSION 2.6.1)
cmake_minimum_required(VERSION 3.12.0)
project(Serialbox LANGUAGES C CXX VERSION 2.6.1)

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_EXTENSIONS OFF)
Expand Down Expand Up @@ -218,7 +218,7 @@ endif()

#---------------------------------------- Python ---------------------------------------------------
if(SERIALBOX_ENABLE_PYTHON)
find_package(PythonInterp 3.4)
find_package(Python3 COMPONENTS Interpreter)

# Python tests are enabled by default if we can find "nose" and "numpy"
set(ENABLE_PYTHON_TESTS OFF)
Expand Down
3 changes: 1 addition & 2 deletions cmake/SerialboxTooling.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ function(serialbox_run_pp_ser)

if(pp_ser_input)
add_custom_command(OUTPUT ${pp_ser_output}
COMMAND ${PYTHON_EXECUTABLE} ${SERIALBOX_PPSER} --verbose
COMMAND ${Python3_EXECUTABLE} ${SERIALBOX_PPSER} --verbose
--ignore-identical
--output-dir=${output_dir}
${pp_ser_input}
DEPENDS ${pp_ser_input}
COMMENT "Preprocessing for serialization")
endif()
endfunction(serialbox_run_pp_ser)

11 changes: 5 additions & 6 deletions cmake/modules/FindPythonModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# find_python_module(PyQt5 REQUIRED)
#
# The module makes use of the ${PYTHON_EXECUTABLE} which needs to be set before calling the
# The module makes use of the ${Python3_EXECUTABLE} which needs to be set before calling the
# find_python_module function.
#
# Variables defined by this cmake module:
Expand All @@ -25,7 +25,7 @@ function(find_python_module module)
endif()

# A module's location is usually a directory, but for binary modules it's a .so file.
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
execute_process(COMMAND "${Python3_EXECUTABLE}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
Expand All @@ -34,7 +34,7 @@ function(find_python_module module)

# Set result
if(NOT _${module}_status)
message(STATUS "Found Python module \"${module}\" for Python: ${PYTHON_EXECUTABLE}")
message(STATUS "Found Python module \"${module}\" for Python: ${Python3_EXECUTABLE}")
set(PY_${module_upper}_PATH ${_${module}_location}
CACHE STRING "Location of Python module ${module}")
set(PY_${module_upper}_FOUND TRUE
Expand All @@ -43,11 +43,10 @@ function(find_python_module module)
else()
set(PY_${module_upper}_FOUND FALSE)
if(${module}_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find module ${module} for python ${PYTHON_EXECUTABLE}")
message(FATAL_ERROR "Could NOT find module ${module} for python ${Python3_EXECUTABLE}")
else()
message(STATUS "Could NOT find \"${module}\" for python: ${PYTHON_EXECUTABLE}")
message(STATUS "Could NOT find \"${module}\" for python: ${Python3_EXECUTABLE}")
endif()
endif()
endif(NOT PY_${module_upper}_FOUND)
endfunction(find_python_module)

11 changes: 6 additions & 5 deletions src/serialbox-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ def build_extension(self, ext):
# Can be set with Conda-Build, for example.
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")

# Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
# Set Python3_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
# EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
# from Python.
cmake_args = [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(extdir),
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
"-DPython3_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
"-DSERIALBOX_ENABLE_FORTRAN=false",
"-DCMAKE_BUILD_RPATH={}".format(origin),
"-DSERIALBOX_ENABLE_SDB=false",
"-DSERIALBOX_ASYNC_API=false",

]
build_args = []
# Adding CMake arguments set as environment variable
Expand All @@ -70,6 +69,7 @@ def build_extension(self, ext):
]
if sys.platform == "darwin":
from distutils import sysconfig

vars = sysconfig.get_config_vars()
vars["SO"] = ".dylib"
vars["EXT_SUFFIX"] = ".dylib"
Expand All @@ -89,7 +89,6 @@ def build_extension(self, ext):
pass

else:

# Single config generators are handled "normally"
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})

Expand Down Expand Up @@ -151,7 +150,9 @@ def _get_origin(self):
author="Serialbox Developers",
packages=find_packages(),
install_requires=["numpy"],
ext_modules=[CMakeExtension("libSerialboxC", sourcedir=os.path.join(DIR, "../../"))],
ext_modules=[
CMakeExtension("libSerialboxC", sourcedir=os.path.join(DIR, "../../"))
],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
)
1 change: 1 addition & 0 deletions src/serialbox/core/hash/Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Hash {
///
/// \return Hex representation as string of the computed hash
virtual std::string hash(const void* data, int length) = 0;
virtual ~Hash() = default;
};

} // namespace serialbox
Expand Down
1 change: 1 addition & 0 deletions src/serialbox/core/hash/SHA256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//===------------------------------------------------------------------------------------------===//

#include "serialbox/core/hash/SHA256.h"
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <sstream>
Expand Down
6 changes: 3 additions & 3 deletions test/serialbox-python/run_python_tests.sh.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${PROJECT_BINARY_DIR}/src/serialbox-c"
#
# Check if nose exists
#
"${PYTHON_EXECUTABLE}" -c "import nose"
"${Python3_EXECUTABLE}" -c "import nose"
if [ "$?" == "1" ]; then
echo ">> Python tests require module 'nose'"
exit 1
Expand All @@ -33,10 +33,10 @@ fi
# Run serialbox python tests with nose
#
cd "${PYTHON_TEST_DIR}/serialbox"
"${PYTHON_EXECUTABLE}" -m "nose"
"${Python3_EXECUTABLE}" -m "nose"

#
# Run the sdb tests with nose
#
cd "${PYTHON_TEST_DIR}/sdb/sdbcore"
"${PYTHON_EXECUTABLE}" -m "nose"
"${Python3_EXECUTABLE}" -m "nose"

0 comments on commit b5732fd

Please sign in to comment.