2013-06-02 20:54:46 +00:00
|
|
|
#!/usr/bin/env python
|
2014-01-08 09:21:02 +00:00
|
|
|
##############################################################################
|
2017-09-07 03:44:16 +00:00
|
|
|
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
2014-01-08 09:21:02 +00:00
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
2016-05-12 04:22:25 +00:00
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
2014-01-08 09:21:02 +00:00
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
2017-11-05 00:08:04 +00:00
|
|
|
# For details, see https://github.com/spack/spack
|
2017-06-25 05:22:55 +00:00
|
|
|
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
2014-01-08 09:21:02 +00:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
2016-05-12 04:22:25 +00:00
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
2014-01-08 09:21:02 +00:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
2016-05-12 04:22:25 +00:00
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
2014-01-08 09:21:02 +00:00
|
|
|
#
|
2016-05-12 04:22:25 +00:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2014-01-08 09:21:02 +00:00
|
|
|
##############################################################################
|
2017-03-07 22:25:48 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-05-08 20:18:29 +00:00
|
|
|
import os
|
2013-06-02 20:54:46 +00:00
|
|
|
import sys
|
2017-05-08 20:18:29 +00:00
|
|
|
|
2017-03-07 17:31:15 +00:00
|
|
|
if sys.version_info[:2] < (2, 6):
|
2014-12-19 19:09:37 +00:00
|
|
|
v_info = sys.version_info[:3]
|
2017-03-07 17:31:15 +00:00
|
|
|
sys.exit("Spack requires Python 2.6 or higher."
|
2016-08-09 20:23:53 +00:00
|
|
|
"This is Python %d.%d.%d." % v_info)
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
# Find spack's location and its prefix.
|
2017-05-08 20:18:29 +00:00
|
|
|
spack_file = os.path.realpath(os.path.expanduser(__file__))
|
|
|
|
spack_prefix = os.path.dirname(os.path.dirname(spack_file))
|
2013-02-14 01:50:44 +00:00
|
|
|
|
|
|
|
# Allow spack libs to be imported in our scripts
|
2017-05-08 20:18:29 +00:00
|
|
|
spack_lib_path = os.path.join(spack_prefix, "lib", "spack")
|
|
|
|
sys.path.insert(0, spack_lib_path)
|
2016-10-13 01:25:18 +00:00
|
|
|
|
|
|
|
# Add external libs
|
2017-05-08 20:18:29 +00:00
|
|
|
spack_external_libs = os.path.join(spack_lib_path, "external")
|
2018-01-16 06:00:39 +00:00
|
|
|
|
|
|
|
if sys.version_info[:2] == (2, 6):
|
|
|
|
sys.path.insert(0, os.path.join(spack_external_libs, 'py26'))
|
|
|
|
|
2017-05-08 20:18:29 +00:00
|
|
|
sys.path.insert(0, spack_external_libs)
|
2013-02-14 01:50:44 +00:00
|
|
|
|
2017-03-07 17:32:43 +00:00
|
|
|
# Handle vendoring of YAML specially, as it has two versions.
|
|
|
|
if sys.version_info[0] == 2:
|
2017-05-08 20:18:29 +00:00
|
|
|
spack_yaml_libs = os.path.join(spack_external_libs, "yaml/lib")
|
2017-03-07 17:32:43 +00:00
|
|
|
else:
|
2017-05-08 20:18:29 +00:00
|
|
|
spack_yaml_libs = os.path.join(spack_external_libs, "yaml/lib3")
|
|
|
|
sys.path.insert(0, spack_yaml_libs)
|
2017-03-07 17:32:43 +00:00
|
|
|
|
2015-11-24 01:39:59 +00:00
|
|
|
# Quick and dirty check to clean orphaned .pyc files left over from
|
|
|
|
# previous revisions. These files were present in earlier versions of
|
|
|
|
# Spack, were removed, but shadow system modules that Spack still
|
|
|
|
# imports. If we leave them, Spack will fail in mysterious ways.
|
|
|
|
# TODO: more elegant solution for orphaned pyc files.
|
2016-08-30 15:47:38 +00:00
|
|
|
orphaned_pyc_files = [
|
2017-05-08 20:18:29 +00:00
|
|
|
os.path.join(spack_external_libs, 'functools.pyc'),
|
|
|
|
os.path.join(spack_external_libs, 'ordereddict.pyc'),
|
|
|
|
os.path.join(spack_lib_path, 'spack', 'platforms', 'cray_xc.pyc'),
|
|
|
|
os.path.join(spack_lib_path, 'spack', 'cmd', 'package-list.pyc'),
|
|
|
|
os.path.join(spack_lib_path, 'spack', 'cmd', 'test-install.pyc'),
|
|
|
|
os.path.join(spack_lib_path, 'spack', 'cmd', 'url-parse.pyc'),
|
|
|
|
os.path.join(spack_lib_path, 'spack', 'test', 'yaml.pyc')
|
2016-08-30 15:47:38 +00:00
|
|
|
]
|
|
|
|
|
2015-11-24 01:39:59 +00:00
|
|
|
for pyc_file in orphaned_pyc_files:
|
|
|
|
if not os.path.exists(pyc_file):
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
os.remove(pyc_file)
|
|
|
|
except OSError as e:
|
2017-03-07 22:25:48 +00:00
|
|
|
print("WARNING: Spack may fail mysteriously. "
|
|
|
|
"Couldn't remove orphaned .pyc file: %s" % pyc_file)
|
2015-11-24 01:39:59 +00:00
|
|
|
|
2017-05-08 20:18:29 +00:00
|
|
|
# Once we've set up the system path, run the spack main method
|
|
|
|
import spack.main # noqa
|
|
|
|
sys.exit(spack.main.main())
|