[llvm] 0ff3cc2 - [gn build] Change python run lines to python3
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 23 13:42:31 PDT 2022
Author: Nico Weber
Date: 2022-03-23T16:42:18-04:00
New Revision: 0ff3cc2087b9aa74f6ad7a744bf3f62e4d3ec9d6
URL: https://github.com/llvm/llvm-project/commit/0ff3cc2087b9aa74f6ad7a744bf3f62e4d3ec9d6
DIFF: https://github.com/llvm/llvm-project/commit/0ff3cc2087b9aa74f6ad7a744bf3f62e4d3ec9d6.diff
LOG: [gn build] Change python run lines to python3
macOS 12.3 no longer ships non-3 python.
Almost all of these scripts were launched by ninja, and the GN files
already told it to run them under python3, so this is a fairly small
change. The main effect is that if you run them manually, you now
get the same behavior.
(A small set of scripts, gn.py, gen.py, sync_source_lists_from_cmake.py,
are for manual running. For these, it is an actual change.)
Differential Revision: https://reviews.llvm.org/D122345
Added:
Modified:
llvm/utils/gn/build/run_tablegen.py
llvm/utils/gn/build/symbol_exports.py
llvm/utils/gn/build/symlink_or_copy.py
llvm/utils/gn/build/sync_source_lists_from_cmake.py
llvm/utils/gn/build/write_cmake_config.py
llvm/utils/gn/build/write_library_dependencies.py
llvm/utils/gn/build/write_vcsrevision.py
llvm/utils/gn/get.py
llvm/utils/gn/gn.py
llvm/utils/gn/secondary/libcxx/utils/gen_link_script.py
llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py
llvm/utils/gn/secondary/llvm/tools/llvm-config/write_extension_dependencies.py
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/run_tablegen.py b/llvm/utils/gn/build/run_tablegen.py
index c7694236be55f..71476d24273b9 100755
--- a/llvm/utils/gn/build/run_tablegen.py
+++ b/llvm/utils/gn/build/run_tablegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Runs tablegen."""
import subprocess
diff --git a/llvm/utils/gn/build/symbol_exports.py b/llvm/utils/gn/build/symbol_exports.py
index 198eb057ccc0f..a76eed8b4202a 100755
--- a/llvm/utils/gn/build/symbol_exports.py
+++ b/llvm/utils/gn/build/symbol_exports.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Converts a .exports file to a format consumable by linkers.
diff --git a/llvm/utils/gn/build/symlink_or_copy.py b/llvm/utils/gn/build/symlink_or_copy.py
index a8f6c1b322bea..d5fbf32c1a6de 100755
--- a/llvm/utils/gn/build/symlink_or_copy.py
+++ b/llvm/utils/gn/build/symlink_or_copy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Symlinks, or on Windows copies, an existing file to a second location.
diff --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index 141517936e77c..a23a8af9d7f17 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Helps to keep BUILD.gn files in sync with the corresponding CMakeLists.txt.
@@ -14,8 +14,6 @@
of HEAD is unspecified; run `git reset --hard origin/main` if this happens.
"""
-from __future__ import print_function
-
from collections import defaultdict
import os
import re
diff --git a/llvm/utils/gn/build/write_cmake_config.py b/llvm/utils/gn/build/write_cmake_config.py
index 4fb9031795e66..ff69079bbef76 100755
--- a/llvm/utils/gn/build/write_cmake_config.py
+++ b/llvm/utils/gn/build/write_cmake_config.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
r"""Emulates the bits of CMake's configure_file() function needed in LLVM.
The CMake build uses configure_file() for several things. This emulates that
@@ -32,8 +32,6 @@
input file, or if the input file references keys that weren't passed in.
"""
-from __future__ import print_function
-
import argparse
import os
import re
diff --git a/llvm/utils/gn/build/write_library_dependencies.py b/llvm/utils/gn/build/write_library_dependencies.py
index 747fe2bae1618..d9fcc326df7f9 100644
--- a/llvm/utils/gn/build/write_library_dependencies.py
+++ b/llvm/utils/gn/build/write_library_dependencies.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env python
-from __future__ import print_function
+#!/usr/bin/env python3
import argparse
import os
diff --git a/llvm/utils/gn/build/write_vcsrevision.py b/llvm/utils/gn/build/write_vcsrevision.py
index b77a33dc8af27..6398b94df76bb 100755
--- a/llvm/utils/gn/build/write_vcsrevision.py
+++ b/llvm/utils/gn/build/write_vcsrevision.py
@@ -1,9 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Gets the current revision and writes it to VCSRevision.h."""
-from __future__ import print_function
-
import argparse
import os
import subprocess
diff --git a/llvm/utils/gn/get.py b/llvm/utils/gn/get.py
index 8ae506f73c524..f0849fd4cd206 100755
--- a/llvm/utils/gn/get.py
+++ b/llvm/utils/gn/get.py
@@ -1,17 +1,12 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Downloads a prebuilt gn binary to a place where gn.py can find it."""
from __future__ import print_function
import io
import os
-try:
- # In Python 3, we need the module urllib.reqest. In Python 2, this
- # functionality was in the urllib2 module.
- from urllib import request as urllib_request
-except ImportError:
- import urllib2 as urllib_request
import sys
+import urllib.request
import zipfile
@@ -19,7 +14,7 @@ def download_and_unpack(url, output_dir, gn):
"""Download an archive from url and extract gn from it into output_dir."""
print('downloading %s ...' % url, end='')
sys.stdout.flush()
- data = urllib_request.urlopen(url).read()
+ data = urllib.request.urlopen(url).read()
print(' done')
zipfile.ZipFile(io.BytesIO(data)).extract(gn, path=output_dir)
diff --git a/llvm/utils/gn/gn.py b/llvm/utils/gn/gn.py
index 4708d4c3b6024..b2936f88bf3fa 100755
--- a/llvm/utils/gn/gn.py
+++ b/llvm/utils/gn/gn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Calls `gn` with the right --dotfile= and --root= arguments for LLVM."""
# GN normally expects a file called '.gn' at the root of the repository.
diff --git a/llvm/utils/gn/secondary/libcxx/utils/gen_link_script.py b/llvm/utils/gn/secondary/libcxx/utils/gen_link_script.py
index 485aa64b97446..3b162a9123b5b 100755
--- a/llvm/utils/gn/secondary/libcxx/utils/gen_link_script.py
+++ b/llvm/utils/gn/secondary/libcxx/utils/gen_link_script.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/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py b/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py
index 9cd1dd0f2ccb7..c31f35ce87416 100755
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env python
-from __future__ import print_function
+#!/usr/bin/env python3
import argparse
import os
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-config/write_extension_dependencies.py b/llvm/utils/gn/secondary/llvm/tools/llvm-config/write_extension_dependencies.py
index 1ebe95ea35ac6..68a341c18bd84 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-config/write_extension_dependencies.py
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-config/write_extension_dependencies.py
@@ -1,8 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
r"""Writes ExtensionDepencencies.inc."""
-from __future__ import print_function
-
import argparse
import os
import re
More information about the llvm-commits
mailing list