Skip to content

Commit

Permalink
Add version to all PYBINDINGS modules.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vicpopov authored and Sergey Yershov committed Jan 15, 2019
1 parent 3b0ffde commit a6898bf
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions generator/mwm_diff/pymwm_diff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(
bindings.cpp
)

include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

omim_link_libraries(
Expand Down
3 changes: 3 additions & 0 deletions generator/mwm_diff/pymwm_diff/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif

#include "pyhelpers/module_version.hpp"

#include <boost/python.hpp>

#if defined(__clang__)
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions kml/pykmlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(
bindings.cpp
)

include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

omim_link_libraries(
Expand Down
2 changes: 2 additions & 0 deletions kml/pykmlib/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -642,6 +643,7 @@ std::string IndexToClassificatorType(uint32_t index)

BOOST_PYTHON_MODULE(pykmlib)
{
scope().attr("__version__") = PYBINDINGS_VERSION;
register_exception_translator<std::runtime_error>(&TranslateRuntimeError);
TimestampConverter();
LatLonConverter();
Expand Down
2 changes: 2 additions & 0 deletions local_ads/pylocal_ads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(
bindings.cpp
)

include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

omim_link_libraries(
Expand Down
2 changes: 2 additions & 0 deletions local_ads/pylocal_ads/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -47,6 +48,7 @@ boost::python::list PyDeserialize(std::vector<uint8_t> const & blob)
BOOST_PYTHON_MODULE(pylocal_ads)
{
using namespace boost::python;
scope().attr("__version__") = PYBINDINGS_VERSION;

// Register the to-python converters.
to_python_converter<std::vector<uint8_t>, vector_uint8t_to_str>();
Expand Down
5 changes: 5 additions & 0 deletions pyhelpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions pyhelpers/module_version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define PYBINDINGS_VERSION "@PYBINDINGS_VERSION@"
2 changes: 2 additions & 0 deletions search/pysearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(
bindings.cpp
)

include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

omim_link_libraries(
Expand Down
3 changes: 3 additions & 0 deletions search/pysearch/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "base/assert.hpp"

#include "pyhelpers/module_version.hpp"

#include <boost/python.hpp>

#include <iomanip>
Expand Down Expand Up @@ -266,6 +268,7 @@ struct SearchEngineProxy
BOOST_PYTHON_MODULE(pysearch)
{
using namespace boost::python;
scope().attr("__version__") = PYBINDINGS_VERSION;

def("init", &Init);

Expand Down
2 changes: 2 additions & 0 deletions tracking/pytracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tracking/pytracking/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "coding/traffic.hpp"

#include "pyhelpers/module_version.hpp"
#include "pyhelpers/pair.hpp"
#include "pyhelpers/vector_uint8.hpp"

Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions traffic/pytraffic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(
bindings.cpp
)

include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

if (PLATFORM_MAC)
Expand Down
2 changes: 2 additions & 0 deletions traffic/pytraffic/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<uint8_t>, vector_uint8t_to_str>();
Expand Down

0 comments on commit a6898bf

Please sign in to comment.