From 69daa33cc7bc64c8cabee0c59ac0f734bcd37898 Mon Sep 17 00:00:00 2001
From: "Olivier J.N. Bertrand" <olivier.bertrand@uni-bielefeld.de>
Date: Sat, 1 Dec 2018 15:07:09 +0100
Subject: [PATCH] Add config checker

---
 navipy/scripts/check_blender_versions.py     | 45 ++++++++++++++++++++
 navipy/scripts/check_blender_versions_pip.py | 17 --------
 2 files changed, 45 insertions(+), 17 deletions(-)
 create mode 100644 navipy/scripts/check_blender_versions.py
 delete mode 100644 navipy/scripts/check_blender_versions_pip.py

diff --git a/navipy/scripts/check_blender_versions.py b/navipy/scripts/check_blender_versions.py
new file mode 100644
index 0000000..b3e7e12
--- /dev/null
+++ b/navipy/scripts/check_blender_versions.py
@@ -0,0 +1,45 @@
+from platform import python_version
+import os
+
+
+packages = ['numpy',
+            'pandas',
+            'matplotlib',
+            'scipy',
+            'networkx',
+            'ipython',
+            'yaml',
+            'PIL',
+            'cv2',
+            'fastdtw']
+filereq = 'requirement.txt'
+# Look for packages require by blender and navipy
+# there versions should match
+requirements = []
+print('Look for packages')
+for pkg in packages:
+    try:
+        cmod = __import__(pkg)
+    except ImportError as e:
+            # Not use by blender so no incompatibilty issues
+        continue
+    line = pkg + '==' + cmod.__version__
+    print('\t', line)
+    requirements.append(line)
+# Write a requirement file to auto install the packages
+# prior to navipy with the correct versions
+with open(filereq, 'w') as cfile:
+    for line in requirements:
+        cfile.write(line + '\n')
+print('Requirement file written... Ok')
+
+# Display user informations
+pythonvec = python_version()
+pathreq = os.path.abspath(filereq)
+print('You can create an anaconda virtual environment as follow')
+print('\t conda update conda')
+print('\t conda create -n myblendnavipy python={} anaconda'.format(
+    pythonvec))
+print('\t activate myblendnavipy')
+print('\t conda install --yes --file {}'.format(pathreq))
+print('\t conda install navipy')
diff --git a/navipy/scripts/check_blender_versions_pip.py b/navipy/scripts/check_blender_versions_pip.py
deleted file mode 100644
index 105511a..0000000
--- a/navipy/scripts/check_blender_versions_pip.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-List all installed packages in a python installation
-by using pip.
-
-It can be used to install a virtual environment, so that it matches
-another installation (for example blender)
-"""
-import pip
-
-
-installed_packages = pip.get_installed_distributions()
-installed_packages = sorted(["%s==%s" % (i.key, i.version)
-                             for i in installed_packages])
-with open('requirement.txt', 'w') as cfile:
-    for line in installed_packages:
-        print(line)
-        cfile.write(line+'\n')
-- 
GitLab