Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
d861a52e
Commit
d861a52e
authored
8 years ago
by
Todd Gamblin
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use cYAML if it is available in Python. (#2010)
parent
b27f4e3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/spack
+10
-0
10 additions, 0 deletions
bin/spack
lib/spack/spack/spec.py
+5
-2
5 additions, 2 deletions
lib/spack/spack/spec.py
lib/spack/spack/util/spack_yaml.py
+6
-2
6 additions, 2 deletions
lib/spack/spack/util/spack_yaml.py
with
21 additions
and
4 deletions
bin/spack
+
10
−
0
View file @
d861a52e
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/spec.py
+
5
−
2
View file @
d861a52e
...
...
@@ -98,7 +98,7 @@
import
base64
import
hashlib
import
imp
import
sy
s
import
ctype
s
from
StringIO
import
StringIO
from
operator
import
attrgetter
...
...
@@ -203,6 +203,9 @@
legal_deps
=
tuple
(
special_types
)
+
alldeps
"""
Max integer helps avoid passing too large a value to cyaml.
"""
maxint
=
2
**
(
ctypes
.
sizeof
(
ctypes
.
c_int
)
*
8
-
1
)
-
1
def
validate_deptype
(
deptype
):
if
isinstance
(
deptype
,
str
):
...
...
@@ -969,7 +972,7 @@ def dag_hash(self, length=None):
return
self
.
_hash
[:
length
]
else
:
yaml_text
=
syaml
.
dump
(
self
.
to_node_dict
(),
default_flow_style
=
True
,
width
=
sys
.
maxint
)
self
.
to_node_dict
(),
default_flow_style
=
True
,
width
=
maxint
)
sha
=
hashlib
.
sha1
(
yaml_text
)
b32_hash
=
base64
.
b32encode
(
sha
.
digest
()).
lower
()[:
length
]
if
self
.
concrete
:
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/util/spack_yaml.py
+
6
−
2
View file @
d861a52e
...
...
@@ -32,6 +32,10 @@
"""
import
yaml
try
:
from
yaml
import
CLoader
as
Loader
,
CDumper
as
Dumper
except
ImportError
as
e
:
from
yaml
import
Loader
,
Dumper
from
yaml.nodes
import
*
from
yaml.constructor
import
ConstructorError
from
ordereddict_backport
import
OrderedDict
...
...
@@ -64,7 +68,7 @@ def mark(obj, node):
obj
.
_end_mark
=
node
.
end_mark
class
OrderedLineLoader
(
yaml
.
Loader
):
class
OrderedLineLoader
(
Loader
):
"""
YAML loader that preserves order and line numbers.
Mappings read in by this loader behave like an ordered dict.
...
...
@@ -156,7 +160,7 @@ def construct_mapping(self, node, deep=False):
u
'
tag:yaml.org,2002:str
'
,
OrderedLineLoader
.
construct_yaml_str
)
class
OrderedLineDumper
(
yaml
.
Dumper
):
class
OrderedLineDumper
(
Dumper
):
"""
Dumper that preserves ordering and formats ``syaml_*`` objects.
This dumper preserves insertion ordering ``syaml_dict`` objects
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment