Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pub
frama-c
Commits
1882e0de
Commit
1882e0de
authored
3 years ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[analysis-scripts] add support for pyinstaller bundle in source_filter
parent
5d8501d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
share/analysis-scripts/source_filter.py
+27
-12
27 additions, 12 deletions
share/analysis-scripts/source_filter.py
with
27 additions
and
12 deletions
share/analysis-scripts/source_filter.py
+
27
−
12
View file @
1882e0de
...
@@ -46,24 +46,39 @@ import sys
...
@@ -46,24 +46,39 @@ import sys
# warnings about missing commands are disabled during testing
# warnings about missing commands are disabled during testing
emit_warns
=
os
.
getenv
(
"
PTESTS_TESTING
"
)
is
None
emit_warns
=
os
.
getenv
(
"
PTESTS_TESTING
"
)
is
None
# Returns a Path to the command binary, or None if it is not found
# Cache for get_command
# Emits a warning the first time it looks for a command
cached_commands
=
{}
warned
=
{}
def
resource_path
(
relative_path
):
"""
Get absolute path to resource; only used by the pyinstaller standalone distribution
"""
base_path
=
getattr
(
sys
,
"
_MEIPASS
"
,
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
return
os
.
path
.
join
(
base_path
,
relative_path
)
def
get_command
(
command
,
env_var_name
):
def
get_command
(
command
,
env_var_name
):
"""
Returns a Path to the command; priority goes to the environment variable,
then in the PATH, then in the resource directory (for a pyinstaller binary).
"""
if
command
in
cached_commands
:
return
cached_commands
[
command
]
p
=
os
.
getenv
(
env_var_name
)
p
=
os
.
getenv
(
env_var_name
)
if
not
p
:
if
p
:
p
=
Path
(
p
)
else
:
p
=
shutil
.
which
(
command
)
p
=
shutil
.
which
(
command
)
if
not
p
:
if
p
:
if
emit_warns
and
command
not
in
warned
:
p
=
Path
(
p
)
print
(
else
:
f
"
info: optional external command
'
{
command
}
'
not found in PATH;
\
p
=
Path
(
resource_path
(
command
))
if
not
p
.
exists
():
if
emit_warns
:
print
(
f
"
info: optional external command
'
{
command
}
'
not found in PATH;
\
consider installing it or setting environment variable
{
env_var_name
}
"
consider installing it or setting environment variable
{
env_var_name
}
"
)
)
warned
[
command
]
=
Tru
e
p
=
Non
e
return
None
cached_commands
[
command
]
=
p
return
Path
(
p
)
return
p
def
run_and_check
(
command_and_args
,
input_data
):
def
run_and_check
(
command_and_args
,
input_data
):
...
...
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