diff --git a/Lib/site.py b/Lib/site.py
index 868b7cb..1b4953f 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -515,6 +515,20 @@ def execusercustomize():
"'import usercustomize' failed; use -v for traceback"
+def ambiguous_python_version_rpmbuild_warn():
+ """Put a warning on stderr if /usr/bin/python is used in rpmbuild."""
+ if (sys.executable == "/usr/bin/python" and "RPM_BUILD_ROOT" in os.environ
+ and not os.environ.get("DISABLE_AMBIGUOUS_PYTHON_VERSION_WARNING")):
+ print>>sys.stderr, \
+ ("DEPRECATION WARNING: python2 invoked with /usr/bin/python.\n"
+ " Use /usr/bin/python3 or /usr/bin/python2\n"
+ " /usr/bin/python will be removed or switched to Python 3"
+ " in the future.\n"
+ " If you cannot make the switch now, please follow"
+ " instructions at "
+ "https://fedoraproject.org/wiki/XXX#Quick_Opt-Out")
+
+
def main():
global ENABLE_USER_SITE
@@ -543,6 +557,7 @@ def main():
# this module is run as a script, because this code is executed twice.
if hasattr(sys, "setdefaultencoding"):
del sys.setdefaultencoding
+ ambiguous_python_version_rpmbuild_warn()
main()