Use cYAML if it is available in Python. (#2010)

This commit is contained in:
Todd Gamblin
2016-10-12 18:25:18 -07:00
committed by GitHub
parent b27f4e3aeb
commit d861a52ebe
3 changed files with 21 additions and 4 deletions

View File

@@ -40,6 +40,16 @@ SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE))
# Allow spack libs to be imported in our scripts
SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack")
sys.path.insert(0, SPACK_LIB_PATH)
# Try to use system YAML if it is available, as it might have libyaml
# support (for faster loading via C). Load it before anything in
# lib/spack/external so it will take precedence over Spack's PyYAML.
try:
import yaml
except ImportError:
pass # ignore and use slow yaml
# Add external libs
SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external")
sys.path.insert(0, SPACK_EXTERNAL_LIBS)