Salome HOME
CMake implementation pour split d install pour branchement a l IHM
[modules/adao.git] / test / test1001 / Versions.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2008-2019 EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22 "Test des versions de modules"
23
24 # ==============================================================================
25 #
26 # Versions minimales Calibre9/Jessie
27 # ----------------------------------
28 minimal_python_version     = "2.7.9"
29 minimal_numpy_version      = "1.8.2"
30 minimal_scipy_version      = "0.14.0"
31 minimal_matplotlib_version = "1.4.2"
32
33 def compare_versions(v1,v2):
34     "Comparaison v1 >= v2"
35     for s in ['+', 'rc1', 'rc2', 'rc3']:
36         v1 = v1.replace(s,'',1)
37         v2 = v2.replace(s,'',1)
38     v11,v12,v13 = list(map(float,v1.split('.')))
39     v21,v22,v23 = list(map(float,v2.split('.')))
40     lv1 = 1e6*v11 + 1e3*v12 + v13
41     lv2 = 1e6*v21 + 1e3*v22 + v23
42     return lv1 >= lv2
43
44 def minimalVersion():
45     "Description"
46     print("  Les versions minimales attendues sont :")
47     print("    - Python systeme....: %s"%minimal_python_version)
48     print("    - Numpy.............: %s"%minimal_numpy_version)
49     print("    - Scipy.............: %s"%minimal_scipy_version)
50     print("    - Matplotlib........: %s"%minimal_matplotlib_version)
51     print("")
52
53 import sys
54 def testSysteme():
55     "Test des versions de modules"
56     print("  Les versions disponibles sont :")
57     v=sys.version.split()
58     print("    - Python systeme....: %s"%v[0])
59     assert compare_versions(sys.version.split()[0], minimal_python_version)
60     #
61     try:
62         import numpy
63         print("    - Numpy.............: %s"%numpy.version.version)
64         assert compare_versions(numpy.version.version, minimal_numpy_version)
65     except ImportError:
66         return 1
67     #
68     try:
69         import scipy
70         print("    - Scipy.............: %s"%scipy.version.version)
71         assert compare_versions(scipy.version.version, minimal_scipy_version)
72     except ImportError:
73         return 1
74     #
75     try:
76         import matplotlib
77         mplversion = matplotlib.__version__
78         print("    - Matplotlib........: %s"%mplversion)
79         assert compare_versions(mplversion, minimal_matplotlib_version)
80         #
81         print("")
82         backends_OK = []
83         backends_KO = []
84         backend_now = matplotlib.get_backend()
85
86         for backend in ['bidon', 'pdf', 'pgf', 'Qt4Agg', 'GTK', 'GTKAgg', 'ps',
87                         'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg',
88                         'template', 'TkAgg', 'GTK3Cairo', 'GTK3Agg', 'svg',
89                         'WebAgg', 'CocoaAgg', 'emf', 'gdk', 'WX']:
90             try:
91                 matplotlib.use(backend)
92                 backends_OK.append(backend)
93             except ValueError:
94                 backends_KO.append(backend)
95         #
96         print("  Backends disponibles pour Matplotlib %s :"%mplversion)
97         print("    Defaut initial......: '%s'"%backend_now)
98         print("    Fonctionnant........:")
99         for b in backends_OK:
100             print("                          '%s'"%b)
101         print("    Non fonctionnant....:")
102         for b in backends_KO:
103             print("                          '%s'"%b)
104         print("    (Le backend 'bidon' n'est ici que pour verifier le test, il n'existe pas)")
105     except ImportError:
106         pass
107     print("")
108     print("  Les résultats obtenus sont corrects.")
109     print("")
110     #
111     return 0
112
113 # ==============================================================================
114 if __name__ == "__main__":
115     print('\nAUTODIAGNOSTIC\n')
116     minimalVersion()
117     sys.exit(testSysteme())
118