From a6898bfebefb6e321e6bf842afbbf844ffc2012f Mon Sep 17 00:00:00 2001 From: Victor Popov Date: Tue, 15 Jan 2019 14:57:13 +0300 Subject: [PATCH] Add version to all PYBINDINGS modules. Make all modules have externally-specified (by build script) version. It must be externally specified since we can't know which tag the code was checked out from. --- CMakeLists.txt | 1 + generator/mwm_diff/pymwm_diff/CMakeLists.txt | 2 ++ generator/mwm_diff/pymwm_diff/bindings.cpp | 3 +++ kml/pykmlib/CMakeLists.txt | 2 ++ kml/pykmlib/bindings.cpp | 2 ++ local_ads/pylocal_ads/CMakeLists.txt | 2 ++ local_ads/pylocal_ads/bindings.cpp | 2 ++ pyhelpers/CMakeLists.txt | 5 +++++ pyhelpers/module_version.hpp.in | 1 + search/pysearch/CMakeLists.txt | 2 ++ search/pysearch/bindings.cpp | 3 +++ tracking/pytracking/CMakeLists.txt | 2 ++ tracking/pytracking/bindings.cpp | 3 +++ traffic/pytraffic/CMakeLists.txt | 2 ++ traffic/pytraffic/bindings.cpp | 2 ++ 15 files changed, 34 insertions(+) create mode 100644 pyhelpers/CMakeLists.txt create mode 100644 pyhelpers/module_version.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ecb6b979c..bbbf6072af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,7 @@ if (NOT Boost_FOUND) endif() if (PYBINDINGS) + add_subdirectory(pyhelpers) if (PYTHON_VERSION VERSION_GREATER 3.0) set(_Boost_PYTHON3_HEADERS "boost/python.hpp") if (NOT DEFINED BOOST_PYTHON_LIBNAME) diff --git a/generator/mwm_diff/pymwm_diff/CMakeLists.txt b/generator/mwm_diff/pymwm_diff/CMakeLists.txt index 990600e7303..582d1bb7e6d 100644 --- a/generator/mwm_diff/pymwm_diff/CMakeLists.txt +++ b/generator/mwm_diff/pymwm_diff/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) omim_link_libraries( diff --git a/generator/mwm_diff/pymwm_diff/bindings.cpp b/generator/mwm_diff/pymwm_diff/bindings.cpp index 0c6baacbbdb..aa5624449dc 100644 --- a/generator/mwm_diff/pymwm_diff/bindings.cpp +++ b/generator/mwm_diff/pymwm_diff/bindings.cpp @@ -8,6 +8,8 @@ #pragma clang diagnostic ignored "-Wunused-local-typedef" #endif +#include "pyhelpers/module_version.hpp" + #include #if defined(__clang__) @@ -20,6 +22,7 @@ using namespace std; BOOST_PYTHON_MODULE(pymwm_diff) { using namespace boost::python; + scope().attr("__version__") = PYBINDINGS_VERSION; def("make_diff", generator::mwm_diff::MakeDiff); def("apply_diff", generator::mwm_diff::ApplyDiff); diff --git a/kml/pykmlib/CMakeLists.txt b/kml/pykmlib/CMakeLists.txt index 2bd7a03a41e..d7418de919a 100644 --- a/kml/pykmlib/CMakeLists.txt +++ b/kml/pykmlib/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) omim_link_libraries( diff --git a/kml/pykmlib/bindings.cpp b/kml/pykmlib/bindings.cpp index a14cd9cf373..b948b487faf 100644 --- a/kml/pykmlib/bindings.cpp +++ b/kml/pykmlib/bindings.cpp @@ -29,6 +29,7 @@ #pragma clang diagnostic ignored "-Wunused-local-typedef" #endif +#include "pyhelpers/module_version.hpp" #include "pyhelpers/vector_uint8.hpp" #include "pyhelpers/vector_list_conversion.hpp" @@ -642,6 +643,7 @@ std::string IndexToClassificatorType(uint32_t index) BOOST_PYTHON_MODULE(pykmlib) { + scope().attr("__version__") = PYBINDINGS_VERSION; register_exception_translator(&TranslateRuntimeError); TimestampConverter(); LatLonConverter(); diff --git a/local_ads/pylocal_ads/CMakeLists.txt b/local_ads/pylocal_ads/CMakeLists.txt index 71fb9743f1d..53dc2b4a700 100644 --- a/local_ads/pylocal_ads/CMakeLists.txt +++ b/local_ads/pylocal_ads/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) omim_link_libraries( diff --git a/local_ads/pylocal_ads/bindings.cpp b/local_ads/pylocal_ads/bindings.cpp index d2cfaaccd40..887a01fe5b3 100644 --- a/local_ads/pylocal_ads/bindings.cpp +++ b/local_ads/pylocal_ads/bindings.cpp @@ -15,6 +15,7 @@ #pragma clang diagnostic ignored "-Wunused-local-typedef" #endif +#include "pyhelpers/module_version.hpp" #include "pyhelpers/vector_uint8.hpp" #include "pyhelpers/vector_list_conversion.hpp" @@ -47,6 +48,7 @@ boost::python::list PyDeserialize(std::vector const & blob) BOOST_PYTHON_MODULE(pylocal_ads) { using namespace boost::python; + scope().attr("__version__") = PYBINDINGS_VERSION; // Register the to-python converters. to_python_converter, vector_uint8t_to_str>(); diff --git a/pyhelpers/CMakeLists.txt b/pyhelpers/CMakeLists.txt new file mode 100644 index 00000000000..c6f92447f7c --- /dev/null +++ b/pyhelpers/CMakeLists.txt @@ -0,0 +1,5 @@ +if (NOT PYBINDINGS_VERSION) + message(FATAL_ERROR "You need to specify PYBINDINGS_VERSION to build PYBINDINGS") +endif() + +configure_file(module_version.hpp.in module_version.hpp) diff --git a/pyhelpers/module_version.hpp.in b/pyhelpers/module_version.hpp.in new file mode 100644 index 00000000000..fd5e5553bfa --- /dev/null +++ b/pyhelpers/module_version.hpp.in @@ -0,0 +1 @@ +#define PYBINDINGS_VERSION "@PYBINDINGS_VERSION@" diff --git a/search/pysearch/CMakeLists.txt b/search/pysearch/CMakeLists.txt index 8c66befb1a0..2464f6d865c 100644 --- a/search/pysearch/CMakeLists.txt +++ b/search/pysearch/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) omim_link_libraries( diff --git a/search/pysearch/bindings.cpp b/search/pysearch/bindings.cpp index d8fe78b85e2..3dc35118f82 100644 --- a/search/pysearch/bindings.cpp +++ b/search/pysearch/bindings.cpp @@ -20,6 +20,8 @@ #include "base/assert.hpp" +#include "pyhelpers/module_version.hpp" + #include #include @@ -266,6 +268,7 @@ struct SearchEngineProxy BOOST_PYTHON_MODULE(pysearch) { using namespace boost::python; + scope().attr("__version__") = PYBINDINGS_VERSION; def("init", &Init); diff --git a/tracking/pytracking/CMakeLists.txt b/tracking/pytracking/CMakeLists.txt index f0bcfe2b151..9e0f813f938 100644 --- a/tracking/pytracking/CMakeLists.txt +++ b/tracking/pytracking/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) omim_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES} tracking coding geometry base) diff --git a/tracking/pytracking/bindings.cpp b/tracking/pytracking/bindings.cpp index eb7a0992f73..6887f4f2682 100644 --- a/tracking/pytracking/bindings.cpp +++ b/tracking/pytracking/bindings.cpp @@ -2,6 +2,7 @@ #include "coding/traffic.hpp" +#include "pyhelpers/module_version.hpp" #include "pyhelpers/pair.hpp" #include "pyhelpers/vector_uint8.hpp" @@ -12,6 +13,8 @@ BOOST_PYTHON_MODULE(pytracking) { using namespace boost::python; + scope().attr("__version__") = PYBINDINGS_VERSION; + using tracking::Protocol; // Register the to-python converters. diff --git a/traffic/pytraffic/CMakeLists.txt b/traffic/pytraffic/CMakeLists.txt index 7c5fb9422e6..5bf96e768b2 100644 --- a/traffic/pytraffic/CMakeLists.txt +++ b/traffic/pytraffic/CMakeLists.txt @@ -5,6 +5,8 @@ set( bindings.cpp ) +include_directories(${CMAKE_BINARY_DIR}) + omim_add_library(${PROJECT_NAME} MODULE ${SRC}) if (PLATFORM_MAC) diff --git a/traffic/pytraffic/bindings.cpp b/traffic/pytraffic/bindings.cpp index d222412c6fc..bc5b55e2c61 100644 --- a/traffic/pytraffic/bindings.cpp +++ b/traffic/pytraffic/bindings.cpp @@ -15,6 +15,7 @@ #include "std/string.hpp" #include "std/vector.hpp" +#include "pyhelpers/module_version.hpp" #include "pyhelpers/vector_list_conversion.hpp" #include "pyhelpers/vector_uint8.hpp" @@ -162,6 +163,7 @@ void LoadClassificator(string const & classifPath) BOOST_PYTHON_MODULE(pytraffic) { using namespace boost::python; + scope().attr("__version__") = PYBINDINGS_VERSION; // Register the to-python converters. to_python_converter, vector_uint8t_to_str>();