Blame SOURCES/00288-ambiguous-python-version-rpmbuild-warn.patch

556498
diff -U3 -r Python-2.7.14.orig/Lib/site.py Python-2.7.14/Lib/site.py
556498
--- Python-2.7.14.orig/Lib/site.py	2018-01-29 15:05:04.517599815 +0100
556498
+++ Python-2.7.14/Lib/site.py	2018-01-30 09:13:17.305270500 +0100
556498
@@ -515,6 +515,41 @@
556498
                 "'import usercustomize' failed; use -v for traceback"
556498
 
556498
 
556498
+def handle_ambiguous_python_version():
556498
+    """Warn or fail if /usr/bin/python is used
556498
+
556498
+    Behavior depends on the value of PYTHON_DISALLOW_AMBIGUOUS_VERSION:
556498
+    - "warn" - print warning to stderr
556498
+    - "1" - print error and exit with positive exit code
556498
+    - otherwise: do nothing
556498
+
556498
+    This is a Fedora modification, see the Change page for details:
556498
+    See https://fedoraproject.org/wiki/Changes/Avoid_usr_bin_python_in_RPM_Build
556498
+    """
556498
+    if sys.executable == "/usr/bin/python":
556498
+        setting = os.environ.get("PYTHON_DISALLOW_AMBIGUOUS_VERSION")
556498
+        if setting == 'warn':
556498
+            print>>sys.stderr, (
556498
+                "DEPRECATION WARNING: python2 invoked with /usr/bin/python.\n"
556498
+                "    Use /usr/bin/python3 or /usr/bin/python2\n"
556498
+                "    /usr/bin/python will be removed or switched to Python 3"
556498
+                    " in the future.\n"
556498
+                "    If you cannot make the switch now, please follow"
556498
+                    " instructions at"
556498
+                    " https://fedoraproject.org/wiki/Changes/"
556498
+                    "Avoid_usr_bin_python_in_RPM_Build#Quick_Opt-Out")
556498
+        elif setting == '1':
556498
+            print>>sys.stderr, (
556498
+                "ERROR: python2 invoked with /usr/bin/python.\n"
556498
+                "    Use /usr/bin/python3 or /usr/bin/python2\n"
556498
+                "    /usr/bin/python will be switched to Python 3"
556498
+                    " in the future.\n"
556498
+                "    More details are at"
556498
+                    " https://fedoraproject.org/wiki/Changes/"
556498
+                    "Avoid_usr_bin_python_in_RPM_Build#Quick_Opt-Out")
556498
+            exit(1)
556498
+
556498
+
556498
 def main():
556498
     global ENABLE_USER_SITE
556498
 
556498
@@ -543,6 +578,7 @@
556498
     # this module is run as a script, because this code is executed twice.
556498
     if hasattr(sys, "setdefaultencoding"):
556498
         del sys.setdefaultencoding
556498
+    handle_ambiguous_python_version()
556498
 
556498
 main()
556498