Bug 1764534: Maintain site_packages_dir order r=emilio

De-duping with `set` causes order to no longer be maintained when the
items are distinct. Use the `OrderedDict` technique to de-dupe
consistently instead.

Differential Revision: https://phabricator.services.mozilla.com/D143604
This commit is contained in:
Mitchell Hentges 2022-04-13 14:44:06 +00:00
parent 6ea9c3b12c
commit 34599d4f60

View File

@ -782,20 +782,17 @@ class PythonVirtualenv:
return os.path.join(normalized_venv_root, relative_path)
def site_packages_dirs(self):
return list(
filter(
None,
[
# On Windows, the top of the virtualenv is added to the sys.path.
self.prefix if sys.platform.startswith("win") else None,
# De-dupe with set literal in case purelib and platlib are identical
*{
self.resolve_sysconfig_packages_path("purelib"),
self.resolve_sysconfig_packages_path("platlib"),
},
],
)
)
dirs = []
if sys.platform.startswith("win"):
dirs.append(self.prefix)
purelib = self.resolve_sysconfig_packages_path("purelib")
platlib = self.resolve_sysconfig_packages_path("platlib")
dirs.append(purelib)
if platlib != purelib:
dirs.append(platlib)
return dirs
def pip_install_with_constraints(self, pip_args):
"""Create a pip constraints file or existing packages