Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 436274 | Differences between
and this patch

Collapse All | Expand All

(-)a/virtualenv.py (-14 / +50 lines)
Lines 1157-1163 def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy Link Here
1157
    else:
1157
    else:
1158
        prefix = sys.prefix
1158
        prefix = sys.prefix
1159
    mkdir(lib_dir)
1159
    mkdir(lib_dir)
1160
    fix_lib64(lib_dir, symlink)
1160
1161
    # Account for libdir of explicit bitness.
1162
    is_bitness_explicit, libdir_bitness = fix_libdir_bitness(lib_dir, symlink)
1163
1161
    stdlib_dirs = [os.path.dirname(os.__file__)]
1164
    stdlib_dirs = [os.path.dirname(os.__file__)]
1162
    if is_win:
1165
    if is_win:
1163
        stdlib_dirs.append(join(os.path.dirname(stdlib_dirs[0]), 'DLLs'))
1166
        stdlib_dirs.append(join(os.path.dirname(stdlib_dirs[0]), 'DLLs'))
Lines 1192-1197 def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy Link Here
1192
    site_dir = os.path.dirname(site_filename_dst)
1195
    site_dir = os.path.dirname(site_filename_dst)
1193
    writefile(site_filename_dst, SITE_PY)
1196
    writefile(site_filename_dst, SITE_PY)
1194
    writefile(join(site_dir, 'orig-prefix.txt'), prefix)
1197
    writefile(join(site_dir, 'orig-prefix.txt'), prefix)
1198
1199
    # We need to record the bitness of original libdir, or the virtualenv
1200
    # site.py will not be able to insert the correct system package paths.
1201
    # Assuming that the simplicity of orig-prefix.txt may be relied upon by
1202
    # external programs, we have to write a new file here.
1203
    if is_bitness_explicit:
1204
        writefile(join(site_dir, 'libdir-bitness.txt'), libdir_bitness)
1205
1195
    site_packages_filename = join(site_dir, 'no-global-site-packages.txt')
1206
    site_packages_filename = join(site_dir, 'no-global-site-packages.txt')
1196
    if not site_packages:
1207
    if not site_packages:
1197
        writefile(site_packages_filename, '')
1208
        writefile(site_packages_filename, '')
Lines 1549-1584 def fix_local_scheme(home_dir, symlink=True): Link Here
1549
                    copyfile(os.path.abspath(os.path.join(home_dir, subdir_name)), \
1560
                    copyfile(os.path.abspath(os.path.join(home_dir, subdir_name)), \
1550
                                                            os.path.join(local_path, subdir_name), symlink)
1561
                                                            os.path.join(local_path, subdir_name), symlink)
1551
1562
1552
def fix_lib64(lib_dir, symlink=True):
1563
def fix_libdir_bitness(lib_dir, symlink=True):
1553
    """
1564
    """
1554
    Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y
1565
    Some platforms (such as Gentoo on x64 or on MIPS ABI n32/n64) put things
1555
    instead of lib/pythonX.Y.  If this is such a platform we'll just create a
1566
    in lib{64,32}/pythonX.Y instead of lib/pythonX.Y.  If this is such a
1556
    symlink so lib64 points to lib
1567
    platform we'll just create a symlink so libXX points to lib.
1557
    """
1568
    """
1569
1570
    # Common bitnesses.
1571
    for bitness in '64', '32', 'x32':
1572
        if _do_fix_libdir_bitness(lib_dir, symlink, bitness):
1573
            return True, bitness
1574
1575
    return False, None
1576
1577
def _do_fix_libdir_bitness(lib_dir, symlink, bitness):
1578
    target_dirname = 'lib' + bitness
1579
    logger.debug("Trying to symlink libdir '%s' to lib" % (target_dirname, ))
1580
1558
    if [p for p in distutils.sysconfig.get_config_vars().values()
1581
    if [p for p in distutils.sysconfig.get_config_vars().values()
1559
        if isinstance(p, basestring) and 'lib64' in p]:
1582
        if isinstance(p, basestring) and target_dirname in p]:
1560
        # PyPy's library path scheme is not affected by this.
1583
        # PyPy's library path scheme is not affected by this.
1561
        # Return early or we will die on the following assert.
1584
        # Return early or we will die on the following assert.
1585
        # Pretend we have succeeded and report the correct bitness back,
1586
        # because later on the bitness information is still needed by site.py
1587
        # inside the virtualenv, to find the correct system package path.
1562
        if is_pypy:
1588
        if is_pypy:
1563
            logger.debug('PyPy detected, skipping lib64 symlinking')
1589
            logger.debug('PyPy detected, skipping %s symlinking' % (target_dirname, ))
1564
            return
1590
            return True
1565
1591
1566
        logger.debug('This system uses lib64; symlinking lib64 to lib')
1592
        logger.debug('This system uses %s; symlinking %s to lib' % (
1593
            target_dirname,
1594
            target_dirname,
1595
        ))
