-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
73 lines (56 loc) · 2.17 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import sys
import subprocess
import pkg_resources
from os import path
from setuptools import setup, find_packages
from setuptools import Command
from setuptools.command.test import test as TestCommand
here = path.abspath(path.dirname(__file__))
class PyTest(TestCommand):
description = "Command to run all unit tests using PyTest"
user_options = [('pytest-args', 'a', 'arguments to pass to pytest')]
def initialize_options(self):
super().initialize_options()
self.pytest_args = None
self._test_target = 'tests/'
def finalize_options(self):
import shlex
super().finalize_options()
if self.pytest_args:
self.pytest_args = shlex.split(self.pytest_args)
else:
self.pytest_args = ['--cov', 'app', self._test_target, '--cov-config', '.coveragerc']
def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
class BuildDocker(Command):
description = "Command to build Docker image for current version"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
build_docker_script = path.join(here, "scripts", "build_docker_image.sh")
command = ["bash", build_docker_script]
subprocess.run(command)
with open(path.join(here, 'README.md'), encoding='utf-8') as readme_file:
long_description = readme_file.read()
with open(path.join(here, 'VERSION')) as version_file:
version = version_file.read().strip()
with open(path.join(here, 'requirements.txt')) as requirements_file:
requirements = [str(req) for req in pkg_resources.parse_requirements(requirements_file.read())]
setup(
name="backend-api",
version=version,
description='Flask API Server',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/jaymindesai/bootstrap-python-backend',
packages=find_packages(exclude=['tests', 'docker']),
install_requires=requirements,
include_package_data=True,
tests_require=['pytest', 'pytest-cov'],
cmdclass=dict(test=PyTest, build_docker=BuildDocker),
)