Skip to content

Commit

Permalink
Make py36 minimal version needed for running molecule
Browse files Browse the repository at this point in the history
Fixes: #2629
  • Loading branch information
ssbarnea committed Mar 26, 2020
1 parent 7de914f commit cd22368
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 135 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ENV PACKAGES="\
py3-ruamel \
py3-setuptools \
py3-simplejson \
py3-six \
py3-tabulate \
py3-urllib3 \
py3-virtualenv \
Expand Down Expand Up @@ -112,7 +111,6 @@ ENV PACKAGES="\
py3-requests \
py3-ruamel \
py3-setuptools \
py3-six \
py3-tabulate \
py3-urllib3 \
py3-virtualenv \
Expand Down
13 changes: 3 additions & 10 deletions docs/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ and run ``molecule test`` in ubuntu.
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7]
python-version: [3.6, 3.7]
steps:
- uses: actions/checkout@v1
Expand Down Expand Up @@ -255,14 +255,7 @@ To test the role against multiple versions of Ansible.
commands =
molecule test
To view the factor generated tox environments.

.. code-block:: bash
$ tox -l
py27-ansible20
py27-ansible21
py27-ansible22
To view the factor generated tox environments run `tox -l`.

If using the `--parallel functionality`_ of Tox (version 3.7 onwards), Molecule
must be made aware of the parallel testing by setting a
Expand All @@ -273,7 +266,7 @@ we export a ``TOX_ENVNAME`` environment variable, it's the name of our tox env.
[tox]
minversion = 3.7
envlist = py{27}_ansible{23,24}
envlist = py{36}_ansible{23,24}
skipsdist = true
[testenv]
Expand Down
7 changes: 3 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ Requirements
Depending on the driver chosen, you may need to install additional OS packages.
See ``INSTALL.rst``, which is created when initializing a new scenario.

* Python 2.7 or Python >= 3.5 with :std:doc:`Ansible <ansible:index>` >= 2.5
* Python >= 3.6 with :std:doc:`Ansible <ansible:index>` >= 2.8

CentOS 7
CentOS 8
--------

.. code-block:: bash
$ sudo yum install -y epel-release
$ sudo yum install -y gcc python3-pip python3-devel openssl-devel libselinux-python
Ubuntu 16.x
Expand Down Expand Up @@ -154,7 +153,7 @@ certain unstable version should the need to send a bug report arise.
Requirements
------------

CentOS 7
CentOS 8
^^^^^^^^

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion molecule/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Molecule API Module."""

from six.moves import UserList
from collections import UserList
import pluggy
from molecule import logger
from molecule.util import lru_cache
Expand Down
4 changes: 1 addition & 3 deletions molecule/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import glob
import os

import six
import shutil

import molecule.command
Expand All @@ -41,8 +40,7 @@
MOLECULE_DEFAULT_SCENARIO_NAME = "default"


@six.add_metaclass(abc.ABCMeta)
class Base(object):
class Base(object, metaclass=abc.ABCMeta):
"""An abstract base class used to define the command interface."""

def __init__(self, c):
Expand Down
4 changes: 2 additions & 2 deletions molecule/command/init/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from molecule import util
from molecule.command import base as command_base
from molecule.command.init import base

from subprocess import check_output

LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -75,7 +75,7 @@ def execute(self):

try:
cmd = ["ansible-galaxy", "init", "-v", "--offline", role_name]
util.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
util.sysexit_with_message(
"Galaxy failed to create role: %s: %s" % (e, e.output)
Expand Down
4 changes: 2 additions & 2 deletions molecule/command/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from molecule import logger
from molecule.command import base
from molecule import util

from subprocess import run

LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -93,7 +93,7 @@ def execute(self):

try:
LOG.info("Executing: %s" % cmd)
util.run(cmd, shell=True, universal_newlines=True, check=True)
run(cmd, shell=True, universal_newlines=True, check=True)
except Exception as e:
util.sysexit_with_message("Lint failed: %s: %s" % (e, e))

Expand Down
4 changes: 1 addition & 3 deletions molecule/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import os

from ansible.module_utils.parsing.convert_bool import boolean
import six

from molecule import api
from molecule import interpolation
Expand Down Expand Up @@ -56,8 +55,7 @@ def __call__(cls, *args, **kwargs):
return obj


@six.add_metaclass(NewInitCaller)
class Config(object):
class Config(object, metaclass=NewInitCaller):
"""
Config Class.
Expand Down
10 changes: 3 additions & 7 deletions molecule/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
# DEALINGS IN THE SOFTWARE.
"""Molecule Scenario Module."""

import shutil
import os
from pathlib import Path
import fnmatch

try:
from pathlib import Path
except ImportError:
from pathlib2 import Path
import os
import shutil

from molecule import logger
from molecule import scenarios
Expand Down
7 changes: 4 additions & 3 deletions molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from molecule import logger
from molecule import util
from subprocess import check_output

from molecule.test.conftest import change_dir_to

