Commit 6874dc07 authored by Reinout van Rees's avatar Reinout van Rees

Added test: future and docstring in distutils scripts

parent 284e2470
...@@ -962,12 +962,14 @@ It also works for zipped eggs: ...@@ -962,12 +962,14 @@ 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. Note that the second line in the scripts can like for the console_scripts.
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 -*- # -*- coding: utf-8 -*-
"""Module docstring."""
from __future__ import print_statement
<BLANKLINE>
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -977,6 +979,12 @@ contain a source encoding hint; buildout retains it. ...@@ -977,6 +979,12 @@ contain a source encoding hint; buildout retains it.
<BLANKLINE> <BLANKLINE>
import sys; sys.stdout.write("distutils!\n") import sys; sys.stdout.write("distutils!\n")
Note that there are several items that need to come first in such a script
*before* buildout's ``sys.path`` statements: a source encoding hint, a module
docstring and ``__future__`` imports. Buildout retains them in their proper
place by looking at the first non-future import and placing its ``sys.path``
statement before that.
Due to the nature of distutils scripts, buildout cannot pass arguments as Due to the nature of distutils scripts, buildout cannot pass arguments as
there's no specific method to pass them to. there's no specific method to pass them to.
......
...@@ -2945,6 +2945,8 @@ def create_sample_eggs(test, executable=sys.executable): ...@@ -2945,6 +2945,8 @@ def create_sample_eggs(test, executable=sys.executable):
tmp, 'distutilsscript', tmp, 'distutilsscript',
'#!/usr/bin/python\n' '#!/usr/bin/python\n'
'# -*- coding: utf-8 -*-\n' '# -*- coding: utf-8 -*-\n'
'"""Module docstring."""\n'
'from __future__ import print_statement\n'
'import sys; sys.stdout.write("distutils!\\n")\n' 'import sys; sys.stdout.write("distutils!\\n")\n'
) )
write( write(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment