From d2fefdf71e61d53ae38a1da23ebeac3814b0178a Mon Sep 17 00:00:00 2001 From: Dwight Hubbard <254983+dwighthubbard@users.noreply.github.com> Date: Tue, 29 Jan 2019 09:25:21 -0800 Subject: [PATCH] Python3 dockerplugin update (#11) * Update docker_build.sh * Update docker_build.sh * Update utility.py * Update setup.py Increment version * Update docker_build.sh * Update docker_build.sh * Update docker_build.sh * Update docker_build.sh * Update docker_build.sh * Update docker_build.sh * Update docker_build.sh * Add missing autodocs Add another test so the coverage numbers don't decrease * Remove junk from tox.ini * Remove junk from tox.ini * Add more tests to address coverage drops. * Documentation tweaks * Remove junk from tox.ini --- MANIFEST.in | 2 - doc/source/configuration.rst | 154 ++++++++++++++++-- doc/source/index.rst | 2 + doc/source/install.rst | 1 + doc/source/invirtualenv.cli.rst | 7 + doc/source/invirtualenv.config.rst | 7 + doc/source/invirtualenv.contextmanager.rst | 7 + doc/source/invirtualenv.deploy.rst | 7 + doc/source/invirtualenv.exceptions.rst | 7 + doc/source/invirtualenv.package.rst | 7 + doc/source/invirtualenv.plugin.rst | 7 + doc/source/invirtualenv.plugin_base.rst | 7 + doc/source/invirtualenv.rst | 4 +- doc/source/invirtualenv.utility.rst | 7 + doc/source/invirtualenv.virtualenv.rst | 7 + doc/source/invirtualenv_plugins.docker.rst | 7 + .../invirtualenv_plugins.parsedconfig.rst | 7 + doc/source/invirtualenv_plugins.rpm.rst | 7 + ...alenv_plugins.rpm_scripts.post_install.rst | 7 + ...lenv_plugins.rpm_scripts.pre_uninstall.rst | 7 + .../invirtualenv_plugins.rpm_scripts.rst | 16 ++ doc/source/invirtualenv_plugins.rst | 24 +++ doc/source/scripts.rst | 32 +++- examples/deploy.conf | 2 +- invirtualenv/contextmanager.py | 2 +- invirtualenv/utility.py | 6 + .../docker_scripts/docker_build.sh | 42 ++++- setup.py | 2 +- tests/test_contextmanager.py | 15 ++ tests/test_plugin__parsed_config.py | 9 +- tox.ini | 149 +---------------- 31 files changed, 395 insertions(+), 172 deletions(-) create mode 100644 doc/source/invirtualenv.cli.rst create mode 100644 doc/source/invirtualenv.config.rst create mode 100644 doc/source/invirtualenv.contextmanager.rst create mode 100644 doc/source/invirtualenv.deploy.rst create mode 100644 doc/source/invirtualenv.exceptions.rst create mode 100644 doc/source/invirtualenv.package.rst create mode 100644 doc/source/invirtualenv.plugin.rst create mode 100644 doc/source/invirtualenv.plugin_base.rst create mode 100644 doc/source/invirtualenv.utility.rst create mode 100644 doc/source/invirtualenv.virtualenv.rst create mode 100644 doc/source/invirtualenv_plugins.docker.rst create mode 100644 doc/source/invirtualenv_plugins.parsedconfig.rst create mode 100644 doc/source/invirtualenv_plugins.rpm.rst create mode 100644 doc/source/invirtualenv_plugins.rpm_scripts.post_install.rst create mode 100644 doc/source/invirtualenv_plugins.rpm_scripts.pre_uninstall.rst create mode 100644 doc/source/invirtualenv_plugins.rpm_scripts.rst create mode 100644 doc/source/invirtualenv_plugins.rst create mode 100644 tests/test_contextmanager.py diff --git a/MANIFEST.in b/MANIFEST.in index ccc8592..7949b87 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,4 @@ -include README.md include README.rst -include README.txt prune .tox diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index e299e6d..09a05f2 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -7,13 +7,17 @@ functionality and usage. .. _deploy.conf: -deploy.conf -=========== +deploy.conf - Deployment configuration file +=========================================== The :ref:`deploy.conf` file allows for setting all configuration arguments in a single file. This allows running the script without any other command line arguments. +The same file can be used for deployment and generation of deployment packages +in multiple packaging formats. Current supported deployment packaging formats +are: rpm and docker containers. + The :ref:`deploy.conf` file is a Python :py:mod:`ConfigParse` format configuration file. This file consists of sections which are deliminated by square brackets. Inside each section are key/value fields. Multi-Line @@ -29,11 +33,12 @@ BUILD_NUMBER environment variable provided by the CI pipeline for example. .. _[global]: -deploy.conf global section settings -################################### +global settings +############### The :ref:`[global]` section of the :ref:`deploy.conf` defines a number of -settings. All of which are optional. +settings. All of which are optional. These settings act as the default +values if they are not set in other sections. .. _[global]name: @@ -58,7 +63,7 @@ install_manifest The :ref:`[global]install_manifest` setting specifies a comma seperated list of manifests to install. If this setting is not set all package manifests -will be installed. +(lists of packages) that will be installed. ** NOTE: It is generally not a good idea to mix multiple types of platform package manifests. Such as using both rpm and tar ** @@ -143,11 +148,14 @@ This setting requires the following: .. _[pip]: -deploy.conf pip section settings -################################ +pip package manifest +#################### This configuration section allows defining settings related to the installation -of python packages that are installed using the `pip` tool. +of python packages that are installed using the `pip` tool. As part of a pip +package manifest. + +This section is used to define the python packages to install. .. _[pip]deps: @@ -159,18 +167,21 @@ the deps is the same as the format of a `pip` requirements file. .. _[rpm]: -deploy.conf rpm section settings -################################ +rpm package manifest +#################### -This configuration section allows defining settings related to the installation +The [rpm] configuration section allows defining package manifests (list of packages) of rpm packages installed using the yum tool. -A few thing to note: +These is section defines a package manifest of rpm packages to install prior to +installing the python packages. + +Note: - * rpm package installations are not atomic and once installed some package - dependencies can block uninstall or upgrade of certain packages. As a - result a rpm install failure can leave the system in a different package - state than when the script run started. + rpm package installations are not atomic and once installed some package + dependencies can block uninstall or upgrade of certain packages. As a + result a rpm install failure can leave the system in a different package + state than when the script run started. .. _[rpm]deps: @@ -179,6 +190,115 @@ deps This section is a list of rpm packages to install. +docker_container packaging (creation) +##################################### + +The [docker_container] section contains the settings used to create a docker +container containing the python application in a virtualenv. This sectiion allows +for adding settings used to create the docker container. + +The docker plugin will generate basic sane container based on the defaults and values +in the global section of the configuration. + +This section can be used to set docker specific settings such as commands to use for +healthchecks of the created docker container. + + +add +~~~ + +base_image +~~~~~~~~~~ + +default=ubuntu:17.10 + +container_name +~~~~~~~~~~~~~~ + +copy +~~~~ + +deb_deps +~~~~~~~~ + +A manifest of debian packages to install into the container prior to creating the +python virtualenv. + +entrypoint +~~~~~~~~~~ + +env +~~~ + +expose +~~~~~~ + +files +~~~~~ + +healthcheck +~~~~~~~~~~~ + +This is the healthcheck script to run in the container. + +label +~~~~~ + +A list of labels to be applied to the container. + +rpm_deps +~~~~~~~~ + +A manifest of rpm packages to install into the container prior to creating the python +virtualenv. + +run_before +~~~~~~~~~~ + +A list of shell commands to run before creating the python virtualenv inside the container. + +run_after +~~~~~~~~~ + +A list of shell commands to run after creating the python virtualenv inside the container. + +setenv +~~~~~~ + +Environment variables to set when creating the container. + +stopsignal +~~~~~~~~~~ + +user +~~~~ + +volume +~~~~~~ + +A list of volume mappings to use with the container. + + +rpm packaging +############# +The [rpm_package] section defines settings related to the creation of rpm packages. +The settings in this section will overide the default values from the global settings +for rpm package generation only. + +.. _[rpm_package]deps: + +deps +~~~~ + +This is a manifest (list of packages) to be listed as dependencies of the created +rpm package. + + +Note:: + + This should include the packages that contain the python interpreter + and virtualenv commands to use to deploy the virtualenv when the created package + is installed. Example deploy.conf ################### diff --git a/doc/source/index.rst b/doc/source/index.rst index 1ad6b8e..5c7550a 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -14,5 +14,7 @@ Contents: scripts.rst configuration.rst invirtualenv.rst + invirtualenv_plugins.rst + diff --git a/doc/source/install.rst b/doc/source/install.rst index 67f8ed8..807fa1e 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -24,3 +24,4 @@ the rpm package support in the :ref:`create_package` script.:: rpm-build +The Docker container build requires the :ref:`docker` command has been installed and working. diff --git a/doc/source/invirtualenv.cli.rst b/doc/source/invirtualenv.cli.rst new file mode 100644 index 0000000..498e0f2 --- /dev/null +++ b/doc/source/invirtualenv.cli.rst @@ -0,0 +1,7 @@ +invirtualenv.cli module +======================= + +.. automodule:: invirtualenv.cli + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.config.rst b/doc/source/invirtualenv.config.rst new file mode 100644 index 0000000..4688938 --- /dev/null +++ b/doc/source/invirtualenv.config.rst @@ -0,0 +1,7 @@ +invirtualenv.config module +========================== + +.. automodule:: invirtualenv.config + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.contextmanager.rst b/doc/source/invirtualenv.contextmanager.rst new file mode 100644 index 0000000..691afaf --- /dev/null +++ b/doc/source/invirtualenv.contextmanager.rst @@ -0,0 +1,7 @@ +invirtualenv.contextmanager module +================================== + +.. automodule:: invirtualenv.contextmanager + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.deploy.rst b/doc/source/invirtualenv.deploy.rst new file mode 100644 index 0000000..570199b --- /dev/null +++ b/doc/source/invirtualenv.deploy.rst @@ -0,0 +1,7 @@ +invirtualenv.deploy module +========================== + +.. automodule:: invirtualenv.deploy + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.exceptions.rst b/doc/source/invirtualenv.exceptions.rst new file mode 100644 index 0000000..a5532bc --- /dev/null +++ b/doc/source/invirtualenv.exceptions.rst @@ -0,0 +1,7 @@ +invirtualenv.exceptions module +============================== + +.. automodule:: invirtualenv.exceptions + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.package.rst b/doc/source/invirtualenv.package.rst new file mode 100644 index 0000000..8415cc2 --- /dev/null +++ b/doc/source/invirtualenv.package.rst @@ -0,0 +1,7 @@ +invirtualenv.package module +=========================== + +.. automodule:: invirtualenv.package + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.plugin.rst b/doc/source/invirtualenv.plugin.rst new file mode 100644 index 0000000..e7d3e7c --- /dev/null +++ b/doc/source/invirtualenv.plugin.rst @@ -0,0 +1,7 @@ +invirtualenv.plugin module +========================== + +.. automodule:: invirtualenv.plugin + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.plugin_base.rst b/doc/source/invirtualenv.plugin_base.rst new file mode 100644 index 0000000..3214058 --- /dev/null +++ b/doc/source/invirtualenv.plugin_base.rst @@ -0,0 +1,7 @@ +invirtualenv.plugin\_base module +================================ + +.. automodule:: invirtualenv.plugin_base + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.rst b/doc/source/invirtualenv.rst index d9988c6..710d4cb 100644 --- a/doc/source/invirtualenv.rst +++ b/doc/source/invirtualenv.rst @@ -1,5 +1,5 @@ -Python module invirtualenv -******************************** +Python invirtualenv module code documentation +********************************************* Python module support functions for the invirtualenv scripts diff --git a/doc/source/invirtualenv.utility.rst b/doc/source/invirtualenv.utility.rst new file mode 100644 index 0000000..4008edf --- /dev/null +++ b/doc/source/invirtualenv.utility.rst @@ -0,0 +1,7 @@ +invirtualenv.utility module +=========================== + +.. automodule:: invirtualenv.utility + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv.virtualenv.rst b/doc/source/invirtualenv.virtualenv.rst new file mode 100644 index 0000000..090e5bb --- /dev/null +++ b/doc/source/invirtualenv.virtualenv.rst @@ -0,0 +1,7 @@ +invirtualenv.virtualenv module +============================== + +.. automodule:: invirtualenv.virtualenv + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.docker.rst b/doc/source/invirtualenv_plugins.docker.rst new file mode 100644 index 0000000..c49c2f7 --- /dev/null +++ b/doc/source/invirtualenv_plugins.docker.rst @@ -0,0 +1,7 @@ +invirtualenv\_plugins.docker module +=================================== + +.. automodule:: invirtualenv_plugins.docker + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.parsedconfig.rst b/doc/source/invirtualenv_plugins.parsedconfig.rst new file mode 100644 index 0000000..301452a --- /dev/null +++ b/doc/source/invirtualenv_plugins.parsedconfig.rst @@ -0,0 +1,7 @@ +invirtualenv\_plugins.parsedconfig module +========================================= + +.. automodule:: invirtualenv_plugins.parsedconfig + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.rpm.rst b/doc/source/invirtualenv_plugins.rpm.rst new file mode 100644 index 0000000..2b4c130 --- /dev/null +++ b/doc/source/invirtualenv_plugins.rpm.rst @@ -0,0 +1,7 @@ +invirtualenv\_plugins.rpm module +================================ + +.. automodule:: invirtualenv_plugins.rpm + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.rpm_scripts.post_install.rst b/doc/source/invirtualenv_plugins.rpm_scripts.post_install.rst new file mode 100644 index 0000000..9ffd76a --- /dev/null +++ b/doc/source/invirtualenv_plugins.rpm_scripts.post_install.rst @@ -0,0 +1,7 @@ +invirtualenv\_plugins.rpm\_scripts.post\_install module +======================================================= + +.. automodule:: invirtualenv_plugins.rpm_scripts.post_install + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.rpm_scripts.pre_uninstall.rst b/doc/source/invirtualenv_plugins.rpm_scripts.pre_uninstall.rst new file mode 100644 index 0000000..b565c34 --- /dev/null +++ b/doc/source/invirtualenv_plugins.rpm_scripts.pre_uninstall.rst @@ -0,0 +1,7 @@ +invirtualenv\_plugins.rpm\_scripts.pre\_uninstall module +======================================================== + +.. automodule:: invirtualenv_plugins.rpm_scripts.pre_uninstall + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/invirtualenv_plugins.rpm_scripts.rst b/doc/source/invirtualenv_plugins.rpm_scripts.rst new file mode 100644 index 0000000..42caffa --- /dev/null +++ b/doc/source/invirtualenv_plugins.rpm_scripts.rst @@ -0,0 +1,16 @@ +invirtualenv\_plugins.rpm\_scripts package +========================================== + +.. automodule:: invirtualenv_plugins.rpm_scripts + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +.. toctree:: + + invirtualenv_plugins.rpm_scripts.post_install + invirtualenv_plugins.rpm_scripts.pre_uninstall + diff --git a/doc/source/invirtualenv_plugins.rst b/doc/source/invirtualenv_plugins.rst new file mode 100644 index 0000000..499d248 --- /dev/null +++ b/doc/source/invirtualenv_plugins.rst @@ -0,0 +1,24 @@ +invirtualenv\_plugins package +============================= + +.. automodule:: invirtualenv_plugins + :members: + :undoc-members: + :show-inheritance: + +Subpackages +----------- + +.. toctree:: + + invirtualenv_plugins.rpm_scripts + +Submodules +---------- + +.. toctree:: + + invirtualenv_plugins.docker + invirtualenv_plugins.parsedconfig + invirtualenv_plugins.rpm + diff --git a/doc/source/scripts.rst b/doc/source/scripts.rst index 0627e1d..282e9b7 100644 --- a/doc/source/scripts.rst +++ b/doc/source/scripts.rst @@ -2,7 +2,37 @@ Scripts ******* -Python module support functions for the invirtualenv scripts +Invirtualenv command line utilities. + +invirtualenv +============ + +The `invirtualenv` command line tool is used to perform invirtualenv operations. This script is meant to replace the +`create_package` and `deploy_virtualenv` scripts that are still provided for backwards compatibility. + +invirtualenv usage +################## + +The invirtualenv command takes a number of subcommands used to specify the invirtualenv function to perform:: + + usage: invirtualenv [-h] [--deploy_conf DEPLOY_CONF] + {list_plugins,create_package_config,create_package,get_setting} + ... + + optional arguments: + -h, --help show this help message and exit + --deploy_conf DEPLOY_CONF + Deploy configuration filename or url (default: + deploy.conf) + + command: + {list_plugins,create_package_config,create_package,get_setting} + list_plugins List the installed invirtualenv plugins + create_package_config + Generate the packaging configuration file + create_package Generate a package from a deployment configuration + get_setting Get a setting value from the configuration + .. _deploy_virtualenv: diff --git a/examples/deploy.conf b/examples/deploy.conf index d50adf6..e2cdffb 100644 --- a/examples/deploy.conf +++ b/examples/deploy.conf @@ -13,7 +13,7 @@ name = public_mirror ; The python interpreter to use for the virtualenv ; this will default to the python interpreter running the virtualenv ; command if it is not specified. -basepython = python2.7 +basepython = python3 ; Base directory to create virtualenv in virtualenv_dir = /var/tmp/virtualenv diff --git a/invirtualenv/contextmanager.py b/invirtualenv/contextmanager.py index 7e40b3e..de673c3 100644 --- a/invirtualenv/contextmanager.py +++ b/invirtualenv/contextmanager.py @@ -42,7 +42,7 @@ def revert_file(filename): try: yield finally: - if original_data: + if original_data: # pragma: no cover with open(filename, 'wb') as file_handle: file_handle.write(original_data) diff --git a/invirtualenv/utility.py b/invirtualenv/utility.py index 7eb3af1..e25f51a 100644 --- a/invirtualenv/utility.py +++ b/invirtualenv/utility.py @@ -106,7 +106,13 @@ def which(command): Raises ------ + CommandNotFound: + Command was not found """ + bin_dir = os.path.dirname(sys.executable) + bin_exe = os.path.join(bin_dir, command) + if os.path.exists(bin_exe) and os.access(bin_exe, os.X_OK): # pragma: no cover + return bin_exe result = find_executable(command) if not result: # pragma: no cover raise CommandNotFound('Command %r was not found in the path' % command) diff --git a/invirtualenv_plugins/docker_scripts/docker_build.sh b/invirtualenv_plugins/docker_scripts/docker_build.sh index 9a9e3a5..7bd46c6 100644 --- a/invirtualenv_plugins/docker_scripts/docker_build.sh +++ b/invirtualenv_plugins/docker_scripts/docker_build.sh @@ -3,29 +3,56 @@ set -e INVIRTUALENV_DIR="/var/lib/invirtualenv" INSTALLVENV="/var/lib/invirtualenv/installvenv" +VENV_COMMAND="virtualenv" +PYTHON="python3" function init_directories { mkdir -p "/var/lib/virtualenvs" mkdir -p "${INVIRTUALENV_DIR}" } +function init_alpine { + echo "Configuring container for alpine packaging" + apk add python3 python3-dev coreutils zip gcc libxml2 libxslt musl-dev libxslt-dev linux-headers make + VENV_COMMAND="python3 -m venv" +} + function init_debian { echo "Configuring container for debian packaging" DEBIAN_FRONTEND="noninteractive" export DEBIAN_FRONTEND apt-get update apt-get upgrade -y - apt-get install -y python-dev python-pip python-virtualenv + + set +e + apt-get install -y python3-dev python3-venv build-essential + RC="$?" + set -e + if [ "$RC" != "0" ]; then + apt-get install -y python-dev python-pip python-virtualenv build-essential + VENV_COMMAND="virtualenv" + else + VENV_COMMAND="python3 -m venv" + fi } function init_rpm { echo "Configuring container for rpm packaging" - yum upgrade -y - yum install -y python-devel python-virtualenv + VENV_COMMAND="virtualenv" + # yum upgrade -y + yum groupinstall -y 'development tools' + set +e + yum install -y python3-devel python3 python3-virtualenv + RC="$?" + set -e + if [ "$RC" != "0" ]; then + yum install -y python-devel python-virtualenv + fi } function install_invirtualenv { - virtualenv "${INSTALLVENV}" + echo "Bootstrapping the invirtualenv package" + $VENV_COMMAND "${INSTALLVENV}" venv_pip="${INSTALLVENV}/bin/pip" ${venv_pip} install -U setuptools @@ -35,7 +62,8 @@ function install_invirtualenv { } function deploy { - cwd=`pwd` + echo "Deploying application virtualenv" + cwd="`pwd`" cd "${INVIRTUALENV_DIR}" cat deploy.conf ${INSTALLVENV}/bin/deploy_virtualenv @@ -54,6 +82,10 @@ if [ -e "/usr/bin/yum" ]; then init_rpm fi +if [ -e "/sbin/apk" ]; then + init_alpine +fi + install_invirtualenv deploy diff --git a/setup.py b/setup.py index 19c34d9..251d14e 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from setuptools import setup # Default version number -BASE_VERSION = '19.1.0' +BASE_VERSION = '19.1.1' METADATA_FILENAME = 'invirtualenv/package_metadata.json' BASEPATH = os.path.dirname(os.path.abspath(__file__)) METADATA_FILE = os.path.join(BASEPATH, METADATA_FILENAME) diff --git a/tests/test_contextmanager.py b/tests/test_contextmanager.py new file mode 100644 index 0000000..780e126 --- /dev/null +++ b/tests/test_contextmanager.py @@ -0,0 +1,15 @@ +import unittest +import invirtualenv.contextmanager + + +class TestContextmanager(unittest.TestCase): + def test__revert_file(self): + with invirtualenv.contextmanager.InTemporaryDirectory(): + with open('testfile', 'w') as fh: + fh.write('original') + self.assertEqual('original', open('testfile').read()) + with invirtualenv.contextmanager.revert_file('testfile'): + with open('testfile', 'w') as fh: + fh.write('changed') + self.assertEqual('changed', open('testfile').read()) + self.assertEqual('original', open('testfile').read()) diff --git a/tests/test_plugin__parsed_config.py b/tests/test_plugin__parsed_config.py index 6c1ef83..91b39b1 100644 --- a/tests/test_plugin__parsed_config.py +++ b/tests/test_plugin__parsed_config.py @@ -14,7 +14,7 @@ [pip] deps: - invirtualenv + confset """ @@ -26,3 +26,10 @@ def test__config_file__argument(self): plugin = InvirtualenvParsedConfig(config_file='deploy.conf') self.assertEqual(plugin.config_file, 'deploy.conf') self.assertEqual(plugin.config['global']['name'], 'test') + + def test__config_file__create(self): + with InTemporaryDirectory(): + with open('deploy.conf', 'w') as config_handle: + config_handle.write(deploy_conf) + plugin = InvirtualenvParsedConfig(config_file='deploy.conf') + plugin.create_package('parsed_deploy_conf') diff --git a/tox.ini b/tox.ini index 49ca326..e378d81 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,10 @@ +[config] +package_dir = invirtualenv +package_name = invirtualenv + [tox] skip_missing_interpreters = True -envlist = pycodestyle, pylint, py27, py34, py35, py36, py37 +envlist = pycodestyle, pylint, py27, py35, py36, py37 [testenv] deps = @@ -9,13 +13,6 @@ deps = commands = pytest --cov=invirtualenv --cov-report=xml:cobertura.xml --cov-report term-missing tests/ -[testenv:pep8] -basepython = python3 -envdir = {toxworkdir}/linter -deps = - pep8 -commands = pep8 invirtualenv - [testenv:pycodestyle] basepython = python3 envdir = {toxworkdir}/linter @@ -35,16 +32,17 @@ commands = [testenv:doc_build] envdir = {toxworkdir}/build_docs -basepython = python3.4 +basepython = python3 deps = sphinx sphinx_rtd_theme recommonmark + commands = python setup.py build_sphinx [testenv:freeze] -basepython = python3.4 +basepython = python3 envdir = {toxworkdir}/freeze whitelist_externals = cd @@ -57,138 +55,7 @@ commands = pyinstaller --onefile {envdir}/bin/create_package tar -C dist -czf frozen_scripts.tar.gz deploy_virtualenv create_package -[pep8] -ignore = E1,E2,E3,E4,E5,W293 -max_line_length = 160 - [pycodestyle] ignore = E1,E2,E3,E4,E5,W293 max_line_length = 160 -[config] -added_by = yahoo.platform_init -package_dir = invirtualenv -package_name = invirtualenv - -[testenv:lint_pep8] -added_by = yahoo.platform_init -deps = - six - pep8 -commands = {envpython} {envbindir}/pep8 {[config]package_dir} -changedir = {toxinidir} -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = SSH_AUTH_SOCK BUILD_NUMBER -extras = - pep8 -basepython = python3 - -[testenv:lint_codestyle] -added_by = yahoo.platform_init -deps = - six - pycodestyle -commands = {envpython} {envbindir}/pycodestyle {[config]package_dir} -changedir = {toxinidir} -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = SSH_AUTH_SOCK BUILD_NUMBER -extras = - pep8 -basepython = python3 - -[testenv:lint_pylint] -added_by = yahoo.platform_init -deps = - six - pylint -commands = {envpython} {envbindir}/pylint --output-format=parseable {[config]package_dir} -changedir = {toxinidir} -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = SSH_AUTH_SOCK BUILD_NUMBER -extras = - pylint -basepython = python3 - -[testenv:lint_mypy] -added_by = yahoo.platform_init -basepython = python3 -deps = - mypy - lxml -commands = - {envpython} {envbindir}/mypy -p {[config]package_name} --strict --ignore-missing-imports --txt-report artifacts/mypy - cat artifacts/mypy/index.txt -changedir = {toxinidir} -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = SSH_AUTH_SOCK BUILD_NUMBER -extras = - mypy -ignore_outcome = True - -[testenv:doc_publish] -added_by = yahoo.platform_init -deps = - sphinx - sphinx_rtd_theme - guzzle_sphinx_theme - recommonmark - yahoo.platform_publish_doc -commands = {envpython} {envbindir}/gh_publish -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = SSH_AUTH_SOCK BUILD_NUMBER -changedir = {toxinidir} -extras = - doc_build -ignore_outcome = True -basepython = python3 - -[testenv:tag_release] -added_by = yahoo.platform_init -deps = - six - yahoo.platform_tagrelease -commands = {envpython} {envbindir}/tagrelease -passenv = SSH_AUTH_SOCK BUILD_NUMBER -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -changedir = {toxinidir} -ignore_outcome = True -basepython = python3 - -[testenv:package_publish] -added_by = yahoo.platform_init -deps = yahoo.platform_publish -commands = {envpython} {envbindir}/screwdriver_v3_python_publish.py -passenv = SSH_AUTH_SOCK BUILD_NUMBER -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -changedir = {toxinidir} - -[testenv:package_yinst] -added_by = yahoo.platform_init -commands = create_package --package_type yinst_release -deps = yahoo.invirtualenv -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -passenv = BUILD_NUMBER SSH_AUTH_SOCK -whitelist_externals = yinst - -[testenv:add_api_docs] -added_by = yahoo.platform_init -deps = - sphinx -commands = - {envpython} {envbindir}/sphinx-apidoc -T -e -M -o doc/source/ . "artifacts/*" "dist/*" "screwdriver/*" "scripts/*" setup.py "tests/*" -changedir = {toxinidir} -extras = - doc_build -passenv = SSH_AUTH_SOCK BUILD_NUMBER -install_command = {envpython} {envbindir}/pip install {opts} {packages} -list_dependencies_command = {envpython} {envbindir}/pip freeze -basepython = python3 -