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
cd960caf
Commit
cd960caf
authored
8 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Clean up Exceptions in `spec.py`
parent
88af9f78
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/spack/spack/spec.py
+3
-60
3 additions, 60 deletions
lib/spack/spack/spec.py
lib/spack/spack/test/spec_dag.py
+3
-3
3 additions, 3 deletions
lib/spack/spack/test/spec_dag.py
with
6 additions
and
63 deletions
lib/spack/spack/spec.py
+
3
−
60
View file @
cd960caf
...
@@ -1569,7 +1569,7 @@ def normalize(self, force=False):
...
@@ -1569,7 +1569,7 @@ def normalize(self, force=False):
# actually deps of this package. Raise an error.
# actually deps of this package. Raise an error.
extra
=
set
(
spec_deps
.
keys
()).
difference
(
visited
)
extra
=
set
(
spec_deps
.
keys
()).
difference
(
visited
)
if
extra
:
if
extra
:
raise
InvalidDependencyE
xception
(
raise
InvalidDependencyE
rror
(
self
.
name
+
"
does not depend on
"
+
comma_or
(
extra
))
self
.
name
+
"
does not depend on
"
+
comma_or
(
extra
))
# Mark the spec as normal once done.
# Mark the spec as normal once done.
...
@@ -2667,17 +2667,11 @@ def parse_anonymous_spec(spec_like, pkg_name):
...
@@ -2667,17 +2667,11 @@ def parse_anonymous_spec(spec_like, pkg_name):
class
SpecError
(
spack
.
error
.
SpackError
):
class
SpecError
(
spack
.
error
.
SpackError
):
"""
Superclass for all errors that occur while constructing specs.
"""
"""
Superclass for all errors that occur while constructing specs.
"""
def
__init__
(
self
,
message
):
super
(
SpecError
,
self
).
__init__
(
message
)
class
SpecParseError
(
SpecError
):
class
SpecParseError
(
SpecError
):
"""
Wrapper for ParseError for when we
'
re parsing specs.
"""
"""
Wrapper for ParseError for when we
'
re parsing specs.
"""
def
__init__
(
self
,
parse_error
):
def
__init__
(
self
,
parse_error
):
super
(
SpecParseError
,
self
).
__init__
(
parse_error
.
message
)
super
(
SpecParseError
,
self
).
__init__
(
parse_error
.
message
)
self
.
string
=
parse_error
.
string
self
.
string
=
parse_error
.
string
...
@@ -2685,79 +2679,49 @@ def __init__(self, parse_error):
...
@@ -2685,79 +2679,49 @@ def __init__(self, parse_error):
class
DuplicateDependencyError
(
SpecError
):
class
DuplicateDependencyError
(
SpecError
):
"""
Raised when the same dependency occurs in a spec twice.
"""
"""
Raised when the same dependency occurs in a spec twice.
"""
def
__init__
(
self
,
message
):
super
(
DuplicateDependencyError
,
self
).
__init__
(
message
)
class
DuplicateVariantError
(
SpecError
):
class
DuplicateVariantError
(
SpecError
):
"""
Raised when the same variant occurs in a spec twice.
"""
"""
Raised when the same variant occurs in a spec twice.
"""
def
__init__
(
self
,
message
):
super
(
DuplicateVariantError
,
self
).
__init__
(
message
)
class
DuplicateCompilerSpecError
(
SpecError
):
class
DuplicateCompilerSpecError
(
SpecError
):
"""
Raised when the same compiler occurs in a spec twice.
"""
"""
Raised when the same compiler occurs in a spec twice.
"""
def
__init__
(
self
,
message
):
super
(
DuplicateCompilerSpecError
,
self
).
__init__
(
message
)
class
UnsupportedCompilerError
(
SpecError
):
class
UnsupportedCompilerError
(
SpecError
):
"""
Raised when the user asks for a compiler spack doesn
'
t know about.
"""
"""
Raised when the user asks for a compiler spack doesn
'
t know about.
"""
def
__init__
(
self
,
compiler_name
):
def
__init__
(
self
,
compiler_name
):
super
(
UnsupportedCompilerError
,
self
).
__init__
(
super
(
UnsupportedCompilerError
,
self
).
__init__
(
"
The
'
%s
'
compiler is not yet supported.
"
%
compiler_name
)
"
The
'
%s
'
compiler is not yet supported.
"
%
compiler_name
)
class
UnknownVariantError
(
SpecError
):
class
UnknownVariantError
(
SpecError
):
"""
Raised when the same variant occurs in a spec twice.
"""
"""
Raised when the same variant occurs in a spec twice.
"""
def
__init__
(
self
,
pkg
,
variant
):
def
__init__
(
self
,
pkg
,
variant
):
super
(
UnknownVariantError
,
self
).
__init__
(
super
(
UnknownVariantError
,
self
).
__init__
(
"
Package %s has no variant %s!
"
%
(
pkg
,
variant
))
"
Package %s has no variant %s!
"
%
(
pkg
,
variant
))
class
DuplicateArchitectureError
(
SpecError
):
class
DuplicateArchitectureError
(
SpecError
):
"""
Raised when the same architecture occurs in a spec twice.
"""
"""
Raised when the same architecture occurs in a spec twice.
"""
def
__init__
(
self
,
message
):
super
(
DuplicateArchitectureError
,
self
).
__init__
(
message
)
class
InconsistentSpecError
(
SpecError
):
class
InconsistentSpecError
(
SpecError
):
"""
Raised when two nodes in the same spec DAG have inconsistent
"""
Raised when two nodes in the same spec DAG have inconsistent
constraints.
"""
constraints.
"""
def
__init__
(
self
,
message
):
super
(
InconsistentSpecError
,
self
).
__init__
(
message
)
class
InvalidDependencyException
(
SpecError
):
class
InvalidDependencyError
(
SpecError
):
"""
Raised when a dependency in a spec is not actually a dependency
"""
Raised when a dependency in a spec is not actually a dependency
of the package.
"""
of the package.
"""
def
__init__
(
self
,
message
):
super
(
InvalidDependencyException
,
self
).
__init__
(
message
)
class
NoProviderError
(
SpecError
):
class
NoProviderError
(
SpecError
):
"""
Raised when there is no package that provides a particular
"""
Raised when there is no package that provides a particular
virtual dependency.
virtual dependency.
"""
"""
def
__init__
(
self
,
vpkg
):
def
__init__
(
self
,
vpkg
):
super
(
NoProviderError
,
self
).
__init__
(
super
(
NoProviderError
,
self
).
__init__
(
"
No providers found for virtual package:
'
%s
'"
%
vpkg
)
"
No providers found for virtual package:
'
%s
'"
%
vpkg
)
...
@@ -2765,11 +2729,9 @@ def __init__(self, vpkg):
...
@@ -2765,11 +2729,9 @@ def __init__(self, vpkg):
class
MultipleProviderError
(
SpecError
):
class
MultipleProviderError
(
SpecError
):
"""
Raised when there is no package that provides a particular
"""
Raised when there is no package that provides a particular
virtual dependency.
virtual dependency.
"""
"""
def
__init__
(
self
,
vpkg
,
providers
):
def
__init__
(
self
,
vpkg
,
providers
):
"""
Takes the name of the vpkg
"""
"""
Takes the name of the vpkg
"""
super
(
MultipleProviderError
,
self
).
__init__
(
super
(
MultipleProviderError
,
self
).
__init__
(
...
@@ -2780,10 +2742,8 @@ def __init__(self, vpkg, providers):
...
@@ -2780,10 +2742,8 @@ def __init__(self, vpkg, providers):
class
UnsatisfiableSpecError
(
SpecError
):
class
UnsatisfiableSpecError
(
SpecError
):
"""
Raised when a spec conflicts with package constraints.
"""
Raised when a spec conflicts with package constraints.
Provide the requirement that was violated when raising.
"""
Provide the requirement that was violated when raising.
"""
def
__init__
(
self
,
provided
,
required
,
constraint_type
):
def
__init__
(
self
,
provided
,
required
,
constraint_type
):
super
(
UnsatisfiableSpecError
,
self
).
__init__
(
super
(
UnsatisfiableSpecError
,
self
).
__init__
(
"
%s does not satisfy %s
"
%
(
provided
,
required
))
"
%s does not satisfy %s
"
%
(
provided
,
required
))
...
@@ -2793,89 +2753,72 @@ def __init__(self, provided, required, constraint_type):
...
@@ -2793,89 +2753,72 @@ def __init__(self, provided, required, constraint_type):
class
UnsatisfiableSpecNameError
(
UnsatisfiableSpecError
):
class
UnsatisfiableSpecNameError
(
UnsatisfiableSpecError
):
"""
Raised when two specs aren
'
t even for the same package.
"""
"""
Raised when two specs aren
'
t even for the same package.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableSpecNameError
,
self
).
__init__
(
super
(
UnsatisfiableSpecNameError
,
self
).
__init__
(
provided
,
required
,
"
name
"
)
provided
,
required
,
"
name
"
)
class
UnsatisfiableVersionSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableVersionSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a spec version conflicts with package constraints.
"""
"""
Raised when a spec version conflicts with package constraints.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableVersionSpecError
,
self
).
__init__
(
super
(
UnsatisfiableVersionSpecError
,
self
).
__init__
(
provided
,
required
,
"
version
"
)
provided
,
required
,
"
version
"
)
class
UnsatisfiableCompilerSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableCompilerSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a spec comiler conflicts with package constraints.
"""
"""
Raised when a spec comiler conflicts with package constraints.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableCompilerSpecError
,
self
).
__init__
(
super
(
UnsatisfiableCompilerSpecError
,
self
).
__init__
(
provided
,
required
,
"
compiler
"
)
provided
,
required
,
"
compiler
"
)
class
UnsatisfiableVariantSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableVariantSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a spec variant conflicts with package constraints.
"""
"""
Raised when a spec variant conflicts with package constraints.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableVariantSpecError
,
self
).
__init__
(
super
(
UnsatisfiableVariantSpecError
,
self
).
__init__
(
provided
,
required
,
"
variant
"
)
provided
,
required
,
"
variant
"
)
class
UnsatisfiableCompilerFlagSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableCompilerFlagSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a spec variant conflicts with package constraints.
"""
"""
Raised when a spec variant conflicts with package constraints.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableCompilerFlagSpecError
,
self
).
__init__
(
super
(
UnsatisfiableCompilerFlagSpecError
,
self
).
__init__
(
provided
,
required
,
"
compiler_flags
"
)
provided
,
required
,
"
compiler_flags
"
)
class
UnsatisfiableArchitectureSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableArchitectureSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a spec architecture conflicts with package constraints.
"""
"""
Raised when a spec architecture conflicts with package constraints.
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableArchitectureSpecError
,
self
).
__init__
(
super
(
UnsatisfiableArchitectureSpecError
,
self
).
__init__
(
provided
,
required
,
"
architecture
"
)
provided
,
required
,
"
architecture
"
)
class
UnsatisfiableProviderSpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableProviderSpecError
(
UnsatisfiableSpecError
):
"""
Raised when a provider is supplied but constraints don
'
t match
"""
Raised when a provider is supplied but constraints don
'
t match
a vpkg requirement
"""
a vpkg requirement
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableProviderSpecError
,
self
).
__init__
(
super
(
UnsatisfiableProviderSpecError
,
self
).
__init__
(
provided
,
required
,
"
provider
"
)
provided
,
required
,
"
provider
"
)
# TODO: get rid of this and be more specific about particular incompatible
# TODO: get rid of this and be more specific about particular incompatible
# dep constraints
# dep constraints
class
UnsatisfiableDependencySpecError
(
UnsatisfiableSpecError
):
class
UnsatisfiableDependencySpecError
(
UnsatisfiableSpecError
):
"""
Raised when some dependency of constrained specs are incompatible
"""
"""
Raised when some dependency of constrained specs are incompatible
"""
def
__init__
(
self
,
provided
,
required
):
def
__init__
(
self
,
provided
,
required
):
super
(
UnsatisfiableDependencySpecError
,
self
).
__init__
(
super
(
UnsatisfiableDependencySpecError
,
self
).
__init__
(
provided
,
required
,
"
dependency
"
)
provided
,
required
,
"
dependency
"
)
class
SpackYAMLError
(
spack
.
error
.
SpackError
):
class
SpackYAMLError
(
spack
.
error
.
SpackError
):
def
__init__
(
self
,
msg
,
yaml_error
):
def
__init__
(
self
,
msg
,
yaml_error
):
super
(
SpackYAMLError
,
self
).
__init__
(
msg
,
str
(
yaml_error
))
super
(
SpackYAMLError
,
self
).
__init__
(
msg
,
str
(
yaml_error
))
class
AmbiguousHashError
(
SpecError
):
class
AmbiguousHashError
(
SpecError
):
def
__init__
(
self
,
msg
,
*
specs
):
def
__init__
(
self
,
msg
,
*
specs
):
super
(
AmbiguousHashError
,
self
).
__init__
(
msg
)
super
(
AmbiguousHashError
,
self
).
__init__
(
msg
)
for
spec
in
specs
:
for
spec
in
specs
:
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/test/spec_dag.py
+
3
−
3
View file @
cd960caf
...
@@ -241,15 +241,15 @@ def test_unsatisfiable_architecture(self):
...
@@ -241,15 +241,15 @@ def test_unsatisfiable_architecture(self):
def
test_invalid_dep
(
self
):
def
test_invalid_dep
(
self
):
spec
=
Spec
(
'
libelf ^mpich
'
)
spec
=
Spec
(
'
libelf ^mpich
'
)
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
xception
,
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
rror
,
spec
.
normalize
)
spec
.
normalize
)
spec
=
Spec
(
'
libelf ^libdwarf
'
)
spec
=
Spec
(
'
libelf ^libdwarf
'
)
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
xception
,
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
rror
,
spec
.
normalize
)
spec
.
normalize
)
spec
=
Spec
(
'
mpich ^dyninst ^libelf
'
)
spec
=
Spec
(
'
mpich ^dyninst ^libelf
'
)
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
xception
,
self
.
assertRaises
(
spack
.
spec
.
InvalidDependencyE
rror
,
spec
.
normalize
)
spec
.
normalize
)
def
test_equal
(
self
):
def
test_equal
(
self
):
...
...
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