Skip to content

Commit

Permalink
Bug 1739486 - Hack around pypa/virtualenv#2208. r=mhentges
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emilio committed Nov 5, 2021
1 parent fb350c6 commit 4963e6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/mach/mach/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 3 additions & 0 deletions third_party/python/virtualenv/virtualenv/discovery/py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4963e6b

Please sign in to comment.