Moving version to a single place in version.py (#358)

* Moving version to a single place in version.py
* Requirements in setup.py + tox.ini
This commit is contained in:
Mike Terzo
2017-02-13 00:35:15 -05:00
committed by GitHub
parent 35486e8e49
commit 1e5f683b66
13 changed files with 142 additions and 94 deletions

View File

@@ -6,28 +6,27 @@ python:
- "3.5"
- "3.6"
env:
- PINNED=TRUE
- PINNED=FALSE
global:
- TEST_DEPS="True"
matrix:
- DEPS_RESOLVE=""
- DEPS_RESOLVE="PINNED"
- DEPS_RESOLVE="UNPINNED"
matrix:
allow_failures:
- python: 2.6
env: PINNED=FALSE
- python: 2.7
env: PINNED=FALSE
- python: 3.5
env: PINNED=FALSE
- python: 3.6
env: PINNED=FALSE
- env: DEPS_RESOLVE="UNPINNED"
install:
- if [ "${PINNED}" == "FALSE" ]; then python scripts/unpin.py; fi
# Travis already include pytest, need to upgrade it when unpinned
- if [[ "${DEPS_RESOLVE}" == "UNPINNED" ]]; then pip install -U pytest; fi
- pip install -r requirements.txt
- pip install -U -r requirements-test.txt
- pip install -q coverage coveralls --use-wheel
- pip install -q coveralls --use-wheel
script:
- py.test --cov=puppetboard --pep8 -v
- ./bandit.sh
- if [ "${TRAVIS_PYTHON_VERSION}" != "2.6" ]; then bandit -r puppetboard; fi
- if [ "${TRAVIS_PYTHON_VERSION}" != "2.6" ]; then bandit -r tests; fi
after_success:
- coveralls

View File

@@ -1,12 +1,14 @@
FROM python:2.7-alpine
ENV PUPPETBOARD_PORT 80
ENV PUPPETBOARD_SETTINGS docker_settings.py
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
EXPOSE 80
COPY requirements-docker.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements-docker.txt
COPY . /usr/src/app
ENV PUPPETBOARD_SETTINGS docker_settings.py
RUN mkdir -p /puppetboard
WORKDIR /puppetboard
COPY . /puppetboard
RUN python setup.py install docker
RUN rm -rf /puppetboard
CMD gunicorn -b 0.0.0.0:${PUPPETBOARD_PORT} --access-logfile=/dev/stdout puppetboard.app:app

View File

@@ -1,12 +0,0 @@
#!/bin/bash -xe
# Runs bandit tests
pyver="$(python -V 2>&1)"
if [[ $pyver =~ Python\ 2\.6 ]]
then
echo 'Bandit does not support python 2.6'
else
bandit -r puppetboard
bandit -r tests
fi

View File

@@ -0,0 +1,5 @@
#
# Pupppetboard
#
from .version import __version__

View File

@@ -29,6 +29,8 @@ from puppetboard.dailychart import get_daily_reports_chart
import werkzeug.exceptions as ex
from . import __version__
REPORTS_COLUMNS = [
{'attr': 'end', 'filter': 'end_time',
'name': 'End time', 'type': 'datetime'},
@@ -66,6 +68,11 @@ logging.basicConfig(level=numeric_level)
log = logging.getLogger(__name__)
@app.template_global()
def version():
return __version__
def stream_template(template_name, **context):
app.update_template_context(context)
t = app.jinja_env.get_template(template_name)

View File

@@ -87,7 +87,7 @@
{% endfor %}
</div>
</div>
<div class="item right"><a href="https://github.com/voxpupuli/puppetboard" target="_blank">v0.2.1</a></div>
<div class="item right"><a href="https://github.com/voxpupuli/puppetboard" target="_blank">{{version()}}</a></div>
</div>
<div class="ui grid padding-bottom">
<div class="one wide column"></div>

5
puppetboard/version.py Normal file
View File

@@ -0,0 +1,5 @@
#
# Puppetboard version module
#
__version__ = '0.3.0.dev0'

View File

@@ -1,10 +0,0 @@
gunicorn==19.6.0
Flask==0.10.1
Flask-WTF==0.12
Jinja2==2.7.2
MarkupSafe==0.19
WTForms==2.1
Werkzeug==0.11.10
itsdangerous==0.23
pypuppetdb==0.3.2
requests==2.6.0

View File

@@ -1,11 +0,0 @@
pep8==1.6.2
coverage==4.0
mock==1.3.0
pytest==3.0.1
pytest-pep8==1.0.5
pytest-cov==2.2.1
pytest-mock==1.5.0
cov-core==1.15.0
unittest2==1.1.0; python_version < '2.7'
bandit
beautifulsoup4==4.5.3

View File

@@ -1,9 +1 @@
Flask==0.10.1
Flask-WTF==0.12
Jinja2==2.7.2
MarkupSafe==0.19
WTForms==2.1
Werkzeug==0.11.10
itsdangerous==0.23
pypuppetdb==0.3.2
requests==2.6.0
-e .

View File

@@ -1,19 +0,0 @@
#!/usr/bin/env python
import glob
import re
try:
import future.utils
except:
pass
for req_file in glob.glob('requirements*.txt'):
new_data = []
with open(req_file, 'r') as fp:
data = fp.readlines()
for line in data:
new_data.append(re.sub(r'==\d+(\.\d+){0,3}\s+$', '\n', line))
with open(req_file, 'w') as fp:
fp.writelines(new_data)

100
setup.py
View File

@@ -1,15 +1,64 @@
import sys
import os
import codecs
import re
from setuptools import setup, find_packages
from puppetboard.version import __version__
install_requires = [
"Flask >= 0.10.1",
"Flask-WTF >= 0.12, <= 0.13",
"WTForms >= 2.0, < 3.0",
"pypuppetdb >= 0.3.2, < 0.4.0",
]
install_pinned_requires = [
"Jinja2 >= 2.7.2",
"MarkupSafe >= 0.19",
"Werkzeug >= 0.11.10",
"itsdangerous >= 0.23",
"requests == 2.6.0",
]
tests_require = [
"pytest >= 3.0.1",
"pytest-pep8 >= 1.0.5",
"pytest-cov >= 2.2.1",
"pytest-mock >= 1.5.0",
"mock >= 1.3.0",
"bandit",
"beautifulsoup4 >= 4.5.3",
]
tests_pinned_requires = [
"pep8 >= 1.6.2",
"coverage >= 4.0",
"cov-core >= 1.15.0",
]
if sys.version_info < (2, 7):
tests_pinned_requires.append("unittest2 >= 1.1.0")
docker_requires = [
"gunicorn == 19.6.0",
]
version_parse = r'^(?P<name>[^\s<=>]+)\s*(?P<pick>[^;]*)(?P<test>(|;.*))$'
if sys.argv[-1] == 'publish':
os.system('python setup.py sdist upload')
sys.exit()
def unpin(requirements):
for i, package in enumerate(requirements):
requirements[i] = re.sub(version_parse, r'\g<name> \g<test>', package)
VERSION = "0.2.1"
def pin(requirements):
for i, package in enumerate(requirements):
match = re.match(version_parse, package)
version = re.sub(
r'^.*((>=|==)\s*(?P<lower>[^,]+)).*$', r'== \g<lower>',
match.group('pick'))
requirements[i] = "%s %s%s" % (
match.group('name'), version, match.group('test'))
with codecs.open('README.rst', encoding='utf-8') as f:
README = f.read()
@@ -17,9 +66,42 @@ with codecs.open('README.rst', encoding='utf-8') as f:
with codecs.open('CHANGELOG.rst', encoding='utf-8') as f:
CHANGELOG = f.read()
test_deps = False
if os.environ.get('TEST_DEPS') in ('y', 'true', 'True', 't'):
test_deps = True
deps_resolve = os.environ.get('DEPS_RESOLVE')
for arg in sys.argv[:]:
if arg == 'publish':
sys.argv = [sys.argv[0], 'sdist', 'upload']
break
elif arg == 'docker':
sys.argv.remove(arg)
install_requires.extend(docker_requires)
elif arg == 'unpinned':
sys.argv.remove(arg)
deps_resolve = 'UNPINNED'
elif arg == 'pinned':
sys.argv.remove(arg)
deps_resolve = 'PINNED'
elif arg == 'with_test':
sys.argv.remove(arg)
test_deps = True
if test_deps:
install_requires.extend(tests_require)
if deps_resolve == 'UNPINNED':
unpin(install_requires)
elif deps_resolve == 'PINNED':
install_requires.extend(install_pinned_requires)
if test_deps:
install_requires.extend(tests_pinned_requires)
pin(install_requires)
setup(
name='puppetboard',
version=VERSION,
version=__version__,
author='Corey Hammerton',
author_email='corey.hammerton@gmail.com',
packages=find_packages(),
@@ -29,12 +111,8 @@ setup(
include_package_data=True,
long_description='\n'.join((README, CHANGELOG)),
zip_safe=False,
install_requires=[
"Flask >= 0.10.1",
"Flask-WTF >= 0.12, <= 0.13",
"WTForms >= 2.0, < 3.0",
"pypuppetdb >= 0.3.0, < 0.4.0",
],
install_requires=install_requires,
test_requires=tests_require,
keywords="puppet puppetdb puppetboard",
classifiers=[
'Development Status :: 3 - Alpha',

12
tox.ini Normal file
View File

@@ -0,0 +1,12 @@
[tox]
envlist = py{26,27,35,36}-{default,pinned,unpinned}
[testenv]
setenv =
TEST_DEPS=True
pinned: DEPS_RESOLVE=PINNED
unpinned: DEPS_RESOLVE=UNPINNED
commands=
py.test --cov=puppetboard --pep8 -v
py{27,35,36}: bandit -r puppetboard
py{27,35,36}: bandit -r tests