Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
390e64c3
Commit
390e64c3
authored
Jan 04, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved get_script_header into ScriptWriter class
parent
db3ee08f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+6
-5
setuptools/tests/test_easy_install.py
setuptools/tests/test_easy_install.py
+18
-10
No files found.
setuptools/command/easy_install.py
View file @
390e64c3
...
...
@@ -1592,11 +1592,6 @@ def _first_line_re():
return
re
.
compile
(
first_line_re
.
pattern
.
decode
())
def
get_script_header
(
script_text
,
executable
=
sys_executable
,
wininst
=
False
):
executable
=
"python.exe"
if
wininst
else
nt_quote_arg
(
executable
)
return
ScriptWriter
.
get_header
(
script_text
,
executable
)
def
auto_chmod
(
func
,
arg
,
exc
):
if
func
is
os
.
remove
and
os
.
name
==
'nt'
:
chmod
(
arg
,
stat
.
S_IWRITE
)
...
...
@@ -1886,6 +1881,11 @@ class ScriptWriter(object):
header
=
get_script_header
(
""
,
executable
,
wininst
)
return
writer
.
_gen_args
(
dist
,
header
)
@
classmethod
def
get_script_header
(
cls
,
script_text
,
executable
=
sys_executable
,
wininst
=
False
):
executable
=
"python.exe"
if
wininst
else
nt_quote_arg
(
executable
)
return
cls
.
get_header
(
script_text
,
executable
)
@
classmethod
def
_gen_args
(
cls
,
dist
,
header
=
None
):
"""
...
...
@@ -2016,6 +2016,7 @@ class WindowsExecutableLauncherWriter(WindowsScriptWriter):
# for backward-compatibility
get_script_args
=
ScriptWriter
.
get_script_args
get_script_header
=
ScriptWriter
.
get_script_header
def
get_win_launcher
(
type
):
...
...
setuptools/tests/test_easy_install.py
View file @
390e64c3
...
...
@@ -23,7 +23,7 @@ from setuptools.compat import StringIO, BytesIO, urlparse
from
setuptools.sandbox
import
run_setup
from
setuptools.command.easy_install
import
(
easy_install
,
fix_jython_executable
,
nt_quote_arg
,
get_script_header
,
is_sh
,
ScriptWriter
,
is_sh
,
ScriptWriter
,
)
from
setuptools.command.easy_install
import
PthDistributions
from
setuptools.command
import
easy_install
as
easy_install_pkg
...
...
@@ -425,15 +425,22 @@ class TestScriptHeader:
)
def
test_get_script_header
(
self
):
expected
=
'#!%s
\
n
'
%
nt_quote_arg
(
os
.
path
.
normpath
(
sys
.
executable
))
assert
get_script_header
(
'#!/usr/local/bin/python'
)
==
expected
actual
=
ScriptWriter
.
get_script_header
(
'#!/usr/local/bin/python'
)
assert
actual
==
expected
expected
=
'#!%s -x
\
n
'
%
nt_quote_arg
(
os
.
path
.
normpath
(
sys
.
executable
))
assert
get_script_header
(
'#!/usr/bin/python -x'
)
==
expected
candidate
=
get_script_header
(
'#!/usr/bin/python'
,
actual
=
ScriptWriter
.
get_script_header
(
'#!/usr/bin/python -x'
)
assert
actual
==
expected
actual
=
ScriptWriter
.
get_script_header
(
'#!/usr/bin/python'
,
executable
=
self
.
non_ascii_exe
)
assert
candidate
==
'#!%s -x
\
n
'
%
self
.
non_ascii_exe
candidate
=
get_script_header
(
'#!/usr/bin/python'
,
expected
=
'#!%s -x
\
n
'
%
self
.
non_ascii_exe
assert
actual
==
expected
actual
=
ScriptWriter
.
get_script_header
(
'#!/usr/bin/python'
,
executable
=
self
.
exe_with_spaces
)
assert
candidate
==
'#!"%s"
\
n
'
%
self
.
exe_with_spaces
expected
=
'#!"%s"
\
n
'
%
self
.
exe_with_spaces
assert
actual
==
expected
@
pytest
.
mark
.
xfail
(
compat
.
PY3
and
os
.
environ
.
get
(
"LC_CTYPE"
)
in
(
"C"
,
"POSIX"
),
...
...
@@ -453,7 +460,8 @@ class TestScriptHeader:
f
.
write
(
header
)
exe
=
str
(
exe
)
header
=
get_script_header
(
'#!/usr/local/bin/python'
,
executable
=
exe
)
header
=
ScriptWriter
.
get_script_header
(
'#!/usr/local/bin/python'
,
executable
=
exe
)
assert
header
==
'#!/usr/bin/env %s
\
n
'
%
exe
expect_out
=
'stdout'
if
sys
.
version_info
<
(
2
,
7
)
else
'stderr'
...
...
@@ -461,14 +469,14 @@ class TestScriptHeader:
with
contexts
.
quiet
()
as
(
stdout
,
stderr
):
# When options are included, generate a broken shebang line
# with a warning emitted
candidate
=
get_script_header
(
'#!/usr/bin/python -x'
,
candidate
=
ScriptWriter
.
get_script_header
(
'#!/usr/bin/python -x'
,
executable
=
exe
)
assert
candidate
==
'#!%s -x
\
n
'
%
exe
output
=
locals
()[
expect_out
]
assert
'Unable to adapt shebang line'
in
output
.
getvalue
()
with
contexts
.
quiet
()
as
(
stdout
,
stderr
):
candidate
=
get_script_header
(
'#!/usr/bin/python'
,
candidate
=
ScriptWriter
.
get_script_header
(
'#!/usr/bin/python'
,
executable
=
self
.
non_ascii_exe
)
assert
candidate
==
'#!%s -x
\
n
'
%
self
.
non_ascii_exe
output
=
locals
()[
expect_out
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment