Merge pull request #375 from mterzo/better_requirements
Simple requirements
This commit is contained in:
25
.travis.yml
25
.travis.yml
@@ -5,28 +5,15 @@ python:
|
|||||||
- "2.7"
|
- "2.7"
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.6"
|
- "3.6"
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- TEST_DEPS="True"
|
|
||||||
matrix:
|
|
||||||
- DEPS_RESOLVE=""
|
|
||||||
- DEPS_RESOLVE="PINNED"
|
|
||||||
- DEPS_RESOLVE="UNPINNED"
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- env: DEPS_RESOLVE="UNPINNED"
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
# Travis already include pytest, need to upgrade it when unpinned
|
- pip install -r requirements-test.txt
|
||||||
- if [[ "${DEPS_RESOLVE}" == "UNPINNED" ]]; then pip install -U pytest; fi
|
|
||||||
- pip install -r requirements.txt
|
|
||||||
- pip install -q coveralls --use-wheel
|
- pip install -q coveralls --use-wheel
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- py.test --cov=puppetboard --pep8 -v
|
- pytest
|
||||||
- if [ "${TRAVIS_PYTHON_VERSION}" != "2.6" ]; then bandit -r puppetboard; fi
|
- if [ "${TRAVIS_PYTHON_VERSION}" != "2.6" ]; then
|
||||||
- if [ "${TRAVIS_PYTHON_VERSION}" != "2.6" ]; then bandit -r tests; fi
|
pip install bandit;
|
||||||
|
bandit -r puppetboard;
|
||||||
|
fi
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
- coveralls
|
||||||
|
|||||||
11
Dockerfile
11
Dockerfile
@@ -4,11 +4,12 @@ ENV PUPPETBOARD_PORT 80
|
|||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
ENV PUPPETBOARD_SETTINGS docker_settings.py
|
ENV PUPPETBOARD_SETTINGS docker_settings.py
|
||||||
RUN mkdir -p /puppetboard
|
RUN mkdir -p /usr/src/app/
|
||||||
WORKDIR /puppetboard
|
WORKDIR /usr/src/app/
|
||||||
|
|
||||||
COPY . /puppetboard
|
COPY requirements*.txt /usr/src/app/
|
||||||
RUN python setup.py install docker
|
RUN pip install -r requirements-docker.txt
|
||||||
RUN rm -rf /puppetboard
|
|
||||||
|
COPY . /usr/src/app
|
||||||
|
|
||||||
CMD gunicorn -b 0.0.0.0:${PUPPETBOARD_PORT} --access-logfile=/dev/stdout puppetboard.app:app
|
CMD gunicorn -b 0.0.0.0:${PUPPETBOARD_PORT} --access-logfile=/dev/stdout puppetboard.app:app
|
||||||
|
|||||||
2
requirements-docker.txt
Normal file
2
requirements-docker.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-r requirements.txt
|
||||||
|
gunicorn==19.6.0
|
||||||
11
requirements-test.txt
Normal file
11
requirements-test.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-r requirements.txt
|
||||||
|
pep8==1.7.0
|
||||||
|
coverage==4.3.4
|
||||||
|
mock==1.3.0
|
||||||
|
pytest==3.0.7
|
||||||
|
pytest-pep8==1.0.6
|
||||||
|
pytest-cov==2.4.0
|
||||||
|
pytest-mock==1.5.0
|
||||||
|
cov-core==1.15.0
|
||||||
|
unittest2==1.1.0; python_version < '2.7'
|
||||||
|
beautifulsoup4==4.5.3
|
||||||
@@ -1 +1,9 @@
|
|||||||
-e .
|
Flask >=0.10.1
|
||||||
|
Flask-WTF >=0.12,<=0.13
|
||||||
|
Jinja2 >=2.7.2
|
||||||
|
MarkupSafe >=0.19
|
||||||
|
WTForms >=2.0,<3.0
|
||||||
|
Werkzeug >=0.7,<= 0.11.5
|
||||||
|
itsdangerous >=0.23
|
||||||
|
pypuppetdb >=0.3.2
|
||||||
|
requests >=2.6.0
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ exclude=venv
|
|||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = --cov=puppetboard --cov-report=term-missing
|
addopts = --cov=puppetboard --cov-report=term-missing
|
||||||
norecursedirs = docs .tox venv
|
norecursedirs = docs .tox venv .eggs lib
|
||||||
pep8ignore = E402
|
pep8ignore = E402
|
||||||
|
python_files = test/*.py
|
||||||
|
|||||||
113
setup.py
113
setup.py
@@ -2,63 +2,10 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import codecs
|
import codecs
|
||||||
import re
|
import re
|
||||||
|
from setuptools.command.test import test as TestCommand
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from puppetboard.version import __version__
|
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>(|;.*))$'
|
|
||||||
|
|
||||||
|
|
||||||
def unpin(requirements):
|
|
||||||
for i, package in enumerate(requirements):
|
|
||||||
requirements[i] = re.sub(version_parse, r'\g<name> \g<test>', package)
|
|
||||||
|
|
||||||
|
|
||||||
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:
|
with codecs.open('README.rst', encoding='utf-8') as f:
|
||||||
README = f.read()
|
README = f.read()
|
||||||
@@ -66,38 +13,32 @@ with codecs.open('README.rst', encoding='utf-8') as f:
|
|||||||
with codecs.open('CHANGELOG.rst', encoding='utf-8') as f:
|
with codecs.open('CHANGELOG.rst', encoding='utf-8') as f:
|
||||||
CHANGELOG = f.read()
|
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[:]:
|
requirements = None
|
||||||
if arg == 'publish':
|
with open('requirements.txt', 'r') as f:
|
||||||
sys.argv = [sys.argv[0], 'sdist', 'upload']
|
requirements = [line.rstrip()
|
||||||
break
|
for line in f.readlines() if not line.startswith('-')]
|
||||||
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:
|
requirements_test = None
|
||||||
install_requires.extend(tests_require)
|
with open('requirements-test.txt', 'r') as f:
|
||||||
|
requirements_test = [line.rstrip() for line in f.readlines()
|
||||||
|
if not line.startswith('-')]
|
||||||
|
|
||||||
|
|
||||||
|
class PyTest(TestCommand):
|
||||||
|
|
||||||
|
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
TestCommand.initialize_options(self)
|
||||||
|
self.pytest_args = '--cov=puppetboard --cov-report=term-missing'
|
||||||
|
|
||||||
|
def run_tests(self):
|
||||||
|
import shlex
|
||||||
|
import pytest
|
||||||
|
errno = pytest.main(shlex.split(self.pytest_args))
|
||||||
|
sys.exit(errno)
|
||||||
|
|
||||||
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(
|
setup(
|
||||||
name='puppetboard',
|
name='puppetboard',
|
||||||
@@ -111,9 +52,11 @@ setup(
|
|||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
long_description='\n'.join((README, CHANGELOG)),
|
long_description='\n'.join((README, CHANGELOG)),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
install_requires=install_requires,
|
install_requires=requirements,
|
||||||
test_requires=tests_require,
|
tests_require=requirements_test,
|
||||||
|
extras_require={'test': requirements_test},
|
||||||
keywords="puppet puppetdb puppetboard",
|
keywords="puppet puppetdb puppetboard",
|
||||||
|
cmdclass={'test': PyTest},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 3 - Alpha',
|
'Development Status :: 3 - Alpha',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
|
|||||||
7
tox.ini
7
tox.ini
@@ -1,12 +1,7 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py{26,27,35,36}-{default,pinned,unpinned}
|
envlist = py{26,27,35,36}
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv =
|
|
||||||
TEST_DEPS=True
|
|
||||||
pinned: DEPS_RESOLVE=PINNED
|
|
||||||
unpinned: DEPS_RESOLVE=UNPINNED
|
|
||||||
commands=
|
commands=
|
||||||
py.test --cov=puppetboard --pep8 -v
|
py.test --cov=puppetboard --pep8 -v
|
||||||
py{27,35,36}: bandit -r puppetboard
|
py{27,35,36}: bandit -r puppetboard
|
||||||
py{27,35,36}: bandit -r tests
|
|
||||||
|
|||||||
Reference in New Issue
Block a user