-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perform a check on the Python version on startup. Refs #1592
Now only Python versions with matching major/minor numbers will be able to import mantid.
- Loading branch information
1 parent
332e58f
commit 7f52556
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Code/Mantid/Framework/PythonInterface/mantid/pyversion.py.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Checks that the running version of Python is compatible with the version of | ||
Python that Mantid was built with. | ||
""" | ||
import sys | ||
|
||
# Define the target major.minor version (i.e. the one mantid was built against) | ||
TARGET_VERSION="@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@" | ||
|
||
_vers_info = sys.version_info | ||
_running_vers = "%d.%d" % (_vers_info[0],_vers_info[1]) | ||
if _running_vers != TARGET_VERSION: | ||
message = \ | ||
"""Python version mismatch, cannot continue. | ||
Mantid was built against version '%s' but you are running version '%s'. These versions | ||
must match. | ||
""" | ||
raise ImportError(message % (TARGET_VERSION, _running_vers)) | ||
|