Skip to content

Commit

Permalink
pybind11: v2.6.1+ (openPMD#857)
Browse files Browse the repository at this point in the history
* Internal: pybind11 2.6.1

Update the internal version of pybind11, version 2.6.1.

Modifications from the releases:
  - remove test & doc dirs
  - remove wheel packaging (setup.py/cfg, pyproject.toml)
  - remove github templates & CI

* Doc: pybind11 2.6.1+

* CMake: 3.15.0+

For new FindPython support (unifying FindPythonLibs and
FindPythonInterp).

* CMake: Adopt to FindPython.cmake

* pybind11: replace non-ascii

* Changelog: PR number

* CI: Update Python Hints (none needed)

Co-authored-by: Wenzel Jakob <wenzel.jakob@epfl.ch>
  • Loading branch information
ax3l and wjakob authored Dec 23, 2020
1 parent a90e494 commit 5889e06
Show file tree
Hide file tree
Showing 63 changed files with 3,832 additions and 1,836 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
run: |
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3) -DopenPMD_USE_MPI=OFF -DopenPMD_USE_HDF5=ON -DopenPMD_USE_INVASIVE_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DopenPMD_USE_MPI=OFF -DopenPMD_USE_HDF5=ON -DopenPMD_USE_INVASIVE_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build . --parallel 2
ctest --output-on-failure
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
run: |
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3) -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_ADIOS2=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_ADIOS2=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake --build . --parallel 2
ctest --output-on-failure
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3) -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_ADIOS1=ON -DopenPMD_USE_ADIOS2=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_ADIOS1=ON -DopenPMD_USE_ADIOS2=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake --build . --parallel 2
ctest --output-on-failure
Expand All @@ -185,6 +185,6 @@ jobs:
mkdir build && cd build
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
find /usr -name adios.pc
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3) -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake -S .. -B . -DopenPMD_USE_PYTHON=ON -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_INVASIVE_TESTS=ON
cmake --build . --parallel 2
ctest --output-on-failure
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Other
"""""

- switch to C++14 #825
- CMake: require version 3.15.0+ #857
- Python: support 3.6 - 3.9 #828
- NLohmann-JSON dependency updated to 3.9.1+ #839
- pybind11 dependency updated 2.6.1+ #857
- Docs:

- Release cibuildwheel example #775
Expand Down
70 changes: 31 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Preamble ####################################################################
#
cmake_minimum_required(VERSION 3.12.0)
cmake_minimum_required(VERSION 3.15.0)

project(openPMD VERSION 0.12.1) # LANGUAGES CXX

Expand Down Expand Up @@ -249,53 +249,38 @@ endif()

# external library: pybind11 (optional)
if(openPMD_USE_PYTHON STREQUAL AUTO)
if(openPMD_USE_INTERNAL_PYBIND11)
add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/pybind11")
set(openPMD_HAVE_PYTHON TRUE)
message(STATUS "pybind11: Using INTERNAL version 2.4.3")
else()
find_package(pybind11 2.4.3 CONFIG)
if(pybind11_FOUND)
find_package(Python 3.6.0 COMPONENTS Interpreter Development)
if(Python_FOUND)
if(openPMD_USE_INTERNAL_PYBIND11)
add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/pybind11")
set(openPMD_HAVE_PYTHON TRUE)
message(STATUS "pybind11: Found version '${pybind11_VERSION}'")
message(STATUS "pybind11: Using INTERNAL version 2.6.1")
else()
set(openPMD_HAVE_PYTHON FALSE)
find_package(pybind11 2.6.1 CONFIG)
if(pybind11_FOUND)
set(openPMD_HAVE_PYTHON TRUE)
message(STATUS "pybind11: Found version '${pybind11_VERSION}'")
else()
set(openPMD_HAVE_PYTHON FALSE)
endif()
endif()
endif()
if(openPMD_HAVE_PYTHON AND
PYTHON_VERSION_MAJOR LESS 3)
else()
set(openPMD_HAVE_PYTHON FALSE)
message(STATUS "python: Found version '"
"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}' "
"is NOT supported. Set for example "
"-DPYTHON_EXECUTABLE=$(which python3) "
"to use 3.6+.")
endif()
elseif(openPMD_USE_PYTHON)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
if(openPMD_USE_INTERNAL_PYBIND11)
add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/pybind11")
set(openPMD_HAVE_PYTHON TRUE)
message(STATUS "pybind11: Using INTERNAL version 2.4.3")
message(STATUS "pybind11: Using INTERNAL version 2.6.1")
else()
find_package(pybind11 2.4.3 REQUIRED CONFIG)
find_package(pybind11 2.6.1 REQUIRED CONFIG)
set(openPMD_HAVE_PYTHON TRUE)
message(STATUS "pybind11: Found version '${pybind11_VERSION}'")
endif()
if(PYTHON_VERSION_MAJOR LESS 3)
message(FATAL_ERROR "python: Found version '"
"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}' "
"is NOT supported. Set for example "
"-DPYTHON_EXECUTABLE=$(which python3) "
"to use 3.6+.")
endif()
else()
set(openPMD_HAVE_PYTHON FALSE)
endif()
if(openPMD_HAVE_PYTHON)
add_library(openPMD::thirdparty::pybind11 INTERFACE IMPORTED)
target_link_libraries(openPMD::thirdparty::pybind11
INTERFACE pybind11::pybind11)
endif()


# Targets #####################################################################
Expand Down Expand Up @@ -535,7 +520,7 @@ endif()

# python bindings
if(openPMD_HAVE_PYTHON)
pybind11_add_module(openPMD.py MODULE SYSTEM
add_library(openPMD.py MODULE
src/binding/python/openPMD.cpp
src/binding/python/Access.cpp
src/binding/python/Attributable.cpp
Expand All @@ -560,6 +545,13 @@ if(openPMD_HAVE_PYTHON)
src/binding/python/UnitDimension.cpp
)
target_link_libraries(openPMD.py PRIVATE openPMD)
target_link_libraries(openPMD.py PRIVATE pybind11::module pybind11::lto pybind11::windows_extras)

pybind11_extension(openPMD.py)
pybind11_strip(openPMD.py)

set_target_properties(openPMD.py PROPERTIES CXX_VISIBILITY_PRESET "hidden"
CUDA_VISIBILITY_PRESET "hidden")

# ancient Clang releases
# https://github.com/openPMD/openPMD-api/issues/542
Expand All @@ -581,7 +573,7 @@ if(openPMD_HAVE_PYTHON)
)
else()
set(CMAKE_INSTALL_PYTHONDIR_DEFAULT
"${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages"
"${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages"
)
endif()
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR_DEFAULT}"
Expand Down Expand Up @@ -926,7 +918,7 @@ if(BUILD_TESTING)
if(openPMD_HAVE_PYTHON)
# do we have mpi4py for MPI-parallel Python tests?
if(openPMD_HAVE_MPI)
execute_process(COMMAND ${PYTHON_EXECUTABLE}
execute_process(COMMAND ${Python_EXECUTABLE}
-m mpi4py
-c "import mpi4py.MPI"
RESULT_VARIABLE MPI4PY_RETURN
Expand Down Expand Up @@ -962,7 +954,7 @@ if(BUILD_TESTING)
if(openPMD_HAVE_HDF5)
if(EXAMPLE_DATA_FOUND)
add_test(NAME Unittest.py
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python_EXECUTABLE}
${openPMD_SOURCE_DIR}/test/python/unittest/Test.py -v
WORKING_DIRECTORY
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
Expand Down Expand Up @@ -1035,7 +1027,7 @@ if(BUILD_TESTING)
# console scripts and replace the all-binary CLI tools.)
foreach(pymodulename ${openPMD_PYTHON_CLI_MODULE_NAMES})
add_test(NAME CLI.py.help.${pymodulename}
COMMAND ${PYTHON_EXECUTABLE} -m openpmd_api.${pymodulename} --help
COMMAND ${Python_EXECUTABLE} -m openpmd_api.${pymodulename} --help
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
if(WIN32)
Expand Down Expand Up @@ -1068,7 +1060,7 @@ if(BUILD_TESTING)
if(openPMD_HAVE_MPI AND MPI4PY_RETURN EQUAL 0)
# see https://mpi4py.readthedocs.io/en/stable/mpi4py.run.html
add_test(NAME Example.py.${examplename}
COMMAND ${MPI_TEST_EXE} ${PYTHON_EXECUTABLE} -m mpi4py
COMMAND ${MPI_TEST_EXE} ${Python_EXECUTABLE} -m mpi4py
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${examplename}.py
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
Expand All @@ -1077,7 +1069,7 @@ if(BUILD_TESTING)
endif()
else()
add_test(NAME Example.py.${examplename}
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python_EXECUTABLE}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${examplename}.py
WORKING_DIRECTORY
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ RUN cd /opt/src; \
#RUN mkdir build \
# && cd build \
# && /opt/cmake/bin/cmake \
# -DPYTHON_EXECUTABLE=$(which /opt/python/cp${PY_TARGET}-cp${PY_TARGET}m/bin/python) \
# -DPython_ROOT_DIR=$(which /opt/python/cp${PY_TARGET}-cp${PY_TARGET}m) \
# -DHDF5_USE_STATIC_LIBRARIES=ON \
# -DBUILD_SHARED_LIBS=OFF \
# -DBUILD_TESTING=OFF \
Expand Down
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Upgrade Guide

Building openPMD-api now requires a compiler that supports C++14 or newer.
Supported Python version are now 3.6 to 3.9.
CMake 3.15.0 is now the minimally supported version for CMake.

Python
^^^^^^
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ Our manual shows full [read & write examples](https://openpmd-api.readthedocs.io
## Dependencies

Required:
* CMake 3.12.0+
* CMake 3.15.0+
* C++14 capable compiler, e.g. g++ 5.0+, clang 5.0+, VS 2017+

Shipped internally in `share/openPMD/thirdParty/`:
* [MPark.Variant](https://github.com/mpark/variant) 1.4.0+ ([BSL-1.0](https://github.com/mpark/variant/blob/master/LICENSE.md))
* [Catch2](https://github.com/catchorg/Catch2) 2.6.1+ ([BSL-1.0](https://github.com/catchorg/Catch2/blob/master/LICENSE.txt))
* [pybind11](https://github.com/pybind/pybind11) 2.4.3+ ([new BSD](https://github.com/pybind/pybind11/blob/master/LICENSE))
* [pybind11](https://github.com/pybind/pybind11) 2.6.1+ ([new BSD](https://github.com/pybind/pybind11/blob/master/LICENSE))
* [NLohmann-JSON](https://github.com/nlohmann/json) 3.9.1+ ([MIT](https://github.com/nlohmann/json/blob/develop/LICENSE.MIT))

I/O backends:
Expand All @@ -120,7 +120,7 @@ while those can be built either with or without:
Optional language bindings:
* Python:
* Python 3.6 - 3.9
* pybind11 2.4.3+
* pybind11 2.6.1+
* numpy 1.15+
* mpi4py 2.1+

Expand Down Expand Up @@ -223,7 +223,7 @@ cd openPMD-api-build
# for options append:
# -DopenPMD_USE_...=...
# e.g. for python support add:
# -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3)
# -DopenPMD_USE_PYTHON=ON
cmake ../openPMD-api

cmake --build .
Expand All @@ -248,7 +248,7 @@ CMake controls options with prefixed `-D`, e.g. `-DopenPMD_USE_MPI=OFF`:
| `openPMD_USE_INVASIVE_TESTS` | ON/**OFF** | Enable unit tests that modify source code <sup>1</sup> |
| `openPMD_USE_VERIFY` | **ON**/OFF | Enable internal VERIFY (assert) macro independent of build type <sup>2</sup> |
| `openPMD_INSTALL` | **ON**/OFF | Add installation targets |
| `PYTHON_EXECUTABLE` | (first found) | Path to Python executable |
| `Python_EXECUTABLE` | (newest found) | Path to Python executable |

<sup>1</sup> *e.g. changes C++ visibility keywords, breaks MSVC*
<sup>2</sup> *this includes most pre-/post-condition checks, disabling without specific cause is highly discouraged*
Expand All @@ -260,7 +260,7 @@ The following options allow to switch to external installs:
|---------------------------------|------------|---------------|---------|
| `openPMD_USE_INTERNAL_VARIANT` | **ON**/OFF | MPark.Variant | 1.4.0+ |
| `openPMD_USE_INTERNAL_CATCH` | **ON**/OFF | Catch2 | 2.6.1+ |
| `openPMD_USE_INTERNAL_PYBIND11` | **ON**/OFF | pybind11 | 2.4.3+ |
| `openPMD_USE_INTERNAL_PYBIND11` | **ON**/OFF | pybind11 | 2.6.1+ |
| `openPMD_USE_INTERNAL_JSON` | **ON**/OFF | NLohmann-JSON | 3.9.1+ |

By default, this will build as a shared library (`libopenPMD.[so|dylib|dll]`) and installs also its headers.
Expand Down
1 change: 0 additions & 1 deletion Singularity
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Supported frontends are C++11 and Python3.
-DopenPMD_USE_ADIOS1=ON \
-DopenPMD_USE_ADIOS2=OFF \
-DopenPMD_USE_PYTHON=ON \
-DPYTHON_EXECUTABLE=$(which python3) \
-DBUILD_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_INSTALL_PYTHONDIR=lib/python3.6/dist-packages
Expand Down
4 changes: 2 additions & 2 deletions docs/source/dev/buildoptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CMake Option Values Description
``openPMD_USE_INVASIVE_TESTS`` ON/**OFF** Enable unit tests that modify source code :sup:`1`
``openPMD_USE_VERIFY`` **ON**/OFF Enable internal VERIFY (assert) macro independent of build type :sup:`2`
``openPMD_INSTALL`` **ON**/OFF Add installation targets
``PYTHON_EXECUTABLE`` (first found) Path to Python executable
``Python_EXECUTABLE`` (newest found) Path to Python executable
============================== =============== ========================================================================

:sup:`1` e.g. changes C++ visibility keywords, breaks MSVC
Expand Down Expand Up @@ -69,7 +69,7 @@ CMake Option Values Installs Library Version
================================= =========== ======== ============= ========
``openPMD_USE_INTERNAL_VARIANT`` **ON**/OFF Yes MPark.Variant 1.4.0+
``openPMD_USE_INTERNAL_CATCH`` **ON**/OFF No Catch2 2.6.1+
``openPMD_USE_INTERNAL_PYBIND11`` **ON**/OFF No pybind11 2.4.3+
``openPMD_USE_INTERNAL_PYBIND11`` **ON**/OFF No pybind11 2.6.1+
``openPMD_USE_INTERNAL_JSON`` **ON**/OFF No NLohmann-JSON 3.9.1+
================================= =========== ======== ============= ========

Expand Down
6 changes: 3 additions & 3 deletions docs/source/dev/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ These are currently:
Required
--------

* CMake 3.12.0+
* CMake 3.15.0+
* C++14 capable compiler, e.g. g++ 5.0+, clang 5.0+, VS 2017+

Shipped internally
Expand All @@ -19,7 +19,7 @@ The following libraries are shipped internally in ``share/openPMD/thirdParty/``

* `MPark.Variant <https://github.com/mpark/variant>`_ 1.4.0+ (`BSL-1.0 <https://github.com/mpark/variant/blob/master/LICENSE.md>`_)
* `Catch2 <https://github.com/catchorg/Catch2>`_ 2.6.1+ (`BSL-1.0 <https://github.com/catchorg/Catch2/blob/master/LICENSE.txt>`__)
* `pybind11 <https://github.com/pybind/pybind11>`_ 2.4.3+ (`new BSD <https://github.com/pybind/pybind11/blob/master/LICENSE>`_)
* `pybind11 <https://github.com/pybind/pybind11>`_ 2.6.1+ (`new BSD <https://github.com/pybind/pybind11/blob/master/LICENSE>`_)
* `NLohmann-JSON <https://github.com/nlohmann/json>`_ 3.9.1+ (`MIT <https://github.com/nlohmann/json/blob/develop/LICENSE.MIT>`_)

Optional: I/O backends
Expand All @@ -40,7 +40,7 @@ Optional: language bindings
* Python:

* Python 3.6 - 3.9
* pybind11 2.4.3+
* pybind11 2.6.1+
* numpy 1.15+
* mpi4py 2.1+

Expand Down
2 changes: 1 addition & 1 deletion docs/source/install/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Linux & OSX
# for options append:
# -DopenPMD_USE_...=...
# e.g. for python support add:
# -DopenPMD_USE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3)
# -DopenPMD_USE_PYTHON=ON
cmake ../openPMD-api
cmake --build .
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools>38.6", "wheel", "cmake>=3.12.0,<4.0.0", "pybind11>=2.4.3,<3.0.0"]
requires = ["setuptools>38.6", "wheel", "cmake>=3.15.0,<4.0.0", "pybind11>=2.6.1,<3.0.0"]
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ def run(self):
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError(
"CMake 3.12.0+ must be installed to build the following " +
"CMake 3.15.0+ must be installed to build the following " +
"extensions: " +
", ".join(e.name for e in self.extensions))

cmake_version = LooseVersion(re.search(
r'version\s*([\d.]+)',
out.decode()
).group(1))
if cmake_version < '3.12.0':
raise RuntimeError("CMake >= 3.12.0 is required")
if cmake_version < '3.15.0':
raise RuntimeError("CMake >= 3.15.0 is required")

for ext in self.extensions:
self.build_extension(ext)
Expand All @@ -48,7 +48,7 @@ def build_extension(self, ext):
os.path.join(extdir, "openpmd_api"),
# '-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=' + extdir,
'-DCMAKE_PYTHON_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable,
'-DPython_ROOT_DIR=' + sys.exec_prefix,
'-DopenPMD_USE_PYTHON:BOOL=ON',
# variants
'-DopenPMD_USE_MPI:BOOL=' + openPMD_USE_MPI,
Expand Down
Loading

0 comments on commit 5889e06

Please sign in to comment.