1567
1596
1568
        assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], (
1597
        assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], (
1569
            "Unexpected python lib dir: %r" % lib_dir)
1598
            "Unexpected python lib dir: %r" % lib_dir)
1570
        lib_parent = os.path.dirname(lib_dir)
1599
        lib_parent = os.path.dirname(lib_dir)
1571
        top_level = os.path.dirname(lib_parent)
1600
        top_level = os.path.dirname(lib_parent)
1572
        lib_dir = os.path.join(top_level, 'lib')
1601
        lib_dir = os.path.join(top_level, 'lib')
1573
        lib64_link = os.path.join(top_level, 'lib64')
1602
        target_lib_link = os.path.join(top_level, target_dirname)
1574
        assert os.path.basename(lib_parent) == 'lib', (
1603
        assert os.path.basename(lib_parent) == 'lib', (
1575
            "Unexpected parent dir: %r" % lib_parent)
1604
            "Unexpected parent dir: %r" % lib_parent)
1576
        if os.path.lexists(lib64_link):
1605
        if os.path.lexists(target_lib_link):
1577
            return
1606
            return True
1578
        if symlink:
1607
        if symlink:
1579
            os.symlink('lib', lib64_link)
1608
            os.symlink('lib', target_lib_link)
1580
        else:
1609
        else:
1581
            copyfile('lib', lib64_link)
1610
            copyfile('lib', target_lib_link)
1611
    # Seems not affected, continue checking
1612
    return False
1582
1613
1583
def resolve_interpreter(exe):
1614
def resolve_interpreter(exe):
1584
    """
1615
    """
Lines 1999-2004 n6kJTcsp4tG42yeT7nQbtdUFwgVJjwDSUYEAC8F0dKOTILrlLO/xC70bnNd0Ha97whQ6UkHJYj5H Link Here
1999
cA/j+zX4tbtTIfGjujOKpj83aHOgXnIQbvYduNXEC4UMm4T21Bs+GHABuCa7v//LR/TvpjHa7oe7
2030
cA/j+zX4tbtTIfGjujOKpj83aHOgXnIQbvYduNXEC4UMm4T21Bs+GHABuCa7v//LR/TvpjHa7oe7
2000
/Grb6lVvHSD7spj5iplBLRKZxxEYGdCbY9LWWC5hBB2voWno6DJUMzfkC3T8KJsWL9umDQY5szPt
2031
/Grb6lVvHSD7spj5iplBLRKZxxEYGdCbY9LWWC5hBB2voWno6DJUMzfkC3T8KJsWL9umDQY5szPt
2001
AVijEPwfucjncQ==
2032
AVijEPwfucjncQ==
2033
CDKnFwi6c88xITGnRQVv4Ovd1ctjc8CH/I6vLUFC2Z0jyzy7srKjd97zanUnZimmlD6LHrd1LKNa
2034
XFtQ2bIb8lA7JWIDXqzOO2JII+d9f26p7uH8bxijNqaG9Y5hSmL8rJzQtKyiOoW7eTLpTrcRW10g
2035
XCD4CCAdEQiwEExHNloJ21uuuhi/UMbNvKYbsu1TXt/aFZS86XIE99AWfINfuzsV9j+qO6Oo+3OD
2036
NgeqJYfNzTYFt7JoslMltKfe8MGAacB3JPT3f/mI/t2zHNP9cJd3ZFod9dblskeCmeiYqdcikX4c
2037
gJIBuTkmaY3lS3qj47VQDR1thmrmhnyBBiFlt+P99+Qmksk7UxaAUQre/wFK8wT0
2002
""")
2038
""")
2003
2039
2004
##file activate.sh
2040
##file activate.sh
(-)a/virtualenv_embedded/site.py (-18 / +38 lines)
Lines 206-212 def addsitedir(sitedir, known_paths=None): Link Here
206
        known_paths = None
206
        known_paths = None
207
    return known_paths
207
    return known_paths
208
208
209
def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix):
209
def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix, bitness=None):
210
    """Add site-packages (and possibly site-python) to sys.path"""
210
    """Add site-packages (and possibly site-python) to sys.path"""
211
    prefixes = [os.path.join(sys_prefix, "local"), sys_prefix]
211
    prefixes = [os.path.join(sys_prefix, "local"), sys_prefix]
212
    if exec_prefix != sys_prefix:
212
    if exec_prefix != sys_prefix:
Lines 236-248 def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre Link Here
236
                                         "site-packages"),
236
                                         "site-packages"),
237
                            os.path.join(prefix, "lib", "site-python"),
237
                            os.path.join(prefix, "lib", "site-python"),
238
                            os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")]
238
                            os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")]
239
                lib64_dir = os.path.join(prefix, "lib64", "python" + sys.version[:3], "site-packages")
