Molecule: Molecule should support Python 3.5

Created on 11 Mar 2019  Â·  23Comments  Â·  Source: ansible-community/molecule

Issue Type

  • Bug report

Molecule and Ansible details

  • v2.19

Desired Behavior

Molecule supports Python 2.6 and 3.5.

Based on discussion in https://github.com/ansible/molecule/pull/1820#discussion_r264356999, I think we should be asking ourselves why we are not supporting 2.6 and 3.5 if the oldest version of Ansible that we offer support for does.

https://github.com/ansible/ansible/blob/stable-2.5/setup.py#L243

I know there was some previous discussion around this but I can't remember the resolution.

So, let's go! Can of worms!

Actual Behaviour

Molecule does not offer support for Python 2.6 and 3.5.

wontfix

Most helpful comment

Some context for this recurring question:

Minutes of the IRC meeting: https://meetbot.fedoraproject.org/ansible-molecule/2019-02-20/ansible_molecule_working_group.2019-02-20-19.01.log.html

Conclusion was:

So python 3.5 is supposed to be still there.

What is the definitive python 3 version of Centos by the way? 3.4 in one discussion, 3.5 in another ?

All 23 comments

Please, don't...

Just an FYI, the latest version of Ansible does not support Python 2.6 on the controller side just the remote. I don't know much about Molecule but if it is executing the actual controller side then Python 2.6 should not be supported. You will also find it's getting harder and harder to install the proper dependencies for Python 2.6, it's a common problem in CI where a new dependency update is not supported in 2.6 but didn't declare it so.

I see we are testing against 3.5 in:

https://github.com/ansible/molecule/blob/master/tox.ini#L5

But we're making constraints against that in:

https://github.com/ansible/molecule/blob/master/setup.cfg#L14

Oh, here we go ...

@decentral1se also take into account that Ansible 2.8 is going to be out in about two months which will probably turn Ansible 2.5 into EOL.

The amount of maintenance burden is totally not worth it.

Oh, and another thing is that adding an extra bunch of jobs into CI sounds painful. I think that's why we removed those.

Thanks @webknjaz @jborean93. I'm fine to keep 2.6 dropped (phew) and heed the 2.5 EOL note.

That leaves us with the Python 3.5 support. Is this contentious? We'd just need to update our setuptools/pbr configuration and documentation to match what we're already testing against. I think this was the main motivation for the original discussion.

Let's also take a look at other deps:

  • ansible-lint: ==2.7 or >=3.6
  • click: dropped support for py2.6 last year, in September
  • testinfra: dropped support for py2.6 last year, in November
  • pytest: dropped suport for py2.6 1.5 years ago

Major packages in ecosystem: are going to drop support for Python 2 completely by the end of this year.

So I'd say that there's no reason to support envs which are not supported by our dependencies.

Regarding updating deps: there's tox+pbr+requirements to be updated if someone wants to go down this road.

Unrelated note: requirements really need to be reorganized to make it simpler to manage them. Will address it separately, though.

Yeah, py26 is pretty much dead and I can longer compile it on macos.
Still, python3.5 is bit more tricky because is default python3 version on CentOS 7 and on that OS is not easy to install py36+, so we should still accept it.

I think we should keep it in a gray area, a best efforth approach, not officially supported but assuring that we don't prevent code from running on it (like adding a requires condition).

I would prefer to let ansible dictate these requirements instead of haivng us to deal with them here.

I'd like to emphasize that Molecule is a testing framework. Which means that its users probably have (full) control over the env where it runs making in possible to use the latest versions of OSs/Pythons.

Now, they will probably develop content which they will be testing to run against other hosts (docker containers, clouds etc.). I'd say that this makes it less important which version the controller/molecule host runs. We already provide a ready-to-use container with Molecule. They don't even have to care about setting up that env...

On the other side, more versions to support == more maintanence pain. I understand that ideal case is to support 100 years old software but there's a cost to it. That's why I don't like the idea of sticking to Python 3.5.

@ssbarnea as it is now, pip will probably yell at users trying to install molecule just because ansible-lint version spec says that it's not supported.

That is not true, check https://github.com/ansible/ansible-lint/blob/master/setup.cfg#L70 --- It was a bug fixed two months ago caused by premature deprecation syndrome ;)

Lets let the py35 have a slow death. I am not asking to add a Travi job test py35 but I do want for a developer that clones molecule on a centos-7 machine, to be able to run "tox" and which will run tests with py27 and py35 if they are installed on his machine.

When I test python code I use 4 architectures for which I happen to have hardware nodes: MacOS, Centos 7, Fedora 28 and Ubuntu 18.x -- I aim to make as easy as possible for anyone running "tox" on each of these. Failing to test with python3 on CentOS would be a real issue as for some, this is their major development machine. This is important because most of molecule contributors will be just occasional ones, they will only want/need to make a small bugs of add a minor feature and they will not have time to dig too much in order to make their change.

