-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Python-related cleanups #163566
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
base: main
Are you sure you want to change the base?
Python-related cleanups #163566
Conversation
Ensure that the nested native build uses the same python interpreter as the main build, in case the python that CMake detects first is not the python that the user has specified explicitly. Original fix by Anuj Mittal <anuj.mittal@intel.com>.
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clangd Author: Ross Burton (rossburton) ChangesEnsure that the nested native CMake build uses the same Python interpreter as the outer build. Unify python shebangs so that they use Patch is 69.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/163566.diff 185 Files Affected:
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
index 49a1b14932644..6158876d15f76 100755
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# =- run-find-all-symbols.py - Parallel find-all-symbols runner -*- python -*-=#
#
diff --git a/clang-tools-extra/clangd/test/remote-index/pipeline_helper.py b/clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
index afdac985221a7..c9432341d304a 100644
--- a/clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ b/clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# ===- pipeline_helper.py - Remote Index pipeline Helper *- python -------*--===#
#
diff --git a/clang/bindings/python/examples/cindex/cindex-dump.py b/clang/bindings/python/examples/cindex/cindex-dump.py
index 10c3e4ba2dba4..79d3441e87fad 100644
--- a/clang/bindings/python/examples/cindex/cindex-dump.py
+++ b/clang/bindings/python/examples/cindex/cindex-dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- cindex-dump.py - cindex/Python Source Dump -------------*- python -*--===#
#
diff --git a/clang/bindings/python/examples/cindex/cindex-includes.py b/clang/bindings/python/examples/cindex/cindex-includes.py
index 4e8bae19005cd..0b021f4554f59 100644
--- a/clang/bindings/python/examples/cindex/cindex-includes.py
+++ b/clang/bindings/python/examples/cindex/cindex-includes.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- cindex-includes.py - cindex/Python Inclusion Graph -----*- python -*--===#
#
diff --git a/clang/docs/tools/generate_formatted_state.py b/clang/docs/tools/generate_formatted_state.py
index 2de43dc383f55..f857320ada1b7 100755
--- a/clang/docs/tools/generate_formatted_state.py
+++ b/clang/docs/tools/generate_formatted_state.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# A tool to parse creates a document outlining how clang formatted the
# LLVM project is.
diff --git a/clang/test/Analysis/check-analyzer-fixit.py b/clang/test/Analysis/check-analyzer-fixit.py
index b616255de89b0..5c19461fd5d82 100644
--- a/clang/test/Analysis/check-analyzer-fixit.py
+++ b/clang/test/Analysis/check-analyzer-fixit.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# ===- check-analyzer-fixit.py - Static Analyzer test helper ---*- python -*-===#
#
diff --git a/clang/test/Analysis/csv2json.py b/clang/test/Analysis/csv2json.py
index 6e1aca9a51779..642610140153e 100644
--- a/clang/test/Analysis/csv2json.py
+++ b/clang/test/Analysis/csv2json.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# ===- csv2json.py - Static Analyzer test helper ---*- python -*-===#
#
diff --git a/clang/test/Driver/ftime-trace-sections.py b/clang/test/Driver/ftime-trace-sections.py
index 02afa4ac54eb7..46248e546d94a 100644
--- a/clang/test/Driver/ftime-trace-sections.py
+++ b/clang/test/Driver/ftime-trace-sections.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import json, sys, time
diff --git a/clang/tools/include-mapping/test.py b/clang/tools/include-mapping/test.py
index 81803855dac8f..7293b5a19d883 100755
--- a/clang/tools/include-mapping/test.py
+++ b/clang/tools/include-mapping/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- test.py - ---------------------------------------------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/clang/tools/scan-build/bin/set-xcode-analyzer b/clang/tools/scan-build/bin/set-xcode-analyzer
index 8e4a5794594a6..5d52c96c59052 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# [PR 11661] Note that we hardwire to /usr/bin/python because we
# want to the use the system version of Python on Mac OS X.
diff --git a/clang/tools/scan-view/bin/scan-view b/clang/tools/scan-view/bin/scan-view
index d01aebb4029a7..f3375804654d2 100755
--- a/clang/tools/scan-view/bin/scan-view
+++ b/clang/tools/scan-view/bin/scan-view
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import print_function
diff --git a/clang/tools/scan-view/share/Reporter.py b/clang/tools/scan-view/share/Reporter.py
index 21874b378687e..aa16a47524c8b 100644
--- a/clang/tools/scan-view/share/Reporter.py
+++ b/clang/tools/scan-view/share/Reporter.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Methods for reporting bugs."""
diff --git a/clang/tools/scan-view/share/startfile.py b/clang/tools/scan-view/share/startfile.py
index c72475e8b6212..a10df214d0046 100644
--- a/clang/tools/scan-view/share/startfile.py
+++ b/clang/tools/scan-view/share/startfile.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Utility for opening a file using the default application in a cross-platform
diff --git a/clang/utils/ABITest/ABITestGen.py b/clang/utils/ABITest/ABITestGen.py
index 119b3299ffa60..b04cc3d29d8d8 100755
--- a/clang/utils/ABITest/ABITestGen.py
+++ b/clang/utils/ABITest/ABITestGen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function
from pprint import pprint
diff --git a/clang/utils/CIndex/completion_logger_server.py b/clang/utils/CIndex/completion_logger_server.py
index ff33331fc53c5..5888fb10fc768 100755
--- a/clang/utils/CIndex/completion_logger_server.py
+++ b/clang/utils/CIndex/completion_logger_server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function
import sys
from socket import *
diff --git a/clang/utils/CaptureCmd b/clang/utils/CaptureCmd
index 705585c3bb041..5ffdfe560edf0 100755
--- a/clang/utils/CaptureCmd
+++ b/clang/utils/CaptureCmd
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""CaptureCmd - A generic tool for capturing information about the
invocations of another program.
diff --git a/clang/utils/CmpDriver b/clang/utils/CmpDriver
index 12ce7a3250f66..c2b6ab5ecb1aa 100755
--- a/clang/utils/CmpDriver
+++ b/clang/utils/CmpDriver
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
A simple utility that compares tool invocations and exit codes issued by
diff --git a/clang/utils/FindSpecRefs b/clang/utils/FindSpecRefs
index 9097f93f28d63..3ad581b3dd7d1 100755
--- a/clang/utils/FindSpecRefs
+++ b/clang/utils/FindSpecRefs
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import os
import re
diff --git a/clang/utils/FuzzTest b/clang/utils/FuzzTest
index 0e043df7cf08e..c4c956b6eb501 100755
--- a/clang/utils/FuzzTest
+++ b/clang/utils/FuzzTest
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
This is a generic fuzz testing tool, see --help for more information.
diff --git a/clang/utils/TestUtils/deep-stack.py b/clang/utils/TestUtils/deep-stack.py
index 4cf5789abdb12..85376dcedc280 100755
--- a/clang/utils/TestUtils/deep-stack.py
+++ b/clang/utils/TestUtils/deep-stack.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function
diff --git a/clang/utils/analyzer/CmpRuns.py b/clang/utils/analyzer/CmpRuns.py
index 94c9907bff315..76444d2a44580 100644
--- a/clang/utils/analyzer/CmpRuns.py
+++ b/clang/utils/analyzer/CmpRuns.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
CmpRuns - A simple tool for comparing two static analyzer runs to determine
diff --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index d70e33f24c2df..8b07effd8b83b 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import sys
diff --git a/clang/utils/analyzer/SATestAdd.py b/clang/utils/analyzer/SATestAdd.py
index 84e6d44b42822..05bebabb3601b 100644
--- a/clang/utils/analyzer/SATestAdd.py
+++ b/clang/utils/analyzer/SATestAdd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Static Analyzer qualification infrastructure: adding a new project to
diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index 66e1ab72985cd..ff1a42de2c569 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Static Analyzer qualification infrastructure.
diff --git a/clang/utils/analyzer/SATestUpdateDiffs.py b/clang/utils/analyzer/SATestUpdateDiffs.py
index 1c5ffaaa2e330..e1416510d0178 100644
--- a/clang/utils/analyzer/SATestUpdateDiffs.py
+++ b/clang/utils/analyzer/SATestUpdateDiffs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Update reference results for static analyzer.
diff --git a/clang/utils/analyzer/SumTimerInfo.py b/clang/utils/analyzer/SumTimerInfo.py
index 01614e41a065c..9772bff335f4b 100644
--- a/clang/utils/analyzer/SumTimerInfo.py
+++ b/clang/utils/analyzer/SumTimerInfo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Script to Summarize statistics in the scan-build output.
diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index dcda91e8a6809..9198fcbfd184e 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# ===- exploded-graph-rewriter.py - ExplodedGraph dump tool -----*- python -*--#
#
diff --git a/clang/utils/check_cfc/check_cfc.py b/clang/utils/check_cfc/check_cfc.py
index 8d42ec532bbb7..6b793937a5d08 100755
--- a/clang/utils/check_cfc/check_cfc.py
+++ b/clang/utils/check_cfc/check_cfc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Check CFC - Check Compile Flow Consistency
diff --git a/clang/utils/check_cfc/obj_diff.py b/clang/utils/check_cfc/obj_diff.py
index 9d602593a4e1a..02e0ebdf0efcd 100755
--- a/clang/utils/check_cfc/obj_diff.py
+++ b/clang/utils/check_cfc/obj_diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function
diff --git a/clang/utils/check_cfc/test_check_cfc.py b/clang/utils/check_cfc/test_check_cfc.py
index cd4441b702cde..a23ad2ccbee41 100755
--- a/clang/utils/check_cfc/test_check_cfc.py
+++ b/clang/utils/check_cfc/test_check_cfc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Test internal functions within check_cfc.py."""
diff --git a/clang/utils/clangdiag.py b/clang/utils/clangdiag.py
index 8c47b1cbcfff3..e4b94e5757cbc 100755
--- a/clang/utils/clangdiag.py
+++ b/clang/utils/clangdiag.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ----------------------------------------------------------------------
# Be sure to add the python path that points to the LLDB shared library.
diff --git a/clang/utils/modfuzz.py b/clang/utils/modfuzz.py
index 49ac522cd17e1..7c00102c2cca5 100644
--- a/clang/utils/modfuzz.py
+++ b/clang/utils/modfuzz.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# To use:
# 1) Update the 'decls' list below with your fuzzing configuration.
diff --git a/clang/utils/token-delta.py b/clang/utils/token-delta.py
index 7c2375c03013f..4fe5798033f41 100755
--- a/clang/utils/token-delta.py
+++ b/clang/utils/token-delta.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import absolute_import, division, print_function
import os
diff --git a/clang/www/builtins.py b/clang/www/builtins.py
index 849e6bd4a816d..235de1a157cd1 100755
--- a/clang/www/builtins.py
+++ b/clang/www/builtins.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import sys, fileinput
diff --git a/compiler-rt/lib/asan/scripts/asan_symbolize.py b/compiler-rt/lib/asan/scripts/asan_symbolize.py
index 8ecd66c745119..f60a8307ec60e 100755
--- a/compiler-rt/lib/asan/scripts/asan_symbolize.py
+++ b/compiler-rt/lib/asan/scripts/asan_symbolize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- lib/asan/scripts/asan_symbolize.py -----------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/compiler-rt/lib/fuzzer/scripts/unbalanced_allocs.py b/compiler-rt/lib/fuzzer/scripts/unbalanced_allocs.py
index 7ba7e09cb4e50..c8c19a017eb3f 100755
--- a/compiler-rt/lib/fuzzer/scripts/unbalanced_allocs.py
+++ b/compiler-rt/lib/fuzzer/scripts/unbalanced_allocs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- lib/fuzzer/scripts/unbalanced_allocs.py ------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py b/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
index fdbceae165e0d..e4b33e6637b0e 100755
--- a/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
+++ b/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===- lib/sanitizer_common/scripts/gen_dynamic_list.py ---------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/compiler-rt/lib/sanitizer_common/scripts/sancov.py b/compiler-rt/lib/sanitizer_common/scripts/sancov.py
index 31055086350ab..06906aabf18e8 100755
--- a/compiler-rt/lib/sanitizer_common/scripts/sancov.py
+++ b/compiler-rt/lib/sanitizer_common/scripts/sancov.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Merge or print the coverage data collected by asan's coverage.
# Input files are sequences of 4-byte integers.
# We need to merge these integers into a set and then
diff --git a/cross-project-tests/debuginfo-tests/dexter/dexter.py b/cross-project-tests/debuginfo-tests/dexter/dexter.py
index 8473cff3c7135..ac507dc2f5ee0 100755
--- a/cross-project-tests/debuginfo-tests/dexter/dexter.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dexter.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# DExTer : Debugging Experience Tester
# ~~~~~~ ~ ~~ ~ ~~
#
diff --git a/libc/AOR_v20.02/math/tools/plot.py b/libc/AOR_v20.02/math/tools/plot.py
index 9ce6b0308dd57..4bbd866993c89 100755
--- a/libc/AOR_v20.02/math/tools/plot.py
+++ b/libc/AOR_v20.02/math/tools/plot.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ULP error plot tool.
#
diff --git a/libc/utils/docgen/docgen.py b/libc/utils/docgen/docgen.py
index 5a57987b3c51e..59cfbd54561c7 100755
--- a/libc/utils/docgen/docgen.py
+++ b/libc/utils/docgen/docgen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# ====- Generate documentation for libc functions ------------*- python -*--==#
#
diff --git a/libcxx/test/libcxx-03/transitive_includes/to_csv.py b/libcxx/test/libcxx-03/transitive_includes/to_csv.py
index 69d94deedf6f5..658aa6e657632 100755
--- a/libcxx/test/libcxx-03/transitive_includes/to_csv.py
+++ b/libcxx/test/libcxx-03/transitive_includes/to_csv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/test/libcxx/transitive_includes/to_csv.py b/libcxx/test/libcxx/transitive_includes/to_csv.py
index 69d94deedf6f5..658aa6e657632 100755
--- a/libcxx/test/libcxx/transitive_includes/to_csv.py
+++ b/libcxx/test/libcxx/transitive_includes/to_csv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_abi_list.py b/libcxx/utils/generate_abi_list.py
index 94e49dca60af1..5e99b14bec72e 100755
--- a/libcxx/utils/generate_abi_list.py
+++ b/libcxx/utils/generate_abi_list.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_escaped_output_table.py b/libcxx/utils/generate_escaped_output_table.py
index 59dd707ae6126..6be7d128ed5f1 100755
--- a/libcxx/utils/generate_escaped_output_table.py
+++ b/libcxx/utils/generate_escaped_output_table.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_extended_grapheme_cluster_table.py b/libcxx/utils/generate_extended_grapheme_cluster_table.py
index eba88a4f48776..7bfb4f41520c7 100755
--- a/libcxx/utils/generate_extended_grapheme_cluster_table.py
+++ b/libcxx/utils/generate_extended_grapheme_cluster_table.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_extended_grapheme_cluster_test.py b/libcxx/utils/generate_extended_grapheme_cluster_test.py
index e0a6003ecd53c..29a3e14014e8d 100755
--- a/libcxx/utils/generate_extended_grapheme_cluster_test.py
+++ b/libcxx/utils/generate_extended_grapheme_cluster_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index f6f252751b3e3..5c9893bf2c742 100644
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import os
from builtins import range
diff --git a/libcxx/utils/generate_indic_conjunct_break_table.py b/libcxx/utils/generate_indic_conjunct_break_table.py
index 580d8157ffebf..4ecb9a135948b 100755
--- a/libcxx/utils/generate_indic_conjunct_break_table.py
+++ b/libcxx/utils/generate_indic_conjunct_break_table.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py
index ab3e3f14e14d8..35da70f62f264 100644
--- a/libcxx/utils/generate_iwyu_mapping.py
+++ b/libcxx/utils/generate_iwyu_mapping.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import libcxx.header_information
diff --git a/libcxx/utils/generate_width_estimation_table.py b/libcxx/utils/generate_width_estimation_table.py
index f81f0ba77489e..3f41ce1657bdd 100644
--- a/libcxx/utils/generate_width_estimation_table.py
+++ b/libcxx/utils/generate_width_estimation_table.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
diff --git a/libcxx/utils/run.py b/libcxx/utils/run.py
index 6b4d615444bcf..b97e1edf05a91 100755
--- a/libcxx/utils/run.py
+++ b/libcxx/utils/run.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# ===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 wit...
[truncated]
|
I'm not clear on the specific purpose here:
Is the first implemented by doing the second? Or are you doing 2 things here? (with so many files I might have missed something) We might be ok with a mass replace of python -> python3 generally, but if you know which specific files fix your use case, I'd prefer to see those in their own PR. So we have a better attribution of problems fixed (or created, as it may be) by each change. Or you can reframe this as "llvm requires python of at least 3, plenty of scripts use python3 already, let's make it consistent". Which is a good pitch that doesn't need the context of your use case. If there is a mass conversion of python shebangs earlier in the git history, you can cite that as precedent. We probably did for some subset of scripts back when we moved to requiring >= 3. Sometimes we will accept changes like this as is, sometimes they need to be broken up. Depends on the sub-projects' attitude to the changes. It can also take a lot of time to get every single part approved. FWIW if you broke out the LLDB changes I'd accept them as is. |
And this broke the Python formatter, as in, it failed to parse some code at all. Probably one of the infrequently changed projects like Polly has some strange code in it that we've never tried to format. Point is - we know this isn't changing actual Python code so ignore it. |
As per PEP-0394[1], there is no real concensus over what binary names Python has, specifically 'python' could be Python 3, Python 2, or not exist. However, everyone has a python3 interpreter and the scripts are all written for Python 3. Unify the shebangs so that the ~50% of shebangs that use python now use python3. [1] https://peps.python.org/pep-0394/
The scripts in polly/utils use Python 2 syntax (notable, print is a statement not a function), so change the interpeter to be python2 as they will not run under python3.
The PYTHON_EXECUTABLE and the shebang cleanups are entirely unrelated except by theme, I can split them it that would make things easier. The use-case was "a few scripts are using Apart from a few which the formatter exploded on and are actually python2 scripts, so the current shebang wouldn't work as for ~everyone who has |
Relevant PEP: https://peps.python.org/pep-0394/ To quote: So I'm not sure the shebang for venvs should be changed to python3. Moreover, this may have pretty big implications since the implementation of these commands 8s very inconsistent across platforms and no common rules seem to exist. |
Yes, this makes sense. I tried "vermin" on it and it reports the same lines as not being python3 compatible. You can exclude the Polly changes.
Yes please. Even if it doesn't fix your use case in itself, if it's explainable on its own, we can review it as is. |
My point exactly: the bulk of these scripts are python3 scripts, so we can be precise. I'm unaware of any real systems where there is no python3 binary. If this code wanted to handle systems where there is only a |
The cmake/python/native commit has been split out to #163574. |
I thought there was a rule but you're right, it does not seem consistent. The PEP you linked has advice for everything but Linux - https://peps.python.org/pep-0394/#for-python-script-publishers. That points us towards For Windows https://peps.python.org/pep-0397/#shebang-line-parsing only mentions There is also this previous thread https://discourse.llvm.org/t/python-vs-python3-shebang/58117/1. The highlights of which are "Windows might want python" and "make the installer rewrite the shebang lines". Which is a much more involved change. The mix we have right now is clearly working for someone, so the onus is on the person changing it to justify it, probably with an RFC on Discourse. I doubt that @rossburton was expecting to sign up for that :) Ross I don't intend to put up a wall here, but without doing more work, I don't see a single recommendation here (and unfortunately don't have time to look into it myself). That said, if changing a handful of these files would unbreak your use cases, we can consider changing those specific files. |
Can we split this up into the different subprojects? |
Do you mean one PR with a commit per subproject, or a PR per subproject? |
Ensure that the nested native CMake build uses the same Python interpreter as the outer build.
Unify python shebangs so that they use
python3
everywhere, instead of a mix ofpython
andpython3
.