~ubuntu-branches/ubuntu/precise/distribute/precise

« back to all changes in this revision

Viewing changes to distribute_setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-12-28 23:52:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091228235240-mw9ruki1uprxfmo2
Tags: 0.6.10-1
* New upstream version.
* Stop building for python2.4. Closes: #557000.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
            args = [quote(arg) for arg in args]
47
47
        return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
48
48
 
49
 
DEFAULT_VERSION = "0.6.8"
 
49
DEFAULT_VERSION = "0.6.10"
50
50
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
 
51
SETUPTOOLS_FAKED_VERSION = "0.6c11"
 
52
 
51
53
SETUPTOOLS_PKG_INFO = """\
52
54
Metadata-Version: 1.0
53
55
Name: setuptools
54
 
Version: 0.6c9
 
56
Version: %s
55
57
Summary: xxxx
56
58
Home-page: xxx
57
59
Author: xxx
58
60
Author-email: xxx
59
61
License: xxx
60
62
Description: xxx
61
 
"""
 
63
""" % SETUPTOOLS_FAKED_VERSION
62
64
 
63
65
 
64
66
def _install(tarball):
79
81
 
80
82
        # installing
81
83
        log.warn('Installing Distribute')
82
 
        assert _python_cmd('setup.py', 'install')
 
84
        if not _python_cmd('setup.py', 'install'):
 
85
            log.warn('Something went wrong during the installation.')
 
86
            log.warn('See the error message above.')
83
87
    finally:
84
88
        os.chdir(old_wd)
85
89
 
220
224
def _same_content(path, content):
221
225
    return open(path).read() == content
222
226
 
223
 
 
 
227
def _no_sandbox(function):
 
228
    def __no_sandbox(*args, **kw):
 
229
        try:
 
230
            from setuptools.sandbox import DirectorySandbox
 
231
            def violation(*args):
 
232
                pass
 
233
            DirectorySandbox._old = DirectorySandbox._violation
 
234
            DirectorySandbox._violation = violation
 
235
            patched = True
 
236
        except ImportError:
 
237
            patched = False
 
238
 
 
239
        try:
 
240
            return function(*args, **kw)
 
241
        finally:
 
242
            if patched:
 
243
                DirectorySandbox._violation = DirectorySandbox._old
 
244
                del DirectorySandbox._old
 
245
 
 
246
    return __no_sandbox
 
247
 
 
248
@_no_sandbox
224
249
def _rename_path(path):
225
250
    new_name = path + '.OLD.%s' % time.time()
226
251
    log.warn('Renaming %s into %s', path, new_name)
227
 
    try:
228
 
        from setuptools.sandbox import DirectorySandbox
229
 
        def _violation(*args):
230
 
            pass
231
 
        DirectorySandbox._violation = _violation
232
 
    except ImportError:
233
 
        pass
234
 
 
235
252
    os.rename(path, new_name)
236
253
    return new_name
237
254
 
238
 
 
239
255
def _remove_flat_installation(placeholder):
240
256
    if not os.path.isdir(placeholder):
241
257
        log.warn('Unkown installation at %s', placeholder)
275
291
    placeholder = dist.get_command_obj('install').install_purelib
276
292
    _create_fake_setuptools_pkg_info(placeholder)
277
293
 
 
294
@_no_sandbox
278
295
def _create_fake_setuptools_pkg_info(placeholder):
279
296
    if not placeholder or not os.path.exists(placeholder):
280
297
        log.warn('Could not find the install location')
281
298
        return
282
299
    pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
283
 
    setuptools_file = 'setuptools-0.6c9.egg-info'
 
300
    setuptools_file = 'setuptools-%s.egg-info' % SETUPTOOLS_FAKED_VERSION
284
301
    pkg_info = os.path.join(placeholder, setuptools_file)
285
302
    if os.path.exists(pkg_info):
286
303
        log.warn('%s already exists', pkg_info)
287
304
        return
 
305
 
288
306
    log.warn('Creating %s', pkg_info)
289
307
    f = open(pkg_info, 'w')
290
308
    try:
291
309
        f.write(SETUPTOOLS_PKG_INFO)
292
310
    finally:
293
311
        f.close()
 
312
 
294
313
    pth_file = os.path.join(placeholder, 'setuptools.pth')
295
314
    log.warn('Creating %s', pth_file)
296
315
    f = open(pth_file, 'w')
299
318
    finally:
300
319
        f.close()
301
320
 
302
 
 
303
321
def _patch_egg_dir(path):
304
322
    # let's check if it's already patched
305
323
    pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')