~j5-dev/+junk/setuptools-0.6c11

« back to all changes in this revision

Viewing changes to setuptools/command/easy_install.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-09-25 10:40:35 UTC
  • mfrom: (1.1.10 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080925104035-4t3bfbs44064gp6u
Tags: 0.6c9-0ubuntu1
* New upstream version (bug fixes from the stable branch).
  - Adds subversion 1.5 compatibility. LP: #262636.

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
 
273
273
        if is_site_dir:
274
274
            if self.pth_file is None:
275
 
                self.pth_file = PthDistributions(pth_file)
 
275
                self.pth_file = PthDistributions(pth_file, self.all_site_dirs)
276
276
        else:
277
277
            self.pth_file = None
278
278
 
639
639
            setups = glob(os.path.join(setup_base, '*', 'setup.py'))
640
640
            if not setups:
641
641
                raise DistutilsError(
642
 
                    "Couldn't find a setup script in %s" % dist_filename
 
642
                    "Couldn't find a setup script in %s" % os.path.abspath(dist_filename)
643
643
                )
644
644
            if len(setups)>1:
645
645
                raise DistutilsError(
646
 
                    "Multiple setup scripts in %s" % dist_filename
 
646
                    "Multiple setup scripts in %s" % os.path.abspath(dist_filename)
647
647
                )
648
648
            setup_script = setups[0]
649
649
 
744
744
        native_libs = []
745
745
        top_level = {}
746
746
        def process(src,dst):
 
747
            s = src.lower()
747
748
            for old,new in prefixes:
748
 
                if src.startswith(old):
 
749
                if s.startswith(old):
749
750
                    src = new+src[len(old):]
750
751
                    parts = src.split('/')
751
752
                    dst = os.path.join(egg_tmp, *parts)
761
762
            if not src.endswith('.pth'):
762
763
                log.warn("WARNING: can't process %s", src)
763
764
            return None
764
 
 
765
765
        # extract, tracking .pyd/.dll->native_libs and .py -> to_compile
766
766
        unpack_archive(dist_filename, egg_tmp, process)
767
767
        stubs = []
1273
1273
    """Get exe->egg path translations for a given .exe file"""
1274
1274
 
1275
1275
    prefixes = [
1276
 
        ('PURELIB/', ''),
 
1276
        ('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''),
1277
1277
        ('PLATLIB/', ''),
1278
1278
        ('SCRIPTS/', 'EGG-INFO/scripts/')
1279
1279
    ]
1290
1290
                continue
1291
1291
            if name.endswith('-nspkg.pth'):
1292
1292
                continue
1293
 
            if parts[0] in ('PURELIB','PLATLIB'):
 
1293
            if parts[0].upper() in ('PURELIB','PLATLIB'):
1294
1294
                for pth in yield_lines(z.read(name)):
1295
1295
                    pth = pth.strip().replace('\\','/')
1296
1296
                    if not pth.startswith('import'):
1297
1297
                        prefixes.append((('%s/%s/' % (parts[0],pth)), ''))
1298
1298
    finally:
1299
1299
        z.close()
1300
 
 
 
1300
    prefixes = [(x.lower(),y) for x, y in prefixes]
1301
1301
    prefixes.sort(); prefixes.reverse()
1302
1302
    return prefixes
1303
1303
 
1315
1315
 
1316
1316
    dirty = False
1317
1317
 
1318
 
    def __init__(self, filename):
1319
 
        self.filename = filename
 
1318
    def __init__(self, filename, sitedirs=()):
 
1319
        self.filename = filename; self.sitedirs=map(normalize_path, sitedirs)
1320
1320
        self.basedir = normalize_path(os.path.dirname(self.filename))
1321
1321
        self._load(); Environment.__init__(self, [], None, None)
1322
1322
        for path in yield_lines(self.paths):
1325
1325
    def _load(self):
1326
1326
        self.paths = []
1327
1327
        saw_import = False
1328
 
        seen = {}
 
1328
        seen = dict.fromkeys(self.sitedirs)
1329
1329
        if os.path.isfile(self.filename):
1330
1330
            for line in open(self.filename,'rt'):
1331
1331
                if line.startswith('import'):
1381
1381
 
1382
1382
    def add(self,dist):
1383
1383
        """Add `dist` to the distribution map"""
1384
 
        if dist.location not in self.paths:
 
1384
        if dist.location not in self.paths and dist.location not in self.sitedirs:
1385
1385
            self.paths.append(dist.location); self.dirty = True
1386
1386
        Environment.add(self,dist)
1387
1387
 
1415
1415
    options = ''
1416
1416
    if match:
1417
1417
        options = match.group(1) or ''
1418
 
        if options:
1419
 
            options = ' '+options
 
1418
        if options: options = ' '+options
1420
1419
    if wininst:
1421
1420
        executable = "python.exe"
1422
1421
    else:
1430
1429
            # else: punt, we can't do it, let the warning happen anyway
1431
1430
        else:
1432
1431
            options = ' -x'
1433
 
        hdr = "#!%(executable)s%(options)s\n" % locals()
 
1432
    executable = fix_jython_executable(executable, options)
 
1433
    hdr = "#!%(executable)s%(options)s\n" % locals()
1434
1434
    return hdr
1435
1435
 
1436
1436
def auto_chmod(func, arg, exc):
1465
1465
    else:
1466
1466
        return True
1467
1467
 
1468
 
 
1469
 
 
1470
 
 
1471
 
 
1472
 
 
1473
 
 
1474
 
 
1475
 
 
 
1468
def is_sh(executable):
 
1469
    """Determine if the specified executable is a .sh (contains a #! line)"""
 
1470
    try:
 
1471
        fp = open(executable)
 
1472
        magic = fp.read(2)
 
1473
        fp.close()
 
1474
    except (OSError,IOError): return executable
 
1475
    return magic == '#!'
1476
1476
 
1477
1477
def nt_quote_arg(arg):
1478
1478
    """Quote a command line argument according to Windows parsing rules"""
1520
1520
    """
1521
1521
    if filename.endswith('.py') or filename.endswith('.pyw'):
1522
1522
        return True     # extension says it's Python
1523
 
 
1524
1523
    if is_python(script_text, filename):
1525
1524
        return True     # it's syntactically valid Python
1526
 
 
1527
1525
    if script_text.startswith('#!'):
1528
1526
        # It begins with a '#!' line, so check if 'python' is in it somewhere
1529
1527
        return 'python' in script_text.splitlines()[0].lower()
1543
1541
    except os.error, e:
1544
1542
        log.debug("chmod failed: %s", e)
1545
1543
 
1546
 
 
1547
 
 
1548
 
 
1549
 
 
1550
 
 
1551
 
 
1552
 
 
1553
 
 
1554
 
 
1555
 
 
1556
 
 
 
1544
def fix_jython_executable(executable, options):
 
1545
    if sys.platform.startswith('java') and is_sh(executable):
 
1546
        # Workaround Jython's sys.executable being a .sh (an invalid
 
1547
        # shebang line interpreter)
 
1548
        if options:
 
1549
            # Can't apply the workaround, leave it broken
 
1550
            log.warn("WARNING: Unable to adapt shebang line for Jython,"
 
1551
                             " the following script is NOT executable\n"
 
1552
                     "         see http://bugs.jython.org/issue1112 for"
 
1553
                             " more information.")
 
1554
        else:
 
1555
            return '/usr/bin/env %s' % executable
 
1556
    return executable
1557
1557
 
1558
1558
 
1559
1559
def get_script_args(dist, executable=sys_executable, wininst=False):