notify and error out on more unsupported versions (#22389)
This is to help debug situations like #22383, where python3.4 is accidentally preferred over python2. It will also help on systems where there is no python2 available or some other issue.
This commit is contained in:
		
							
								
								
									
										23
									
								
								bin/spack
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								bin/spack
									
									
									
									
									
								
							| @@ -29,10 +29,15 @@ from __future__ import print_function | |||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
|  |  | ||||||
| if sys.version_info[:2] < (2, 6): | min_python3 = (3, 5) | ||||||
|  |  | ||||||
|  | if sys.version_info[:2] < (2, 6) or ( | ||||||
|  |     sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < min_python3 | ||||||
|  | ): | ||||||
|     v_info = sys.version_info[:3] |     v_info = sys.version_info[:3] | ||||||
|     sys.exit("Spack requires Python 2.6 or higher." |     msg = "Spack requires Python 2.6, 2.7 or %d.%d or higher " % min_python3 | ||||||
|              "This is Python %d.%d.%d." % v_info) |     msg += "You are running spack with Python %d.%d.%d." % v_info | ||||||
|  |     sys.exit(msg) | ||||||
|  |  | ||||||
| # Find spack's location and its prefix. | # Find spack's location and its prefix. | ||||||
| spack_file = os.path.realpath(os.path.expanduser(__file__)) | spack_file = os.path.realpath(os.path.expanduser(__file__)) | ||||||
| @@ -46,9 +51,9 @@ sys.path.insert(0, spack_lib_path) | |||||||
| spack_external_libs = os.path.join(spack_lib_path, "external") | spack_external_libs = os.path.join(spack_lib_path, "external") | ||||||
|  |  | ||||||
| if sys.version_info[:2] <= (2, 7): | if sys.version_info[:2] <= (2, 7): | ||||||
|     sys.path.insert(0, os.path.join(spack_external_libs, 'py2')) |     sys.path.insert(0, os.path.join(spack_external_libs, "py2")) | ||||||
| if sys.version_info[:2] == (2, 6): | if sys.version_info[:2] == (2, 6): | ||||||
|     sys.path.insert(0, os.path.join(spack_external_libs, 'py26')) |     sys.path.insert(0, os.path.join(spack_external_libs, "py26")) | ||||||
|  |  | ||||||
| sys.path.insert(0, spack_external_libs) | sys.path.insert(0, spack_external_libs) | ||||||
|  |  | ||||||
| @@ -58,11 +63,11 @@ sys.path.insert(0, spack_external_libs) | |||||||
| # Briefly: ruamel.yaml produces a .pth file when installed with pip that | # Briefly: ruamel.yaml produces a .pth file when installed with pip that | ||||||
| # makes the site installed package the preferred one, even though sys.path | # makes the site installed package the preferred one, even though sys.path | ||||||
| # is modified to point to another version of ruamel.yaml. | # is modified to point to another version of ruamel.yaml. | ||||||
| if 'ruamel.yaml' in sys.modules: | if "ruamel.yaml" in sys.modules: | ||||||
|     del sys.modules['ruamel.yaml'] |     del sys.modules["ruamel.yaml"] | ||||||
|  |  | ||||||
| if 'ruamel' in sys.modules: | if "ruamel" in sys.modules: | ||||||
|     del sys.modules['ruamel'] |     del sys.modules["ruamel"] | ||||||
|  |  | ||||||
| import spack.main  # noqa | import spack.main  # noqa | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tom Scogland
					Tom Scogland