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
67db8ddc
Commit
67db8ddc
authored
10 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Factor ignore logic into a predicate builder.
parent
06d6b0b2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/spack/llnl/util/lang.py
+31
-0
31 additions, 0 deletions
lib/spack/llnl/util/lang.py
var/spack/packages/python/package.py
+11
-14
11 additions, 14 deletions
var/spack/packages/python/package.py
with
42 additions
and
14 deletions
lib/spack/llnl/util/lang.py
+
31
−
0
View file @
67db8ddc
...
...
@@ -291,6 +291,37 @@ def foo(self, **kwargs):
%
(
next
(
kwargs
.
iterkeys
()),
fun
.
__name__
))
def
match_predicate
(
*
args
):
"""
Utility function for making string matching predicates.
Each arg can be a:
- regex
- list or tuple of regexes
- predicate that takes a string.
This returns a predicate that is true if:
- any arg regex matches
- any regex in a list or tuple of regexes matches.
- any predicate in args matches.
"""
def
match
(
string
):
for
arg
in
args
:
if
isinstance
(
arg
,
basestring
):
if
re
.
search
(
arg
,
string
):
return
True
elif
isinstance
(
arg
,
list
)
or
isinstance
(
arg
,
tuple
):
if
any
(
re
.
search
(
i
,
string
)
for
i
in
arg
):
return
True
elif
callable
(
arg
):
if
arg
(
string
):
return
True
else
:
raise
ValueError
(
"
args to match_predicate must be regex,
"
"
list of regexes, or callable.
"
)
return
False
return
match
class
RequiredAttributeError
(
ValueError
):
def
__init__
(
self
,
message
):
super
(
RequiredAttributeError
,
self
).
__init__
(
message
)
This diff is collapsed.
Click to expand it.
var/spack/packages/python/package.py
+
11
−
14
View file @
67db8ddc
import
os
import
re
from
contextlib
import
closing
from
llnl.util.lang
import
match_predicate
from
spack
import
*
import
spack
...
...
@@ -85,23 +86,19 @@ def setup_dependent_environment(self, module, spec, ext_spec):
def
python_ignore
(
self
,
ext_pkg
,
args
):
"""
Add some ignore files to activate/deactivate args.
"""
orig_
ignore
=
args
.
get
(
'
ignore
'
,
lambda
f
:
False
)
ignore
_arg
=
args
.
get
(
'
ignore
'
,
lambda
f
:
False
)
def
ignore
(
filename
):
# Always ignore easy-install.pth, as it needs to be merged.
patterns
=
[
r
'
easy-install\.pth$
'
]
# Always ignore easy-install.pth, as it needs to be merged.
patterns
=
[
r
'
easy-install\.pth$
'
]
# Ignore pieces of setuptools installed by other packages.
if
ext_pkg
.
name
!=
'
py-setuptools
'
:
patterns
.
append
(
r
'
/site\.pyc?$
'
)
patterns
.
append
(
r
'
setuptools\.pth
'
)
patterns
.
append
(
r
'
bin/easy_install[^/]*$
'
)
patterns
.
append
(
r
'
setuptools.*egg$
'
)
# Ignore pieces of setuptools installed by other packages.
if
ext_pkg
.
name
!=
'
py-setuptools
'
:
patterns
.
append
(
r
'
/site\.pyc?$
'
)
patterns
.
append
(
r
'
setuptools\.pth
'
)
patterns
.
append
(
r
'
bin/easy_install[^/]*$
'
)
patterns
.
append
(
r
'
setuptools.*egg$
'
)
return
(
any
(
re
.
search
(
p
,
filename
)
for
p
in
patterns
)
or
orig_ignore
(
filename
))
return
ignore
return
match_predicate
(
ignore_arg
,
patterns
)
def
write_easy_install_pth
(
self
,
exts
):
...
...
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