From 72576398070ec6772a1cf8dcf13a3ac8f9fd6a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 5 Nov 2021 15:41:55 +0000 Subject: [PATCH] Bug 1739486 - Hack around https://github.com/pypa/virtualenv/issues/2208. r=mhentges The virutalenv hack is in the fedora-distributed version of virtualenv... Presumably eventually will become unnecessary once they provide a proper "venv" distutils? This patch applies both before and after the bump in comment 5, so your call. Differential Revision: https://phabricator.services.mozilla.com/D130410 --- python/mach/mach/virtualenv.py | 11 +++++++++-- .../python/virtualenv/virtualenv/discovery/py_info.py | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/python/mach/mach/virtualenv.py b/python/mach/mach/virtualenv.py index 8ad24a29a7755..36d35ac02de4f 100644 --- a/python/mach/mach/virtualenv.py +++ b/python/mach/mach/virtualenv.py @@ -416,13 +416,20 @@ def _site_packages_dir(self): # because it's needed by the "virtualenv" package. from distutils import dist + normalized_venv_root = os.path.normpath(self.virtualenv_root) + distribution = dist.Distribution({"script_args": "--no-user-cfg"}) installer = distribution.get_command_obj("install") - installer.prefix = os.path.normpath(self.virtualenv_root) + installer.prefix = normalized_venv_root installer.finalize_options() # Path to virtualenv's "site-packages" directory - return installer.install_purelib + path = installer.install_purelib + local_folder = os.path.join(normalized_venv_root, "local") + # Hack around https://github.com/pypa/virtualenv/issues/2208 + if path.startswith(local_folder): + path = os.path.join(normalized_venv_root, path[len(local_folder) + 1 :]) + return path def get_archflags(): diff --git a/third_party/python/virtualenv/virtualenv/discovery/py_info.py b/third_party/python/virtualenv/virtualenv/discovery/py_info.py index 0de612814524b..006df83e818a2 100644 --- a/third_party/python/virtualenv/virtualenv/discovery/py_info.py +++ b/third_party/python/virtualenv/virtualenv/discovery/py_info.py @@ -124,6 +124,9 @@ def install_path(self, key): prefixes = self.prefix, self.exec_prefix, self.base_prefix, self.base_exec_prefix config_var = {k: "" if v in prefixes else v for k, v in self.sysconfig_vars.items()} result = self.sysconfig_path(key, config_var=config_var).lstrip(os.sep) + # A hack for https://github.com/pypa/virtualenv/issues/2208 + if result.startswith(u"local/"): + return result[6:] return result @staticmethod