From 5e37825ddb9af6b532a7fde326dc5335505b0d61 Mon Sep 17 00:00:00 2001 From: Sangyeon Date: Sun, 24 Nov 2019 17:11:17 +0900 Subject: [PATCH 1/3] Add mlpack version to __init__.py --- src/mlpack/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mlpack/CMakeLists.txt b/src/mlpack/CMakeLists.txt index fce358817f..8e81c05d07 100644 --- a/src/mlpack/CMakeLists.txt +++ b/src/mlpack/CMakeLists.txt @@ -140,6 +140,9 @@ if (BUILDING_PYTHON_BINDINGS) COMMENT "Configuring setup.py...") add_dependencies(python_configure python_copy) add_dependencies(python_configured python_configure) + + file(APPEND ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/mlpack/__init__.py + "__version__='${PACKAGE_VERSION}'\n") endif () # If we are building Markdown documentation, we have to run some setup after we From 114d7c0e491f254aee3a5f622e1e4cf9837f5f43 Mon Sep 17 00:00:00 2001 From: Sangyeon Date: Sun, 24 Nov 2019 17:17:39 +0900 Subject: [PATCH 2/3] Add a comment --- src/mlpack/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mlpack/CMakeLists.txt b/src/mlpack/CMakeLists.txt index 8e81c05d07..e9c2c89c37 100644 --- a/src/mlpack/CMakeLists.txt +++ b/src/mlpack/CMakeLists.txt @@ -141,6 +141,7 @@ if (BUILDING_PYTHON_BINDINGS) add_dependencies(python_configure python_copy) add_dependencies(python_configured python_configure) + # Append the package version to __init__.py after all the imports are loaded. file(APPEND ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/mlpack/__init__.py "__version__='${PACKAGE_VERSION}'\n") endif () From 5d57aa7a817d6539b7a142842ef4cf14fd813d9b Mon Sep 17 00:00:00 2001 From: Sangyeon Date: Sun, 24 Nov 2019 19:46:41 +0900 Subject: [PATCH 3/3] Update HISTORY.md --- HISTORY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index ed6be81d65..08f5a2945d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,6 +16,8 @@ * Fix Windows Python build configuration (#1885). + * Add `__version__` to `__init__.py` (#2092). + ### mlpack 3.2.1 ###### 2019-10-01 * Enforce CMake version check for ensmallen (#2032).