diff --git a/search/search_engine_pylib/README.txt b/search/search_engine_pylib/README.txt new file mode 100644 index 0000000000..afd8f68a53 --- /dev/null +++ b/search/search_engine_pylib/README.txt @@ -0,0 +1,37 @@ +This document describes how to use this module. + +1. How to build? + + To build the module you need Python2.7 and Boost Python. Also, you + need Qt5.5 (or higher), but you need it in any case, if you're + planning to build the project. On MacOS, Python2.7 should be + installed by default, to get Boost via Brew just type in the shell: + + brew update + brew install boost --with-python + brew install boost-python + + On Debian, type in the shell: + + sudo apt-get install libboost-* + + Note that on MacOS Boost is built by default with libc++, on Debian + Boost is built by default with libstdc++. Therefore, you can use + only macx-clang and linux-clang specs correspondingly. It's wrong + to use linux-clang-libc++ because it's generally a bad idea to have + two implementations of the C++ standard library in the same + application. + + Then, invoke qmake from the shell, for example: + + qmake CONFIG+=search_engine_pylib path-to-omim.pro + make -k -j8 all + +2. How to use? + + As search_engine_pylib is a custom Python module, all that you need + is to customize PYTHONPATH environment variable before running your + scripts. For example: + + PYTHONPATH=path-to-the-directory-with-search_engine_pylib.so \ + ./search/search_engine_pylib/run_search_engine.py diff --git a/search/search_engine_pylib/api.cpp b/search/search_engine_pylib/api.cpp index 6eef117cdc..f899c3d831 100644 --- a/search/search_engine_pylib/api.cpp +++ b/search/search_engine_pylib/api.cpp @@ -78,7 +78,7 @@ struct LatLon string ToString() const { ostringstream os; - os << "lat:" << m_lat << ", lon:" << m_lon; + os << "lat: " << m_lat << ", lon: " << m_lon; return os.str(); } @@ -168,7 +168,7 @@ struct SearchEngineProxy { SearchEngineProxy() { - CHECK(g_storage.get() != nullptr, ("init() is not called.")); + CHECK(g_storage.get() != nullptr, ("init() was not called.")); auto & platform = GetPlatform(); auto infoGetter = storage::CountryInfoReader::CreateCountryInfoReader(platform); infoGetter->InitAffiliationsInfo(&g_storage->GetAffiliations()); @@ -208,6 +208,7 @@ struct SearchEngineProxy results.append(Result(result)); return results; } + shared_ptr m_engine; }; } // namespace diff --git a/search/run_search_engine.py b/search/search_engine_pylib/run_search_engine.py similarity index 86% rename from search/run_search_engine.py rename to search/search_engine_pylib/run_search_engine.py index a8fe4de3ee..73f18506bd 100755 --- a/search/run_search_engine.py +++ b/search/search_engine_pylib/run_search_engine.py @@ -8,8 +8,8 @@ import search_engine_pylib as search DIR = os.path.dirname(__file__) -RESOURCE_PATH = os.path.realpath(os.path.join(DIR, '..', 'data')) -MWM_PATH = os.path.realpath(os.path.join(DIR, '..', 'data')) +RESOURCE_PATH = os.path.realpath(os.path.join(DIR, '..', '..', 'data')) +MWM_PATH = os.path.realpath(os.path.join(DIR, '..', '..', 'data')) parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-r', metavar='RESOURCE_PATH', default=RESOURCE_PATH, help='Path to resources directory.') diff --git a/search/search_engine_pylib/search_engine_pylib.pro b/search/search_engine_pylib/search_engine_pylib.pro index 469ca97d3e..4e64bf1de1 100644 --- a/search/search_engine_pylib/search_engine_pylib.pro +++ b/search/search_engine_pylib/search_engine_pylib.pro @@ -18,11 +18,32 @@ INCLUDEPATH -= $$ROOT_DIR/3party/boost # We do not support search_engine_pylib for other combinations of # OS and c++ standard library. macx-clang { - INCLUDEPATH += /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 - LIBS += -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -lpython2.7 + QMAKE_LFLAGS_PLUGIN += -bundle + + LIBRARY_PYTHON=/Library/Frameworks/Python.framework/Versions/2.7 + SYSTEM_LIBRARY_PYTHON=/System/Library/Frameworks/Python.framework/Versions/2.7 + + exists($$LIBRARY_PYTHON) { + INCLUDEPATH += $$LIBRARY_PYTHON/include/python2.7 + LIBS += -L$$LIBRARY_PYTHON/lib -lpython2.7 + } else:exists($$SYSTEM_LIBRARY_PYTHON) { + INCLUDEPATH += $$SYSTEM_LIBRARY_PYTHON/include/python2.7 + LIBS += -L$$SYSTEM_LIBRARY_PYTHON/lib -lpython2.7 + } else { + error("Can't find Python2.7") + } + + LIBS *= "-framework IOKit" + LIBS *= "-framework SystemConfiguration" + + LIBS *= -L/usr/local/opt/qt5/lib + LIBS *= "-framework QtCore" + LIBS *= "-framework QtNetwork" INCLUDEPATH += /usr/local/include LIBS += -L/usr/local/lib -lboost_python + + INCLUDEPATH += /usr/local/opt/qt5/include } else:linux-clang { INCLUDEPATH += /usr/include LIBS += -L/usr/lib/x86_64-linux-gnu/ -lboost_python