From cadd07eb833ba85faa7c251d04afc578f786ee5f Mon Sep 17 00:00:00 2001
From: Neta Zmora <neta.zmora@intel.com>
Date: Wed, 13 Nov 2019 18:05:06 +0200
Subject: [PATCH] Distiller versioning - fix dual version strings

Two strings represented the library version: one in distiller.__init__.py
and one in setup.py.
This can lead to two difference version string values.
The fix: have distiller.__init__.py read the version string from the
package installation.
This assumes that we've installed distiller properly, but we've been
making this assumption for a long time in our code (e.g. how we do
imports of distiller from the `tests` directory).
---
 distiller/__init__.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/distiller/__init__.py b/distiller/__init__.py
index 220b8d0..458b824 100755
--- a/distiller/__init__.py
+++ b/distiller/__init__.py
@@ -27,7 +27,7 @@ from .thinning import *
 from .knowledge_distillation import KnowledgeDistillationPolicy, DistillationLossWeights
 from .summary_graph import SummaryGraph, onnx_name_2_pytorch_name
 from .early_exit import EarlyExitMgr
-
+import pkg_resources
 import logging
 logging.captureWarnings(True)
 
@@ -35,7 +35,10 @@ del dict_config
 del thinning
 
 # Distiller version
-__version__ = "0.4.0-pre"
+try:
+    __version__ = pkg_resources.require("distiller")[0].version
+except pkg_resources.DistributionNotFound:
+    __version__ = "Unknown"
 
 
 def model_find_param_name(model, param_to_find):
-- 
GitLab