Expand Down Expand Up @@ -267,7 +268,7 @@ def get_virtualbox_executable():
def supports_docker():
docker = get_docker_executable()
if docker:
result = util.run([docker, "info"], stdout=PIPE, universal_newlines=True)
result = subprocess.run([docker, "info"], stdout=PIPE, universal_newlines=True)
if result.returncode != 0:
LOG.error(
"Error %s returned from `docker info`: %s",
Expand All @@ -293,7 +294,7 @@ def supports_podman():
if not min_ansible("2.8.6") or platform.system() == "Darwin" or not podman:
return False

result = util.run([podman, "info"], stdout=PIPE, universal_newlines=True)
result = subprocess.run([podman, "info"], stdout=PIPE, universal_newlines=True)
if result.returncode != 0:
LOG.error(
"Error %s returned from `podman info`: %s",
Expand All @@ -305,7 +306,7 @@ def supports_podman():

# checks for minimal version of podman
cmd = ["podman", "version", "-f", "{{.Version}}"]
podman_version = util.check_output(
podman_version = check_output(
cmd, stderr=subprocess.STDOUT, universal_newlines=True
)
# We need to use the outdated LooseVersion because podman versioning
Expand Down
6 changes: 1 addition & 5 deletions molecule/test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@
# DEALINGS IN THE SOFTWARE.

from uuid import uuid4
from pathlib import Path
import copy
import functools
import os
import shutil

try:
from pathlib import Path
except ImportError:
from pathlib2 import Path

import pytest

from molecule import util
Expand Down
21 changes: 3 additions & 18 deletions molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,16 @@

from __future__ import print_function

from collections.abc import Mapping
import contextlib
import fnmatch
import jinja2
import os
import re
import sys

try:
from subprocess import check_output # noqa 401
from subprocess import run # noqa 401
from subprocess import STDOUT # noqa 401
except ImportError:
from subprocess32 import check_output # noqa 401
from subprocess32 import run # noqa 401
from subprocess32 import STDOUT # noqa 401

try:
from collections.abc import Mapping
except ImportError: # Python 2 compatibility
from collections import Mapping

try:
from functools import lru_cache # noqa
except ImportError:
from backports.functools_lru_cache import lru_cache # noqa

from functools import lru_cache # noqa

import colorama
import yaml
Expand Down
16 changes: 4 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ classifiers =
Operating System :: OS Independent

Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8

Topic :: System :: Systems Administration
Topic :: Utilities
Expand All @@ -56,7 +55,7 @@ keywords =

[options]
use_scm_version = True
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
python_requires = >=3.6
packages = find:
include_package_data = True
zip_safe = False
Expand All @@ -70,7 +69,6 @@ setup_requires =
install_requires =
ansible >= 2.8 # keep it N/N-1

backports.functools_lru_cache; python_version<"3.3"
cerberus >= 1.3.1
click >= 7.0
click-completion >= 0.5.1
Expand All @@ -80,13 +78,10 @@ install_requires =
python-gilt >= 1.2.1, < 2
Jinja2 >= 2.10.1
paramiko >= 2.5.0, < 3
pathlib2; python_version<"3.2"
pexpect >= 4.6.0, < 5
pluggy >= 0.7.1, < 1.0
PyYAML >= 5.1, < 6
sh >= 1.12.14
six >= 1.11.0
subprocess32; python_version<"3.5"
tabulate >= 0.8.4
tree-format >= 0.1.2
yamllint >= 1.15.0, < 2
Expand All @@ -111,21 +106,18 @@ test =
mock>=3.0.5, < 4
pytest-cov>=2.7.1, < 3
pytest-helpers-namespace>=2019.1.8, < 2020
pytest-html>=1.21.0,<2.0; python_version < '3.6'
pytest-html>=1.21.0; python_version >= '3.6'
pytest-html>=1.21.0
pytest-mock>=1.10.4, < 2
pytest-verbose-parametrize>=1.7.0, < 2
pytest-plus
pytest-sugar>=0.9.2, < 1
pytest-xdist>=1.29.0, < 2
pytest>=4.6.3, < 5
shade>=1.31.0, < 2
testinfra >= 3.4.0
lint =
ansible-lint >= 4.1.1a2, < 5
flake8 >= 3.6.0
pre-commit >= 1.21.0, < 2; python_version<"3.5"
pre-commit >= 1.21.0; python_version>="3.5"
pre-commit >= 1.21.0
yamllint >= 1.15.0

[options.entry_points]
Expand Down
2 changes: 1 addition & 1 deletion tools/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -euxo pipefail
# non-sudo mode.
PYTHON=$(command -v python3 python | head -n1)

sudo $PYTHON -m pip install -U tox "zipp<0.6.0;python_version=='2.7'"
sudo "$PYTHON" -m pip install "tox>=3.14.6"

# Workaround for a potential:
# Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
Expand Down
Loading

0 comments on commit cd22368

Please sign in to comment.