We're alreading testing against 3.5:

(.venv) ➜  molecule (master) ✔ tox -l  | grep -i py35
py35-ansible25-functional
py35-ansible25-unit
py35-ansible26-functional
py35-ansible26-unit
py35-ansible27-functional
py35-ansible27-unit

So, RE: "more maintenance", it's nothing more than what we have. We just need to "officially" support it by updating docs/packaging meta. And then, follow our dependencies / Ansible / ecosystem in dropping Python 3.5 support when it is time.

That's my proposal.

Some context for this recurring question:

Minutes of the IRC meeting: https://meetbot.fedoraproject.org/ansible-molecule/2019-02-20/ansible_molecule_working_group.2019-02-20-19.01.log.html

Conclusion was:

So python 3.5 is supposed to be still there.

What is the definitive python 3 version of Centos by the way? 3.4 in one discussion, 3.5 in another ?

meanwhile i read: Python 2 has been deprecated in RHEL 7.6. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/7.6_release_notes/#chap-Red_Hat_Enterprise_Linux-7.6_Release_Notes-Deprecated_Functionality_in_RHEL7 But still present right?

Debian stable has python 3.5, testing and unstable python 3.7: https://packages.debian.org/search?keywords=python3
Ubuntu: xenial (16.04LTS) has 3.5, bionic (18.04LTS) and cosmic (18.10) 3.6, disco has 3.7
https://packages.ubuntu.com/search?keywords=python3

I read that centos/RHEL supports python 3 with SCL, and python 3.5 and 3.6 are available https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/html-single/3.2_release_notes/#sect-RHSCL-Features

@themr0c AFAIR RHEL 8 comes with an "isolated" platform-python which is 3.7 but users mustn't use it. Unless Molecule is going to provide RPMs it shouldn't rely on it. Other Python versions should be mostly installed from SCL, that's correct. AFAIK there's no Python 2 shipped by default but I think you should be able to install it there.

Ref: https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8/

Personally, I usually encourage people to have a separate Python in userspace to not mess with any of the system stuff. It can be installed using pyenv. Which is fine because Molecule targets development/testing, not some live production systems with other software.

BTW one can easily have Python 3.6 under CentOS if needed: https://hub.docker.com/r/centos/python-36-centos7

Hello! I have the feeling that Molecule does not support Python 3.5 anymore, from version 3.0.6. We only have xenial servers support on our Travis instance and we get the following error when trying to run Molecule:

```$ molecule --version

Traceback (most recent call last):

File "/home/travis/.local/bin/molecule", line 7, in

from molecule.__main__ import main

File "/home/travis/.local/lib/python3.5/site-packages/molecule/__main__.py", line 22, in

from molecule.shell import main

File "/home/travis/.local/lib/python3.5/site-packages/molecule/shell.py", line 31, in

from molecule import command

File "/home/travis/.local/lib/python3.5/site-packages/molecule/command/__init__.py", line 27, in

from molecule.command import base  # noqa

File "/home/travis/.local/lib/python3.5/site-packages/molecule/command/base.py", line 34, in

from molecule import config, logger, util

File "/home/travis/.local/lib/python3.5/site-packages/molecule/config.py", line 28, in

from molecule import api, interpolation, logger, platforms, scenario, state, util

File "/home/travis/.local/lib/python3.5/site-packages/molecule/api.py", line 9, in

from molecule.driver.base import Driver  # noqa

File "/home/travis/.local/lib/python3.5/site-packages/molecule/driver/base.py", line 27, in

from molecule.status import Status

File "/home/travis/.local/lib/python3.5/site-packages/molecule/status.py", line 28

instance_name: str

             ^

SyntaxError: invalid syntax

The command "molecule --version" exited with 1.
```

Python 3.7 seems to work (on my Mac); Python 3.6 also (on some Ubuntu 18.04 box.)

Can you please confirm? I didn't see anything related to this in the release notes :(

Thank you very much!

Regards,
Pierre-Yves

Yep, not supported and with zero plans to do it.

Ah, I just found the commit about this: https://github.com/ansible-community/molecule/commit/cd223688e14b244e77c6a52f932a9da2e4d5b1a9#diff-380c6a8ebbbce17d55d50ef17d3cf906

No (big) problem, we'll find another way (and keep v. 3.0.5 for now.) Thank you!

You can ask Travis to put any version of Python up through 3.9dev or even nightly for a Bionic box.

language: python
python:
  - "3.6"

Thank you very much Greg, that's what we did, after reading a bit of doc ;)

(I did have specified python: - "3.6" but... with language: bash. Obviously it did not work as expected.)

Was this page helpful?
0 / 5 - 0 ratings