From dd1d41aa45ac253b78cc94f0cb29158cd295a9e7 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Mon, 4 Feb 2013 09:34:03 -0800 Subject: [PATCH] Bug 837631 - Part 2: Unbust virtualenv on Debians; r=glandium This is a cherry-pick of Git commit 813fc02af8723421eeeadcb13eb361e2e44416ca from the Virtualenv repo. It fixes https://github.com/pypa/virtualenv/issues/378. --- python/virtualenv/virtualenv_embedded/site.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/virtualenv/virtualenv_embedded/site.py b/python/virtualenv/virtualenv_embedded/site.py index 4271f43905c4..a12458659f2a 100644 --- a/python/virtualenv/virtualenv_embedded/site.py +++ b/python/virtualenv/virtualenv_embedded/site.py @@ -584,9 +584,19 @@ def virtual_install_main_packages(): paths.insert(0, lib64_path) else: paths.append(lib64_path) - # This is hardcoded in the Python executable, but relative to sys.prefix: - plat_path = os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3], - 'plat-%s' % sys.platform) + # This is hardcoded in the Python executable, but relative to + # sys.prefix. Debian change: we need to add the multiarch triplet + # here, which is where the real stuff lives. As per PEP 421, in + # Python 3.3+, this lives in sys.implementation, while in Python 2.7 + # it lives in sys. + try: + arch = getattr(sys, 'implementation', sys)._multiarch + except AttributeError: + # This is a non-multiarch aware Python. Fallback to the old way. + arch = sys.platform + plat_path = os.path.join(sys.real_prefix, 'lib', + 'python'+sys.version[:3], + 'plat-%s' % arch) if os.path.exists(plat_path): paths.append(plat_path) # This is hardcoded in the Python executable, but