-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
150 lines (123 loc) · 4.4 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python3
import os
import glob
import shutil
from setuptools import setup, Command
import distutils.cmd
import distutils.log
import subprocess
# get key package details from py_pkg/__version__.py
about = {} # type: ignore
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'flex', '__version__.py')) as f:
exec(f.read(), about)
# load the README file and use it as the long_description for PyPI
with open('README.md', 'r') as f:
readme = f.read()
class PyTestCommand(distutils.cmd.Command):
"""A custom command to run Pylint on all Python source files."""
description = 'Run pytest tests'
user_options = [
]
def initialize_options(self):
"""Set default values for options."""
# Each user option must be listed here with their default value.
pass
def finalize_options(self):
"""Post-process options."""
pass
def run(self):
"""Run command."""
command = [
'pytest --full-trace --verbose --color=yes --disable-pytest-warnings --no-summary --pyargs flex.tests']
self.announce(
'Running command: %s' % str(command),
level=distutils.log.INFO)
subprocess.Popen(command, shell=True)
class PylintCommand(distutils.cmd.Command):
"""A custom command to run Pylint on all Python source files."""
description = 'run Pylint on Python source files'
user_options = [
# The format is (long option, short option, description).
('pylint-rcfile=', None, 'path to Pylint config file'),
]
def initialize_options(self):
"""Set default values for options."""
# Each user option must be listed here with their default value.
self.pylint_rcfile = ''
def finalize_options(self):
"""Post-process options."""
if self.pylint_rcfile:
assert os.path.exists(self.pylint_rcfile), (
'Pylint config file %s does not exist.' % self.pylint_rcfile)
def run(self):
"""Run command."""
command = ['pylint blazer']
self.announce(
'Running command: %s' % str(command),
level=distutils.log.INFO)
subprocess.Popen(command, shell=True)
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
CLEAN_FILES = './docs/build ./*.out ./*.log ./work/* ./build ./dist ./__pycache__ ./flex/cli/__pycache__ ./*/__pycache__ ./*.pyc ./ssh*py ./*.tgz ./.pytest_cache ./*.egg-info'.split(
' ')
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
global here
for path_spec in self.CLEAN_FILES:
# Make paths absolute and relative to this path
abs_paths = glob.glob(os.path.normpath(
os.path.join(here, path_spec)))
for path in [str(p) for p in abs_paths]:
if not path.startswith(here):
# Die if path in CLEAN_FILES is absolute + outside this directory
raise ValueError(
"%s is not a path inside %s" % (path, here))
print('removing %s' % os.path.relpath(path))
try:
shutil.rmtree(path)
except:
os.remove(path)
# package configuration - for reference see:
# https://setuptools.readthedocs.io/en/latest/setuptools.html#id9
setup(
name=about['__title__'],
description=about['__description__'],
long_description=readme,
long_description_content_type='text/markdown',
version=about['__version__'],
author=about['__author__'],
author_email=about['__author_email__'],
url=about['__url__'],
packages=['flex', 'flex.json', 'flex.backends', 'flex.cli', 'tests'],
include_package_data=True,
python_requires=">=3.8.*",
install_requires=[
'pytest',
'click',
'black',
'isort',
'boto3',
'flake8'
],
license=about['__license__'],
zip_safe=False,
cmdclass={
'clean': CleanCommand,
'pylint': PylintCommand,
'test': PyTestCommand
},
entry_points={
'console_scripts': ['flex=flex.cli:cli']
},
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.10',
],
keywords='cli, tools, utility'
)