Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
base
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
Container Registry
Model registry
Operate
Environments
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
FSL
base
Commits
e5bf4784
Commit
e5bf4784
authored
3 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Plain Diff
Merge branch 'rf/pythonw' into 'master'
Detect pythonw scripts Closes
#3
See merge request
!18
parents
1dfe1085
791c73af
No related branches found
No related tags found
1 merge request
!18
Detect pythonw scripts
Pipeline
#10178
passed
3 years ago
Stage: test
Stage: fsl-ci-build
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
share/fsl/sbin/createFSLWrapper
+17
-15
17 additions, 15 deletions
share/fsl/sbin/createFSLWrapper
tests/test_create_remove_wrapper.py
+35
-0
35 additions, 0 deletions
tests/test_create_remove_wrapper.py
with
54 additions
and
15 deletions
CHANGELOG.md
+
2
−
0
View file @
e5bf4784
...
...
@@ -8,6 +8,8 @@
-
The
`$FSLDIR/etc/fslconf/fsl.sh`
script now uses
`$FSLDIR/etc/fslversion`
to identify official FSL installations - if this file is present,
`$FSLDIR/share/fsl/bin`
is automatically added to the
`$PATH`
variable.
-
The
`$FSLDIR/share/fsl/sbin/createFSLWrapper`
script now detects
`pythonw`
executables.
## 2107.3 (Monday 12th July 2021)
...
...
This diff is collapsed.
Click to expand it.
share/fsl/sbin/createFSLWrapper
+
17
−
15
View file @
e5bf4784
...
...
@@ -85,27 +85,29 @@ for script in $targets; do
# Figure out whether this is a python
# executable or some other type of
# executable. We search for these strings
# in source file headers to ID them as
# python scripts. We need to check both
# match "#!/usr/bin/env python" and
# "#!<fsldir>/bin/python...", because
# conda might generate one or the other
# in different scenarios.
id1
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"#!/usr/bin/env python"
)
id2
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"#!
${
FSLDIR
%/
}
/bin/python"
)
# executable.
id
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
-e
'^#!.*pythonw\?$'
)
# Non-python executable - use
a
# pass-through script
if
[
-z
"
$id
1
"
]
&&
[
-z
"
$id2
"
]
;
then
# Non-python executable - use
#
a
pass-through script
if
[
-z
"
$id
"
]
;
then
echo
"#!/usr/bin/env bash"
>
"
$targetScript
"
echo
"
$FSLDIR
/bin/
$script
"
'"$@"'
>>
"
$targetScript
"
else
# Python executable - run it via
# $FSLDIR/bin/python in isolated mode
echo
"#!/usr/bin/env bash"
>
"
$targetScript
"
echo
"
$FSLDIR
/bin/python -I
$sourceScript
"
'"$@"'
>>
"
$targetScript
"
# $FSLDIR/bin/python[w] in isolated
# mode. Under macOS, GUI apps are
# invoked with pythonw, so we need
# to preserve the interpreter.
if
[[
"
$id
"
==
*
"pythonw"
]]
;
then
interp
=
"pythonw"
else
interp
=
"python"
fi
echo
"#!/usr/bin/env bash"
>
"
$targetScript
"
echo
"
${
FSLDIR
}
/bin/
${
interp
}
-I
$sourceScript
"
'"$@"'
>>
"
$targetScript
"
fi
# Preserve file permissions
...
...
This diff is collapsed.
Click to expand it.
tests/test_create_remove_wrapper.py
+
35
−
0
View file @
e5bf4784
...
...
@@ -126,6 +126,40 @@ def test_create_python_wrapper():
assert
got
==
expect
def
test_create_pythonw_wrapper
():
"""
Test creation of a wrapper script for a python script which
uses pythonw as the interpreter (for GUI apps on macOS).
"""
hashbangs
=
[
'
#!/bin/bash /usr/bin/pythonw
'
,
'
#!/usr/bin/pythonw
'
,
'
#!/usr/bin/env pythonw
'
]
with
temp_fsldir
()
as
(
fsldir
,
wrapperdir
):
script_path
=
op
.
join
(
fsldir
,
'
bin
'
,
'
test_script
'
)
wrapper_path
=
op
.
join
(
wrapperdir
,
'
test_script
'
)
touch
(
script_path
)
for
hb
in
hashbangs
:
with
open
(
script_path
,
'
wt
'
)
as
f
:
f
.
write
(
hb
+
'
\n
'
)
f
.
write
(
'
print(
"
hello
"
)
\n
'
)
expect
=
tw
.
dedent
(
f
"""
#!/usr/bin/env bash
{
fsldir
}
/bin/pythonw -I
{
script_path
}
"
$@
"
"""
).
strip
()
run
(
f
'
{
CREATE_WRAPPER
}
test_script
'
)
assert
op
.
exists
(
wrapper_path
)
with
open
(
wrapper_path
,
'
rt
'
)
as
f
:
got
=
f
.
read
().
strip
()
assert
got
==
expect
def
test_create_other_wrapper
():
"""
Test creation of a wrapper script for a non-python executable.
"""
with
temp_fsldir
()
as
(
fsldir
,
wrapperdir
):
...
...
@@ -151,6 +185,7 @@ def test_create_other_wrapper():
assert
got
==
expect
def
test_permissions_preserved
():
"""
Test that wrapper script has same permissions as wrapped script.
"""
with
temp_fsldir
()
as
(
fsldir
,
wrapperdir
):
...
...
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