diff options
author | tarek <none@none> | 2009-09-08 22:44:01 +0200 |
---|---|---|
committer | tarek <none@none> | 2009-09-08 22:44:01 +0200 |
commit | e1b49ceae4787252de524b4c5210331be526c2cb (patch) | |
tree | 1ddd9bedfcd93e096184f431cee141171eecee47 | |
parent | 321880f989c67fe471e2736f7be5517a098120c5 (diff) | |
download | external_python_setuptools-e1b49ceae4787252de524b4c5210331be526c2cb.tar.gz external_python_setuptools-e1b49ceae4787252de524b4c5210331be526c2cb.tar.bz2 external_python_setuptools-e1b49ceae4787252de524b4c5210331be526c2cb.zip |
now with 2.4 support for tarfile0.6.1
--HG--
branch : distribute
extra : rebase_source : 0c0159d0868dc3b1f7b68b3d748ef33551075627
-rw-r--r-- | distribute_setup.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/distribute_setup.py b/distribute_setup.py index 9b388b57..8f67829e 100644 --- a/distribute_setup.py +++ b/distribute_setup.py @@ -16,11 +16,9 @@ This file can also be run as a script to install or upgrade setuptools. from site import USER_SITE import sys import os -import shutil import time import fnmatch from distutils import log -from distutils.errors import DistutilsError is_jython = sys.platform.startswith('java') if is_jython: @@ -28,8 +26,7 @@ if is_jython: DEFAULT_VERSION = "0.6.1" -#DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/" -DEFAULT_URL = "http://nightly.ziade.org/" +DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/" def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, @@ -41,7 +38,7 @@ def download_setuptools( with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ - import urllib2, shutil + import urllib2 tgz_name = "distribute-%s.tar.gz" % version url = download_base + tgz_name saveto = os.path.join(to_dir, tgz_name) @@ -263,6 +260,46 @@ def _relaunch(): import tempfile import tarfile +def extractall(self, path=".", members=None): + """Extract all members from the archive to the current working + directory and set owner, modification time and permissions on + directories afterwards. `path' specifies a different directory + to extract to. `members' is optional and must be a subset of the + list returned by getmembers(). + """ + import copy + import operator + from tarfile import ExtractError + directories = [] + + if members is None: + members = self + + for tarinfo in members: + if tarinfo.isdir(): + # Extract directories with a safe mode. + directories.append(tarinfo) + tarinfo = copy.copy(tarinfo) + tarinfo.mode = 0700 + self.extract(tarinfo, path) + + # Reverse sort directories. + directories.sort(key=operator.attrgetter('name')) + directories.reverse() + + # Set correct owner, mtime and filemode on directories. + for tarinfo in directories: + dirpath = os.path.join(path, tarinfo.name) + try: + self.chown(tarinfo, dirpath) + self.utime(tarinfo, dirpath) + self.chmod(tarinfo, dirpath) + except ExtractError, e: + if self.errorlevel > 1: + raise + else: + self._dbg(1, "tarfile: %s" % e) + def _install(tarball): # extracting the tarball tmpdir = tempfile.mkdtemp() @@ -271,7 +308,7 @@ def _install(tarball): try: os.chdir(tmpdir) tar = tarfile.open(tarball) - tar.extractall() + extractall(tar) tar.close() # going in the directory |