Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce support for Python 2.6 to python_stub_template #11269

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import shutil
import subprocess
import tempfile
import zipfile
import collections

# Return True if running on Windows
def IsWindows():
Expand Down Expand Up @@ -264,7 +263,11 @@ https://github.com/bazelbuild/bazel/issues/7899 for more information.

def Deduplicate(items):
"""Efficiently filter out duplicates, keeping the first element only."""
return list(collections.OrderedDict((it, None) for it in items).keys())
seen = set()
for it in items:
if it not in seen:
seen.add(it)
yield it

def Main():
args = sys.argv[1:]
Expand All @@ -281,8 +284,10 @@ def Main():
python_path_entries += GetRepositoriesImports(module_space, %import_all%)
# Remove duplicates to avoid overly long PYTHONPATH (#10977). Preserve order,
# keep first occurrence only.
python_path_entries = Deduplicate(python_path_entries)
python_path_entries = [GetWindowsPathWithUNCPrefix(d) for d in python_path_entries]
python_path_entries = [
GetWindowsPathWithUNCPrefix(d)
for d in Deduplicate(python_path_entries)
]

old_python_path = os.environ.get('PYTHONPATH')
python_path = os.pathsep.join(python_path_entries)
Expand Down