Commit c6772294 authored by pombredanne's avatar pombredanne

Merge remote-tracking branch 'buildout/master' into header_expressions

parents 937537a4 8c13789c
Change History Change History
************** **************
2.0.1 (2013-02-14) 2.0.1 (2013-02-16)
================== ==================
- Fixed: buildout didn't honor umask settings when creating scripts.
- Fix for distutils scripts installation on Python 3, related to - Fix for distutils scripts installation on Python 3, related to
``__pycache__`` directories. ``__pycache__`` directories.
......
...@@ -18,7 +18,11 @@ The script accepts buildout command-line options, so you can ...@@ -18,7 +18,11 @@ The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file. use the -c option to specify an alternate configuration file.
""" """
import os, shutil, sys, tempfile import os
import shutil
import sys
import tempfile
from optparse import OptionParser from optparse import OptionParser
tmpeggs = tempfile.mkdtemp() tmpeggs = tempfile.mkdtemp()
...@@ -61,7 +65,8 @@ options, args = parser.parse_args() ...@@ -61,7 +65,8 @@ options, args = parser.parse_args()
to_reload = False to_reload = False
try: try:
import pkg_resources, setuptools import pkg_resources
import setuptools
if not hasattr(pkg_resources, '_distribute'): if not hasattr(pkg_resources, '_distribute'):
to_reload = True to_reload = True
raise ImportError raise ImportError
...@@ -73,7 +78,8 @@ except ImportError: ...@@ -73,7 +78,8 @@ except ImportError:
except ImportError: except ImportError:
from urllib2 import urlopen from urllib2 import urlopen
exec(urlopen('http://python-distribute.org/distribute_setup.py').read(), ez) exec(urlopen('http://python-distribute.org/distribute_setup.py').read(),
ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True) setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True)
ez['use_setuptools'](**setup_args) ez['use_setuptools'](**setup_args)
...@@ -113,6 +119,7 @@ if version is None and not options.accept_buildout_test_releases: ...@@ -113,6 +119,7 @@ if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout. # Figure out the most recent final version of zc.buildout.
import setuptools.package_index import setuptools.package_index
_final_parts = '*final-', '*final' _final_parts = '*final-', '*final'
def _final_version(parsed_version): def _final_version(parsed_version):
for part in parsed_version: for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts): if (part[:1] == '*') and (part not in _final_parts):
......
...@@ -117,6 +117,16 @@ def call_subprocess(args, **kw): ...@@ -117,6 +117,16 @@ def call_subprocess(args, **kw):
"Failed to run command:\n%s" "Failed to run command:\n%s"
% repr(args)[1:-1]) % repr(args)[1:-1])
def _execute_permission():
current_umask = os.umask(0o022)
# os.umask only returns the current umask if you also give it one, so we
# have to give it a dummy one and immediately set it back to the real
# value... Distribute does the same.
os.umask(current_umask)
return 0o777 - current_umask
_easy_install_cmd = 'from setuptools.command.easy_install import main; main()' _easy_install_cmd = 'from setuptools.command.easy_install import main; main()'
class Installer: class Installer:
...@@ -1099,7 +1109,7 @@ def _create_script(contents, dest): ...@@ -1099,7 +1109,7 @@ def _create_script(contents, dest):
script.endswith('-script.py') and script[:-10] or script) script.endswith('-script.py') and script[:-10] or script)
try: try:
os.chmod(dest, 493) # 0755 os.chmod(dest, _execute_permission())
except (AttributeError, os.error): except (AttributeError, os.error):
pass pass
...@@ -1167,7 +1177,7 @@ def _pyscript(path, dest, rsetup, initialization=''): ...@@ -1167,7 +1177,7 @@ def _pyscript(path, dest, rsetup, initialization=''):
if changed: if changed:
open(dest, 'w').write(contents) open(dest, 'w').write(contents)
try: try:
os.chmod(dest, 493) # 0755 os.chmod(dest, _execute_permission())
except (AttributeError, os.error): except (AttributeError, os.error):
pass pass
logger.info("Generated interpreter %r.", script) logger.info("Generated interpreter %r.", script)
......
...@@ -697,6 +697,15 @@ original script names to new script names. ...@@ -697,6 +697,15 @@ original script names to new script names.
>>> print_(system(os.path.join(bin, 'run')), end='') >>> print_(system(os.path.join(bin, 'run')), end='')
3 1 3 1
The scripts that are generated are made executable:
>>> if sys.platform == 'win32':
... os.access(os.path.join(bin, 'run.exe'), os.X_OK)
... else:
... os.access(os.path.join(bin, 'run'), os.X_OK)
True
Including extra paths in scripts Including extra paths in scripts
-------------------------------- --------------------------------
......
...@@ -236,6 +236,13 @@ Since buildout 2.0, the functionality of the `buildout-versions ...@@ -236,6 +236,13 @@ Since buildout 2.0, the functionality of the `buildout-versions
<http://packages.python.org/buildout-versions/>`_ extension is part of <http://packages.python.org/buildout-versions/>`_ extension is part of
buildout itself. This makes reporting and managing versions easier. buildout itself. This makes reporting and managing versions easier.
Buildout picks a version for distribute and for the tests, we need to grab the
version number:
>>> import pkg_resources
>>> req = pkg_resources.Requirement.parse('distribute')
>>> distribute_version = pkg_resources.working_set.find(req).version
If you set the ``show-picked-versions`` option, buildout will print If you set the ``show-picked-versions`` option, buildout will print
versions it picked at the end of its run: versions it picked at the end of its run:
...@@ -270,12 +277,12 @@ When everything is pinned, no output is generated: ...@@ -270,12 +277,12 @@ When everything is pinned, no output is generated:
... show-picked-versions = true ... show-picked-versions = true
... ...
... [versions] ... [versions]
... distribute = 0.6.34 ... distribute = %s
... spam = 2 ... spam = 2
... ...
... [foo] ... [foo]
... recipe = spam ... recipe = spam
... ''' % join('recipe', 'dist')) ... ''' % (join('recipe', 'dist'), distribute_version))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS >>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo. Updating foo.
recipe v2 recipe v2
...@@ -294,12 +301,12 @@ and case differences won't impact the pinning: ...@@ -294,12 +301,12 @@ and case differences won't impact the pinning:
... show-picked-versions = true ... show-picked-versions = true
... ...
... [versions] ... [versions]
... distriBUTE = 0.6.34 ... distriBUTE = %s
... Spam = 2 ... Spam = 2
... ...
... [foo] ... [foo]
... recipe = spam ... recipe = spam
... ''' % join('recipe', 'dist')) ... ''' % (join('recipe', 'dist'), distribute_version))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS >>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo. Updating foo.
recipe v2 recipe v2
...@@ -311,9 +318,9 @@ extending from that versions file: ...@@ -311,9 +318,9 @@ extending from that versions file:
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = 0.6.34 ... distribute = %s
... spam = 2 ... spam = 2
... ''') ... ''' % distribute_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
...@@ -336,8 +343,8 @@ at the end. ...@@ -336,8 +343,8 @@ at the end.
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = 0.6.34 ... distribute = %s
... ''') ... ''' % distribute_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
...@@ -377,8 +384,8 @@ printing them to the console): ...@@ -377,8 +384,8 @@ printing them to the console):
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = 0.6.34 ... distribute = %s
... ''') ... ''' % distribute_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
......
...@@ -2872,6 +2872,22 @@ def test_buildout_section_shorthand_for_command_line_assignments(): ...@@ -2872,6 +2872,22 @@ def test_buildout_section_shorthand_for_command_line_assignments():
>>> print_(system(buildout+' parts='), end='') # doctest: +ELLIPSIS >>> print_(system(buildout+' parts='), end='') # doctest: +ELLIPSIS
""" """
def buildout_honors_umask():
"""
For setting the executable permission, the user's umask is honored:
>>> orig_umask = os.umask(0o077) # Only user gets permissions.
>>> zc.buildout.easy_install._execute_permission() == 0o700
True
>>> tmp = os.umask(0o022) # User can write, the rest not.
>>> zc.buildout.easy_install._execute_permission() == 0o755
True
>>> tmp = os.umask(orig_umask) # Reset umask to the original value.
"""
if sys.platform == 'win32':
del buildout_honors_umask # umask on dohs is academic
###################################################################### ######################################################################
......
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