From baa725e5ff99b09ddc34a34134abb9a390500f87 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Sep 2024 21:40:21 +0100 Subject: [PATCH] Python shebang modernisation for python3 PEP-394 recommends specifying python2 or python3 in shebangs unless the script is known to only run in an activated virtual environment. PEP-394 also says distributors may not provide the python command. Newer versions of Ubuntu, at least, no longer provide python unless the python-is-python3 package is explicitly installed. Removed some shebangs from testcases (the test-suite does not need them). --- Doc/Manual/Makefile | 4 ++-- Doc/Manual/Python.html | 2 +- Doc/Manual/fixstyle.py | 2 +- Doc/Manual/makechap.py | 2 +- Doc/Manual/maketoc.py | 2 +- Examples/test-suite/javascript/operbool_runme.js | 1 - Examples/test-suite/python/cpp_static_runme.py | 1 - Examples/test-suite/python/keyword_rename_c_runme.py | 1 - Examples/test-suite/python/keyword_rename_runme.py | 1 - Examples/test-suite/python/operbool_runme.py | 1 - Tools/obs-buildlogs.py | 2 +- Tools/pyname_patch.py | 2 +- Tools/testflags.py | 2 +- 13 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 0f9fe0e96..ece079d5a 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -22,7 +22,7 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont all: maketoc check generate maketoc: - python maketoc.py + python3 maketoc.py # Use this to regenerate CCache.html should this ever be needed CCache.html: ../../CCache/ccache.yo @@ -48,7 +48,7 @@ generate: SWIGDocumentation.html SWIGDocumentation.html: swightml.book htmldoc --batch swightml.book || true - python fixstyle.py SWIGDocumentation.html + python3 fixstyle.py SWIGDocumentation.html swightml.book: chapters Sections.html echo "#HTMLDOC 1.8.24" > swightml.book diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 656d00467..f21267e02 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -319,7 +319,7 @@ Here is a sample setup.py file for the above example:
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 setup.py file for SWIG example
diff --git a/Doc/Manual/fixstyle.py b/Doc/Manual/fixstyle.py
index a36096890..f71ee46e5 100644
--- a/Doc/Manual/fixstyle.py
+++ b/Doc/Manual/fixstyle.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # Replace the inline htmldoc stylesheet with the SWIG stylesheet
 
diff --git a/Doc/Manual/makechap.py b/Doc/Manual/makechap.py
index 9c43f6ac5..03bf782dd 100644
--- a/Doc/Manual/makechap.py
+++ b/Doc/Manual/makechap.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 ###############################################################################
 # Takes a chapter as input and adds internal links and numbering to all
diff --git a/Doc/Manual/maketoc.py b/Doc/Manual/maketoc.py
index 8322e3767..f860cfb04 100644
--- a/Doc/Manual/maketoc.py
+++ b/Doc/Manual/maketoc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys
 import os
diff --git a/Examples/test-suite/javascript/operbool_runme.js b/Examples/test-suite/javascript/operbool_runme.js
index b1bf89fa8..266036623 100644
--- a/Examples/test-suite/javascript/operbool_runme.js
+++ b/Examples/test-suite/javascript/operbool_runme.js
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 var operbool = require("operbool");
 const b = new operbool.Test();
 if (b.operator_bool()) {
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index cd7398fbb..4c43a8f1c 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -1,4 +1,3 @@
-#!/usr/bin/evn python
 from cpp_static import *
 
 
diff --git a/Examples/test-suite/python/keyword_rename_c_runme.py b/Examples/test-suite/python/keyword_rename_c_runme.py
index c17aede4c..e46e0aecf 100644
--- a/Examples/test-suite/python/keyword_rename_c_runme.py
+++ b/Examples/test-suite/python/keyword_rename_c_runme.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 import keyword_rename_c
 keyword_rename_c._in(1)
 keyword_rename_c._except(1)
diff --git a/Examples/test-suite/python/keyword_rename_runme.py b/Examples/test-suite/python/keyword_rename_runme.py
index 0bdd64b10..79e3184d1 100644
--- a/Examples/test-suite/python/keyword_rename_runme.py
+++ b/Examples/test-suite/python/keyword_rename_runme.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 import keyword_rename
 keyword_rename._in(1)
 keyword_rename._in(_except=1)
diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py
index cdef85abc..bcfb68571 100644
--- a/Examples/test-suite/python/operbool_runme.py
+++ b/Examples/test-suite/python/operbool_runme.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 import operbool
 if operbool.Test():
     raise RuntimeError("operbool failed")
diff --git a/Tools/obs-buildlogs.py b/Tools/obs-buildlogs.py
index 1c77e80c4..1fc8f66f4 100755
--- a/Tools/obs-buildlogs.py
+++ b/Tools/obs-buildlogs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import os
 import subprocess
diff --git a/Tools/pyname_patch.py b/Tools/pyname_patch.py
index f8f436c38..37ce1b430 100644
--- a/Tools/pyname_patch.py
+++ b/Tools/pyname_patch.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 """
 From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
 since they are inappropriate and discouraged in Python documentation
diff --git a/Tools/testflags.py b/Tools/testflags.py
index 24cd80469..01833be18 100755
--- a/Tools/testflags.py
+++ b/Tools/testflags.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 def get_cflags(language, std, compiler):
     if std == None or len(std) == 0: