| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,13 @@ | |||
| 6 | 6 | # The full license is in the file LICENSE, distributed with this software. # | |
| 7 | 7 | ############################################################################ | |
| 8 | 8 | ||
| 9 | + if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
| 10 | + project(xtensor-python-benchmark) | ||
| 11 | + | ||
| 12 | + find_package(xtensor-python REQUIRED CONFIG) | ||
| 13 | + set(XTENSOR_PYTHON_INCLUDE_DIR ${xtensor-python_INCLUDE_DIRS}) | ||
| 14 | + endif () | ||
| 15 | + | ||
| 9 | 16 | message(STATUS "Forcing tests build type to Release") | |
| 10 | 17 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) | |
| 11 | 18 | ||
@@ -72,7 +79,7 @@ if (APPLE) | |||
| 72 | 79 | elseif (MSVC) | |
| 73 | 80 | target_link_libraries(${XTENSOR_PYTHON_BENCHMARK_TARGET} ${PYTHON_LIBRARIES}) | |
| 74 | 81 | else () | |
| 75 | - target_link_libraries(${XTENSOR_PYTHON_BENCHMARK_TARGET} "-shared") | ||
| 82 | + target_link_libraries(${XTENSOR_PYTHON_BENCHMARK_TARGET} PRIVATE xtensor-python) | ||
| 76 | 83 | endif() | |
| 77 | 84 | ||
| 78 | 85 | configure_file(benchmark_pyarray.py benchmark_pyarray.py COPYONLY) | |
@@ -81,5 +88,11 @@ configure_file(benchmark_pybind_array.py benchmark_pybind_array.py COPYONLY) | |||
| 81 | 88 | configure_file(benchmark_pyvectorize.py benchmark_pyvectorize.py COPYONLY) | |
| 82 | 89 | configure_file(benchmark_pybind_vectorize.py benchmark_pybind_vectorize.py COPYONLY) | |
| 83 | 90 | ||
| 84 | - add_custom_target(xbenchmark DEPENDS ${XTENSOR_PYTHON_BENCHMARK_TARGET}) | ||
| 91 | + add_custom_target(xbenchmark | ||
| 92 | + COMMAND "${PYTHON_EXECUTABLE}" "benchmark_pyarray.py" | ||
| 93 | + COMMAND "${PYTHON_EXECUTABLE}" "benchmark_pytensor.py" | ||
| 94 | + COMMAND "${PYTHON_EXECUTABLE}" "benchmark_pybind_array.py" | ||
| 95 | + COMMAND "${PYTHON_EXECUTABLE}" "benchmark_pyvectorize.py" | ||
| 96 | + COMMAND "${PYTHON_EXECUTABLE}" "benchmark_pybind_vectorize.py" | ||
| 97 | + DEPENDS ${XTENSOR_PYTHON_BENCHMARK_TARGET}) | ||
| 85 | 98 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,6 @@ PYBIND11_MODULE(benchmark_xtensor_python, m) | |||
| 17 | 17 | if(_import_array() < 0) | |
| 18 | 18 | { | |
| 19 | 19 | PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); | |
| 20 | - return nullptr; | ||
| 21 | 20 | } | |
| 22 | 21 | ||
| 23 | 22 | m.doc() = "Benchmark module for xtensor python bindings"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,7 @@ def build_extensions(self): | |||
| 107 | 107 | description='An example project using xtensor-python', | |
| 108 | 108 | long_description='', | |
| 109 | 109 | ext_modules=ext_modules, | |
| 110 | - install_requires=['pybind11==2.0.1'], | ||
| 110 | + install_requires=['pybind11>=2.2.1'], | ||
| 111 | 111 | cmdclass={'build_ext': BuildExt}, | |
| 112 | 112 | zip_safe=False, | |
| 113 | 113 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,45 @@ | |||
| 1 | + .. Copyright (c) 2016, Johan Mabille and Sylvain Corlay | ||
| 2 | + | ||
| 3 | + Distributed under the terms of the BSD 3-Clause License. | ||
| 4 | + | ||
| 5 | + The full license is in the file LICENSE, distributed with this software. | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + Build, test and benchmark | ||
| 9 | + ========================= | ||
| 10 | + | ||
| 11 | + ``xtensor-python`` build supports the following options: | ||
| 12 | + | ||
| 13 | + - ``BUILD_TESTS``: enables the ``xtest`` and ``xbenchmark`` targets (see below). | ||
| 14 | + - ``DOWNLOAD_GTEST``: downloads ``gtest`` and builds it locally instead of using a binary installation. | ||
| 15 | + - ``GTEST_SRC_DIR``: indicates where to find the ``gtest`` sources instead of downloading them. | ||
| 16 | + | ||
| 17 | + All these options are disabled by default. Enabling ``DOWNLOAD_GTEST`` or | ||
| 18 | + setting ``GTEST_SRC_DIR`` enables ``BUILD_TESTS``. | ||
| 19 | + | ||
| 20 | + If the ``BUILD_TESTS`` option is enabled, the following targets are available: | ||
| 21 | + | ||
| 22 | + - xtest: builds an run the test suite. | ||
| 23 | + - xbenchmark: builds and runs the benchmarks. | ||
| 24 | + | ||
| 25 | + For instance, building the test suite of ``xtensor-python`` and downloading ``gtest`` automatically: | ||
| 26 | + | ||
| 27 | + .. code:: | ||
| 28 | + | ||
| 29 | + mkdir build | ||
| 30 | + cd build | ||
| 31 | + cmake -DDOWNLOAD_GTEST=ON ../ | ||
| 32 | + make xtest | ||
| 33 | + | ||
| 34 | + To run the benchmark: | ||
| 35 | + | ||
| 36 | + .. code:: | ||
| 37 | + | ||
| 38 | + make xbenchmark | ||
| 39 | + | ||
| 40 | + To test the Python bindings: | ||
| 41 | + | ||
| 42 | + .. code:: | ||
| 43 | + | ||
| 44 | + cd .. | ||
| 45 | + pytest -s | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,6 +73,7 @@ This software is licensed under the BSD-3-Clause license. See the LICENSE file f | |||
| 73 | 73 | .. toctree:: | |
| 74 | 74 | :caption: DEVELOPER ZONE | |
| 75 | 75 | ||
| 76 | + dev_build_options | ||
| 76 | 77 | compilers | |
| 77 | 78 | releasing | |
| 78 | 79 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments