import os
from setuptools import setup, find_packages

__here__ = os.path.dirname(os.path.abspath(__file__))

package_info = dict.fromkeys(["RELEASE", "COMMIT", "VERSION", "NAME"])

for name in package_info:
    with open(os.path.join(__here__, "insights", name)) as f:
        package_info[name] = f.read().strip()

entry_points = {
    'console_scripts': [
        'insights-run = insights:main',
        'insights-info = insights.tools.query:main',
        'gen_api = insights.tools.generate_api_config:main',
        'insights-perf = insights.tools.perf:main',
        'client = insights.client:run',
        'mangle = insights.util.mangle:main'
    ]
}

runtime = set([
    'pyyaml>=3.10,<=3.13',
    'six',
])


def maybe_require(pkg):
    try:
        __import__(pkg)
    except ImportError:
        runtime.add(pkg)


maybe_require("importlib")
maybe_require("argparse")


client = set([
    'requests',
    'pyOpenSSL',
])

develop = set([
    'futures==3.0.5',
    'requests==2.13.0',
    'wheel',
])

docs = set([
    'Sphinx==1.7.9',
    'nbsphinx==0.3.1',
    'sphinx_rtd_theme',
    'ipython<6',
    'colorama',
])

testing = set([
    'coverage==4.3.4',
    'pytest==3.0.6',
    'pytest-cov==2.4.0',
    'mock==2.0.0',
])

linting = set([
    'flake8==3.3.0',
])

optional = set([
    'jinja2',
    'python-cjson',
    'python-logstash',
    'python-statsd',
    'watchdog',
])

if __name__ == "__main__":
    # allows for runtime modification of rpm name
    name = os.environ.get("INSIGHTS_CORE_NAME", package_info["NAME"])

    setup(
        name=name,
        version=package_info["VERSION"],
        description="Insights Core is a data collection and analysis framework",
        long_description=open("README.rst").read(),
        url="https://github.com/redhatinsights/insights-core",
        author="Red Hat, Inc.",
        author_email="insights@redhat.com",
        packages=find_packages(),
        install_requires=list(runtime),
        package_data={'': ['LICENSE']},
        license='Apache 2.0',
        extras_require={
            'develop': list(runtime | develop | client | docs | linting | testing),
            'client': list(runtime | client),
            'optional': list(optional),
            'docs': list(docs),
            'linting': list(linting | client),
            'testing': list(testing | client)
        },
        classifiers=[
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Natural Language :: English',
            'License :: OSI Approved :: Apache Software License',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Programming Language :: Python :: 3.6'
        ],
        entry_points=entry_points,
        include_package_data=True
    )

setup.py
import os
from setuptools import setup, find_packages

__here__ = os.path.dirname(os.path.abspath(__file__))

package_info = dict.fromkeys(["RELEASE", "COMMIT", "VERSION", "NAME"])

for name in package_info:
    with open(os.path.join(__here__, "insights", name)) as f:
        package_info[name] = f.read().strip()

entry_points = {
    'console_scripts': [
        'insights-run = insights:main',
        'insights-info = insights.tools.query:main',
        'gen_api = insights.tools.generate_api_config:main',
        'insights-perf = insights.tools.perf:main',
        'client = insights.client:run',
        'mangle = insights.util.mangle:main'
    ]
}

runtime = set([
    'pyyaml>=3.10,<=3.13',
    'six',
])


def maybe_require(pkg):
    try:
        __import__(pkg)
    except ImportError:
        runtime.add(pkg)


maybe_require("importlib")
maybe_require("argparse")


client = set([
    'requests',
    'pyOpenSSL',
])

develop = set([
    'futures==3.0.5',
    'requests==2.13.0',
    'wheel',
])

docs = set([
    'Sphinx==1.7.9',
    'nbsphinx==0.3.1',
    'sphinx_rtd_theme',
    'ipython<6',
    'colorama',
])

testing = set([
    'coverage==4.3.4',
    'pytest==3.0.6',
    'pytest-cov==2.4.0',
    'mock==2.0.0',
])

linting = set([
    'flake8==2.6.2',
])

optional = set([
    'jinja2',
    'python-cjson',
    'python-logstash',
    'python-statsd',
    'watchdog',
])

if __name__ == "__main__":
    # allows for runtime modification of rpm name
    name = os.environ.get("INSIGHTS_CORE_NAME", package_info["NAME"])

    setup(
        name=name,
        version=package_info["VERSION"],
        description="Insights Core is a data collection and analysis framework",
        long_description=open("README.rst").read(),
        url="https://github.com/redhatinsights/insights-core",
        author="Red Hat, Inc.",
        author_email="insights@redhat.com",
        packages=find_packages(),
        install_requires=list(runtime),
        package_data={'': ['LICENSE']},
        license='Apache 2.0',
        extras_require={
            'develop': list(runtime | develop | client | docs | linting | testing),
            'client': list(runtime | client),
            'optional': list(optional),
            'docs': list(docs),
            'linting': list(linting | client),
            'testing': list(testing | client)
        },
        classifiers=[
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Natural Language :: English',
            'License :: OSI Approved :: Apache Software License',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Programming Language :: Python :: 3.6'
        ],
        entry_points=entry_points,
        include_package_data=True
    )

setup.py
diff --git a/Jenkinsfile b/Jenkinsfile
index d622ffc54d..44a1334efc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -26,6 +26,15 @@ pipeline {
                 pip install -e .[testing]
                 pytest
             """
+            echo "Testing with Linter..."
+            sh """
+                virtualenv .lintenv
+                source .lintenv/bin/activate
+                pip install "pycparser<=2.18"
+                pip install "pyOpenSSL<=17.5.0"
+                pip install -e .[linting]
+                flake8
+            """
           }
         }
         stage('Build RHEL7 Python 2.7') {
diff --git a/setup.py b/setup.py
index 23f41c8280..198bd3afae 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ def maybe_require(pkg):
 ])
 
 linting = set([
-    'flake8==3.3.0',
+    'flake8==2.6.2',
 ])
 
 optional = set([

Run Flake8 lint on RHEL6
Currently, flake8 is run only on RHEL7 and 8 and not on RHEL6. According to [the documentation](http://flake8.pycqa.org/en/latest/#installation) it is necessary to run flake8 with the exact Python version that is used. Thus to be sure that the syntax is ok even for the older Python version, we have to run in to RHEL6 too.

Tackled in #1251.
