diff options
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/__init__.py | 6 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 4 | ||||
-rwxr-xr-x | setuptools/command/install_egg_info.py | 2 | ||||
-rw-r--r-- | setuptools/dist.py | 19 | ||||
-rw-r--r-- | setuptools/svn_utils.py | 2 | ||||
-rw-r--r-- | setuptools/tests/environment.py | 65 | ||||
-rw-r--r-- | setuptools/version.py | 2 | ||||
-rw-r--r-- | setuptools/windows_support.py | 29 |
8 files changed, 62 insertions, 67 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index d99ab2a6..ca025c30 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -139,7 +139,7 @@ def findall(dir = os.curdir): (relative to 'dir'). """ all_files = [] - for base, dirs, files in os.walk(dir): + for base, dirs, files in os.walk(dir, followlinks=True): if base==os.curdir or base.startswith(os.curdir+os.sep): base = base[2:] if base: @@ -148,7 +148,3 @@ def findall(dir = os.curdir): return all_files distutils.filelist.findall = findall # fix findall bug in distutils. - -# sys.dont_write_bytecode was introduced in Python 2.6. -_dont_write_bytecode = getattr(sys, 'dont_write_bytecode', - bool(os.environ.get("PYTHONDONTWRITEBYTECODE"))) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 68548272..2e00b996 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -35,7 +35,7 @@ import warnings import site import struct -from setuptools import Command, _dont_write_bytecode +from setuptools import Command from setuptools.sandbox import run_setup from setuptools.py31compat import get_path, get_config_vars from setuptools.command import setopt @@ -1152,7 +1152,7 @@ See the setuptools documentation for the "develop" command for more info. chmod(f, mode) def byte_compile(self, to_compile): - if _dont_write_bytecode: + if sys.dont_write_bytecode: self.warn('byte-compiling is disabled, skipping.') return diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 992709f1..fd0f118b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [] + self.outputs = [self.target] def run(self): self.run_command('egg_info') diff --git a/setuptools/dist.py b/setuptools/dist.py index a3a37ee4..e44796fd 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -22,6 +22,7 @@ except ImportError: from setuptools.depends import Require from setuptools.compat import basestring, PY2 +from setuptools import windows_support import pkg_resources @@ -334,6 +335,21 @@ class Distribution(_Distribution): else: self.convert_2to3_doctests = [] + def get_egg_cache_dir(self): + egg_cache_dir = os.path.join(os.curdir, '.eggs') + if not os.path.exists(egg_cache_dir): + os.mkdir(egg_cache_dir) + windows_support.hide_file(egg_cache_dir) + readme_txt_filename = os.path.join(egg_cache_dir, 'README.txt') + with open(readme_txt_filename, 'w') as f: + f.write('This directory contains eggs that were downloaded ' + 'by setuptools to build, test, and run plug-ins.\n\n') + f.write('This directory caches those eggs to prevent ' + 'repeated downloads.\n\n') + f.write('However, it is safe to delete this directory.\n\n') + + return egg_cache_dir + def fetch_build_egg(self, req): """Fetch an egg needed for building""" @@ -357,8 +373,9 @@ class Distribution(_Distribution): if 'find_links' in opts: links = opts['find_links'][1].split() + links opts['find_links'] = ('setup', links) + install_dir = self.get_egg_cache_dir() cmd = easy_install( - dist, args=["x"], install_dir=os.curdir, exclude_scripts=True, + dist, args=["x"], install_dir=install_dir, exclude_scripts=True, always_copy=False, build_directory=None, editable=False, upgrade=False, multi_version=True, no_report=True, user=False ) diff --git a/setuptools/svn_utils.py b/setuptools/svn_utils.py index dadb682a..6502fc98 100644 --- a/setuptools/svn_utils.py +++ b/setuptools/svn_utils.py @@ -302,7 +302,7 @@ class SvnInfo(object): self._externals = None
def get_revision(self):
- 'Retrieve the directory revision informatino using svnversion'
+ 'Retrieve the directory revision information using svnversion'
code, data = _run_command(['svnversion', '-c', self.path])
if code:
log.warn("svnversion failed")
diff --git a/setuptools/tests/environment.py b/setuptools/tests/environment.py index 476d280a..c8d0e669 100644 --- a/setuptools/tests/environment.py +++ b/setuptools/tests/environment.py @@ -10,57 +10,6 @@ import unicodedata from subprocess import Popen as _Popen, PIPE as _PIPE -def _extract(self, member, path=None, pwd=None): - """for zipfile py2.5 borrowed from cpython""" - if not isinstance(member, zipfile.ZipInfo): - member = self.getinfo(member) - - if path is None: - path = os.getcwd() - - return _extract_member(self, member, path, pwd) - - -def _extract_from_zip(self, name, dest_path): - dest_file = open(dest_path, 'wb') - try: - dest_file.write(self.read(name)) - finally: - dest_file.close() - - -def _extract_member(self, member, targetpath, pwd): - """for zipfile py2.5 borrowed from cpython""" - # build the destination pathname, replacing - # forward slashes to platform specific separators. - # Strip trailing path separator, unless it represents the root. - if (targetpath[-1:] in (os.path.sep, os.path.altsep) - and len(os.path.splitdrive(targetpath)[1]) > 1): - targetpath = targetpath[:-1] - - # don't include leading "/" from file name if present - if member.filename[0] == '/': - targetpath = os.path.join(targetpath, member.filename[1:]) - else: - targetpath = os.path.join(targetpath, member.filename) - - targetpath = os.path.normpath(targetpath) - - # Create all upper directories if necessary. - upperdirs = os.path.dirname(targetpath) - if upperdirs and not os.path.exists(upperdirs): - os.makedirs(upperdirs) - - if member.filename[-1] == '/': - if not os.path.isdir(targetpath): - os.mkdir(targetpath) - return targetpath - - _extract_from_zip(self, member.filename, targetpath) - - return targetpath - - def _remove_dir(target): #on windows this seems to a problem @@ -92,7 +41,7 @@ class ZippedEnvironment(unittest.TestCase): try: zip_file = zipfile.ZipFile(self.datafile) for files in zip_file.namelist(): - _extract(zip_file, files, self.temp_dir) + zip_file.extract(files, self.temp_dir) finally: if zip_file: zip_file.close() @@ -147,10 +96,13 @@ def run_setup_py(cmd, pypath=None, path=None, cmd = [sys.executable, "setup.py"] + list(cmd) - #regarding the shell argument, see: http://bugs.python.org/issue8557 + # http://bugs.python.org/issue8557 + shell = sys.platform == 'win32' + try: - proc = _Popen(cmd, stdout=_PIPE, stderr=_PIPE, - shell=(sys.platform == 'win32'), env=env) + proc = _Popen( + cmd, stdout=_PIPE, stderr=_PIPE, shell=shell, env=env, + ) data = proc.communicate()[data_stream] except OSError: @@ -158,7 +110,8 @@ def run_setup_py(cmd, pypath=None, path=None, #decode the console string if needed if hasattr(data, "decode"): - data = data.decode() # should use the preffered encoding + # use the default encoding + data = data.decode() data = unicodedata.normalize('NFC', data) #communciate calls wait() diff --git a/setuptools/version.py b/setuptools/version.py index 29524eba..4ca9d5df 100644 --- a/setuptools/version.py +++ b/setuptools/version.py @@ -1 +1 @@ -__version__ = '7.0' +__version__ = '8.0' diff --git a/setuptools/windows_support.py b/setuptools/windows_support.py new file mode 100644 index 00000000..cb977cff --- /dev/null +++ b/setuptools/windows_support.py @@ -0,0 +1,29 @@ +import platform +import ctypes + + +def windows_only(func): + if platform.system() != 'Windows': + return lambda *args, **kwargs: None + return func + + +@windows_only +def hide_file(path): + """ + Set the hidden attribute on a file or directory. + + From http://stackoverflow.com/questions/19622133/ + + `path` must be text. + """ + __import__('ctypes.wintypes') + SetFileAttributes = ctypes.windll.kernel32.SetFileAttributesW + SetFileAttributes.argtypes = ctypes.wintypes.LPWSTR, ctypes.wintypes.DWORD + SetFileAttributes.restype = ctypes.wintypes.BOOL + + FILE_ATTRIBUTE_HIDDEN = 0x02 + + ret = SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN) + if not ret: + raise ctypes.WinError() |