Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
a31ae812
Commit
a31ae812
authored
Feb 14, 2013
by
Jim Fulton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68 from reinout/reinout-distutils-encoding-fix
Reinout distutils script encoding fix for #65
parents
9e36ccbe
b2ad694d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+9
-0
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+4
-2
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+1
-0
No files found.
src/zc/buildout/easy_install.py
View file @
a31ae812
...
@@ -46,6 +46,8 @@ default_index_url = os.environ.get(
...
@@ -46,6 +46,8 @@ default_index_url = os.environ.get(
logger
=
logging
.
getLogger
(
'zc.buildout.easy_install'
)
logger
=
logging
.
getLogger
(
'zc.buildout.easy_install'
)
url_match
=
re
.
compile
(
'[a-z0-9+.-]+://'
).
match
url_match
=
re
.
compile
(
'[a-z0-9+.-]+://'
).
match
is_source_encoding_line
=
re
.
compile
(
'coding[:=]
\
s*([-
\
w.]+)'
).
search
# Source encoding regex from http://www.python.org/dev/peps/pep-0263/
is_win32
=
sys
.
platform
==
'win32'
is_win32
=
sys
.
platform
==
'win32'
is_jython
=
sys
.
platform
.
startswith
(
'java'
)
is_jython
=
sys
.
platform
.
startswith
(
'java'
)
...
@@ -1046,12 +1048,18 @@ def _distutils_script(path, dest, script_content, initialization, rsetup):
...
@@ -1046,12 +1048,18 @@ def _distutils_script(path, dest, script_content, initialization, rsetup):
if
not
(
'#!'
in
lines
[
0
])
and
(
'python'
in
lines
[
0
]):
if
not
(
'#!'
in
lines
[
0
])
and
(
'python'
in
lines
[
0
]):
# The script doesn't follow distutil's rules. Ignore it.
# The script doesn't follow distutil's rules. Ignore it.
return
[]
return
[]
source_encoding_line
=
''
original_content
=
''
.
join
(
lines
[
1
:])
original_content
=
''
.
join
(
lines
[
1
:])
if
(
len
(
lines
)
>
1
)
and
is_source_encoding_line
(
lines
[
1
]):
# The second line contains a source encoding line. Copy it verbatim.
source_encoding_line
=
lines
[
1
].
rstrip
()
original_content
=
''
.
join
(
lines
[
2
:])
python
=
_safe_arg
(
sys
.
executable
)
python
=
_safe_arg
(
sys
.
executable
)
contents
=
distutils_script_template
%
dict
(
contents
=
distutils_script_template
%
dict
(
python
=
python
,
python
=
python
,
source_encoding_line
=
source_encoding_line
,
path
=
path
,
path
=
path
,
initialization
=
initialization
,
initialization
=
initialization
,
relative_paths_setup
=
rsetup
,
relative_paths_setup
=
rsetup
,
...
@@ -1118,6 +1126,7 @@ if __name__ == '__main__':
...
@@ -1118,6 +1126,7 @@ if __name__ == '__main__':
distutils_script_template
=
script_header
+
'''
\
distutils_script_template
=
script_header
+
'''
\
%(source_encoding_line)s
%(relative_paths_setup)s
%(relative_paths_setup)s
import sys
import sys
sys.path[0:0] = [
sys.path[0:0] = [
...
...
src/zc/buildout/easy_install.txt
View file @
a31ae812
...
@@ -938,11 +938,13 @@ It also works for zipped eggs:
...
@@ -938,11 +938,13 @@ It also works for zipped eggs:
Distutils copies the script files verbatim, apart from a line at the top that
Distutils copies the script files verbatim, apart from a line at the top that
looks like ``#!/usr/bin/python``, which gets replaced by the actual python
looks like ``#!/usr/bin/python``, which gets replaced by the actual python
interpreter. Buildout does the same, but additionally also adds the sys.path
interpreter. Buildout does the same, but additionally also adds the sys.path
like for the console_scripts:
like for the console_scripts. Note that the second line in the scripts can
contain a source encoding hint; buildout retains it.
>>> cat(distbin, 'distutilsscript')
>>> cat(distbin, 'distutilsscript')
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
# -*- coding: utf-8 -*-
<BLANKLINE>
<BLANKLINE>
import sys
import sys
sys.path[0:0] = [
sys.path[0:0] = [
...
...
src/zc/buildout/tests.py
View file @
a31ae812
...
@@ -2899,6 +2899,7 @@ def create_sample_eggs(test, executable=sys.executable):
...
@@ -2899,6 +2899,7 @@ def create_sample_eggs(test, executable=sys.executable):
write
(
write
(
tmp
,
'distutilsscript'
,
tmp
,
'distutilsscript'
,
'#!/usr/bin/python
\
n
'
'#!/usr/bin/python
\
n
'
'# -*- coding: utf-8 -*-
\
n
'
'import sys; sys.stdout.write("distutils!
\
\
n")
\
n
'
'import sys; sys.stdout.write("distutils!
\
\
n")
\
n
'
)
)
write
(
write
(
...
...
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