Repository: mesos Updated Branches: refs/heads/master 05594d69d -> ae4e7956a
Added support script to check if Python >= 3.6 is available. Review: https://reviews.apache.org/r/67247/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7ecb2fef Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7ecb2fef Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7ecb2fef Branch: refs/heads/master Commit: 7ecb2fef2edf99a03188a871cfaf0f16ec71508a Parents: 05594d6 Author: Armand Grillet <agril...@mesosphere.io> Authored: Thu May 24 14:58:00 2018 -0700 Committer: Andrew Schwartzmeyer <and...@schwartzmeyer.com> Committed: Thu May 24 14:58:00 2018 -0700 ---------------------------------------------------------------------- support/check-python3.py | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/7ecb2fef/support/check-python3.py ---------------------------------------------------------------------- diff --git a/support/check-python3.py b/support/check-python3.py new file mode 100644 index 0000000..4cb5365 --- /dev/null +++ b/support/check-python3.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Checks if Python 3.6 is available on the machine. +""" +# pylint: disable=superfluous-parens + +import os +import subprocess +import sys + + +def print_error(): + """Prints a warning requesting to install Python 3.6.""" + print("The support scripts will be upgraded to Python 3 by July 1st.") + print("Make sure to install Python 3.6 on your machine before.") + +if sys.version_info[0] < 3: + # On Windows, system-wide installations of Python 3.6 gives a tools called + # py and that we can use to know if Python 3 is installed. + if os.name == "nt": + PY = subprocess.call(["WHERE", "py"], stdout=open(os.devnull, "wb")) + else: + # We are not using Python 3 as python, let's check if python3 exists. + PY = subprocess.call(["which", "python3"], + stdout=open(os.devnull, "wb")) + if PY != 0: + print_error() + else: + # It does exist, let's check its version. + if os.name == "nt": + VERSION = subprocess.check_output("py -3 --version", shell=True) + else: + VERSION = subprocess.check_output("python3 --version", shell=True) + # x goes from 0 to 5 so that we can check for Python < 3.6. + for x in range(0, 6): + if "3.%d." % (x) in VERSION: + print_error() +elif sys.version_info[1] < 6: + # python is by default Python 3 but it's < 3.6. + print_error()