239
240
                if (os.path.exists(lib64_dir) and
240
                if bitness is not None:
241
                    os.path.realpath(lib64_dir) not in [os.path.realpath(p) for p in sitedirs]):
241
                    libXX = "lib" + bitness
242
                    if _is_64bit:
242
                    libXX_dir = os.path.join(prefix, libXX, "python" + sys.version[:3], "site-packages")
243
                        sitedirs.insert(0, lib64_dir)
243
                    if (os.path.exists(libXX_dir) and
244
                    else:
244
                        os.path.realpath(libXX_dir) not in [os.path.realpath(p) for p in sitedirs]):
245
                        sitedirs.append(lib64_dir)
245
                            sitedirs.insert(0, libXX_dir)
246
246
                try:
247
                try:
247
                    # sys.getobjects only available in --with-pydebug build
248
                    # sys.getobjects only available in --with-pydebug build
248
                    sys.getobjects
249
                    sys.getobjects
Lines 549-555 def execsitecustomize(): Link Here
549
    except ImportError:
550
    except ImportError:
550
        pass
551
        pass
551
552
552
def virtual_install_main_packages():
553
def virtual_install_main_packages(bitness=None):
553
    f = open(os.path.join(os.path.dirname(__file__), 'orig-prefix.txt'))
554
    f = open(os.path.join(os.path.dirname(__file__), 'orig-prefix.txt'))
554
    sys.real_prefix = f.read().strip()
555
    sys.real_prefix = f.read().strip()
555
    f.close()
556
    f.close()
Lines 583-594 def virtual_install_main_packages(): Link Here
583
    else:
584
    else:
584
        paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])]
585
        paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])]
585
        hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
586
        hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
586
        lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python'+sys.version[:3])
587
587
        if os.path.exists(lib64_path):
588
        if bitness is not None:
588
            if _is_64bit:
589
            libXX = 'lib' + bitness
589
                paths.insert(0, lib64_path)
590
            libXX_path = os.path.join(sys.real_prefix, libXX, 'python'+sys.version[:3])
590
            else:
591
            if os.path.exists(libXX_path):
591
                paths.append(lib64_path)
592
                # Originally the code here checked if the current system is 64-bit,
593
                # and chose to append the path instead of prepending if the system
594
                # turns out to be 32-bit.
595
                # Unfortunately this will fail on some multilib MIPS systems with
596
                # N32 as default ABI, where /usr/lib32 is the expected libdir and
597
                # /usr/lib for O32.
598
                # We'd rather be safe here...
599
                paths.insert(0, libXX_path)
600
592
        # This is hardcoded in the Python executable, but relative to
601
        # This is hardcoded in the Python executable, but relative to
593
        # sys.prefix.  Debian change: we need to add the multiarch triplet
602
        # sys.prefix.  Debian change: we need to add the multiarch triplet
594
        # here, which is where the real stuff lives.  As per PEP 421, in
603
        # here, which is where the real stuff lives.  As per PEP 421, in
Lines 667-673 def execusercustomize(): Link Here
667
676
668
def main():
677
def main():
669
    global ENABLE_USER_SITE
678
    global ENABLE_USER_SITE
670
    virtual_install_main_packages()
679
680
    # Account for system libdirs of explicit bitness.
681
    libdir_bitness = None
682
    bitness_file = os.path.join(os.path.dirname(__file__), 'libdir-bitness.txt')
683
    if os.path.exists(bitness_file):
684
        # Read the bitness recorded on virtualenv creation.
685
        bitness_fp = open(bitness_file)
686
        try:
687
            libdir_bitness = bitness_fp.read().strip()
688
        finally:
689
            bitness_fp.close()
690
691
    virtual_install_main_packages(libdir_bitness)
671
    abs__file__()
692
    abs__file__()
672
    paths_in_sys = removeduppaths()
693
    paths_in_sys = removeduppaths()
673
    if (os.name == "posix" and sys.path and
694
    if (os.name == "posix" and sys.path and
Lines 680-686 def main(): Link Here
680
        ENABLE_USER_SITE = False
701
        ENABLE_USER_SITE = False
681
    if ENABLE_USER_SITE is None:
702
    if ENABLE_USER_SITE is None:
682
        ENABLE_USER_SITE = check_enableusersite()
703
        ENABLE_USER_SITE = check_enableusersite()
683
    paths_in_sys = addsitepackages(paths_in_sys)
704
    paths_in_sys = addsitepackages(paths_in_sys, bitness=libdir_bitness)
684
    paths_in_sys = addusersitepackages(paths_in_sys)
705
    paths_in_sys = addusersitepackages(paths_in_sys)
685
    if GLOBAL_SITE_PACKAGES:
706
    if GLOBAL_SITE_PACKAGES:
686
        paths_in_sys = virtual_addsitepackages(paths_in_sys)
707
        paths_in_sys = virtual_addsitepackages(paths_in_sys)
687
- 

Return to bug 436274