Commit e1b49cea authored by tarek's avatar tarek

now with 2.4 support for tarfile

--HG--
branch : distribute
extra : rebase_source : 0c0159d0868dc3b1f7b68b3d748ef33551075627
parent 321880f9
...@@ -16,11 +16,9 @@ This file can also be run as a script to install or upgrade setuptools. ...@@ -16,11 +16,9 @@ This file can also be run as a script to install or upgrade setuptools.
from site import USER_SITE from site import USER_SITE
import sys import sys
import os import os
import shutil
import time import time
import fnmatch import fnmatch
from distutils import log from distutils import log
from distutils.errors import DistutilsError
is_jython = sys.platform.startswith('java') is_jython = sys.platform.startswith('java')
if is_jython: if is_jython:
...@@ -28,8 +26,7 @@ if is_jython: ...@@ -28,8 +26,7 @@ if is_jython:
DEFAULT_VERSION = "0.6.1" DEFAULT_VERSION = "0.6.1"
#DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/" DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
DEFAULT_URL = "http://nightly.ziade.org/"
def download_setuptools( def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
...@@ -41,7 +38,7 @@ def download_setuptools( ...@@ -41,7 +38,7 @@ def download_setuptools(
with a '/'). `to_dir` is the directory where the egg will be downloaded. 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. `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 tgz_name = "distribute-%s.tar.gz" % version
url = download_base + tgz_name url = download_base + tgz_name
saveto = os.path.join(to_dir, tgz_name) saveto = os.path.join(to_dir, tgz_name)
...@@ -263,6 +260,46 @@ def _relaunch(): ...@@ -263,6 +260,46 @@ def _relaunch():
import tempfile import tempfile
import tarfile 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): def _install(tarball):
# extracting the tarball # extracting the tarball
tmpdir = tempfile.mkdtemp() tmpdir = tempfile.mkdtemp()
...@@ -271,7 +308,7 @@ def _install(tarball): ...@@ -271,7 +308,7 @@ def _install(tarball):
try: try:
os.chdir(tmpdir) os.chdir(tmpdir)
tar = tarfile.open(tarball) tar = tarfile.open(tarball)
tar.extractall() extractall(tar)
tar.close() tar.close()
# going in the directory # going in the directory
......
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