-
Notifications
You must be signed in to change notification settings - Fork 872
/
setup.py
114 lines (98 loc) · 3.06 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
#!/usr/bin/env python
import glob
import subprocess
from pathlib import Path
from distutils.cmd import Command # pylint: disable=deprecated-module
from setuptools import setup, find_packages
# pylint: disable=unused-import
import fastentrypoints # noqa: F401
# pylint: enable=unused-import
import howdoi
class Lint(Command):
"""A custom command to run Flake8 on all Python source files.
"""
description = 'run Flake8 on Python source files'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
local_python_files_str = ' '.join(glob.glob('*.py'))
commands = {'Flake8': 'flake8 --config=.flake8rc .'.split(),
'Pylint': f'pylint howdoi {local_python_files_str} --rcfile=.pylintrc'.split()}
for linter, command in commands.items():
try:
print(f'\nRunning {linter}...')
subprocess.check_call(command)
print(f'No lint errors found by {linter}')
except FileNotFoundError:
print(f'{linter} not installed')
except subprocess.CalledProcessError:
pass
def read(*names):
values = {}
for name in names:
value = ''
for extension in ('.txt', '.md'):
filename = name + extension
if Path(filename).is_file():
with open(filename, encoding='utf-8') as in_file:
value = in_file.read()
break
values[name] = value
return values
# pylint: disable=consider-using-f-string
long_description = """
%(README)s
# News
%(CHANGES)s
""" % read('README', 'CHANGES')
# pylint: enable=consider-using-f-string
setup(
name='howdoi',
version=howdoi.__version__,
description='Instant coding answers via the command line',
long_description=long_description,
long_description_content_type='text/markdown',
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Documentation",
],
keywords='howdoi help console command line answer',
author='Benjamin Gleitzman',
author_email='[email protected]',
maintainer='Benjamin Gleitzman',
maintainer_email='[email protected]',
url='https://github.com/gleitz/howdoi',
license='MIT',
packages=find_packages(),
entry_points={
'console_scripts': [
'howdoi = howdoi.howdoi:command_line_runner',
]
},
install_requires=[
'Pygments',
'cssselect',
'lxml',
'pyquery',
'requests',
'cachelib',
'appdirs',
'keep',
'rich',
'colorama'
],
cmdclass={
'lint': Lint
}
)