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