#310 Docker provisiner: Use python3 interpreter
Opened 5 years ago by ssahani. Modified 5 years ago
ssahani/standard-test-roles py3-interpreter  into  master

@@ -112,25 +112,24 @@ 

          raise RuntimeError("Could not find container file for launched container")

      with open(cidfile, "r") as f:

          name = f.read().strip()

-     # Need to figure out what python interpreter to use

-     interpreters = ["/usr/bin/python3", "/usr/bin/python2"]

-     for interpreter in interpreters:

-         check_file = ["/usr/bin/docker", "exec", "--user=root", name, "/usr/bin/ls", interpreter]

-         try:

-             subprocess.check_call(check_file, stdout=null, stderr=null)

-             ansible_python_interpreter = interpreter

-             break

-         except subprocess.CalledProcessError:

-             pass

+ 

+     # Figure out what whenther python3 interpreter is available

+     check_file = ["/usr/bin/docker", "exec", "--user=root", name, "/usr/bin/ls", "/usr/bin/python3"]

+     try:

+         subprocess.check_call(check_file, stdout=null, stderr=null)

+         break

+     except subprocess.CalledProcessError:

+         pass

      else:

          logger.error("Could not set ansible_python_interpreter.")

          return None

+ 

      # Directory to place artifacts

      artifacts = os.environ.get("TEST_ARTIFACTS", os.path.join(os.getcwd(), "artifacts"))

      # The variables

      variables = {

          "ansible_connection": "docker",

-         "ansible_python_interpreter": ansible_python_interpreter

+         "ansible_python_interpreter": "/usr/bin/python3"

      }

      # Process of our parent

      ppid = os.getppid()

Since we have already ported to python3 do not look for python2
interpreter

rebased onto 1753883

5 years ago

What problem are you trying to fix here?

This was checking what python version was available in the container, nothing to do with the test runner. If the container image would have only python2 and not python3 we would use python2.

If the idea is to drop python2 support completely there is not need to run the Figure out what whenther python3 interpreter is available part and just set the interpreter to python3.

This was checking what python version was available in the container, nothing to do with the test runner. If the container image would have only python2 and not python3 we would use python2.

Since we agreed to run on python3 no need to look for python2

If the idea is to drop python2 support completely there is not need to run the Figure out what whenther python3 interpreter is available part and just set the interpreter to python3.

Well it has to look whether python is available there. Just can't assume it's installed.

let's not close our doors on testing rhel6/rhel7 .... where there is no python3

@ssahani is this PR still being worked or it should just be closed?