1
0

setup.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/usr/bin/env python
  2. import glob
  3. import subprocess
  4. from pathlib import Path
  5. from distutils.cmd import Command # pylint: disable=deprecated-module
  6. from setuptools import setup, find_packages
  7. # pylint: disable=unused-import
  8. import fastentrypoints # noqa: F401
  9. # pylint: enable=unused-import
  10. import howdoi
  11. class Lint(Command):
  12. """A custom command to run Flake8 on all Python source files.
  13. """
  14. description = 'run Flake8 on Python source files'
  15. user_options = []
  16. def initialize_options(self):
  17. pass
  18. def finalize_options(self):
  19. pass
  20. def run(self):
  21. local_python_files_str = ' '.join(glob.glob('*.py'))
  22. commands = {'Flake8': 'flake8 --config=.flake8rc .'.split(),
  23. 'Pylint': f'pylint howdoi {local_python_files_str} --rcfile=.pylintrc'.split()}
  24. for linter, command in commands.items():
  25. try:
  26. print(f'\nRunning {linter}...')
  27. subprocess.check_call(command)
  28. print(f'No lint errors found by {linter}')
  29. except FileNotFoundError:
  30. print(f'{linter} not installed')
  31. except subprocess.CalledProcessError:
  32. pass
  33. def read(*names):
  34. values = {}
  35. for name in names:
  36. value = ''
  37. for extension in ('.txt', '.md'):
  38. filename = name + extension
  39. if Path(filename).is_file():
  40. with open(filename, encoding='utf-8') as in_file:
  41. value = in_file.read()
  42. break
  43. values[name] = value
  44. return values
  45. # pylint: disable=consider-using-f-string
  46. long_description = """
  47. %(README)s
  48. # News
  49. %(CHANGES)s
  50. """ % read('README', 'CHANGES')
  51. # pylint: enable=consider-using-f-string
  52. setup(
  53. name='howdoi',
  54. version=howdoi.__version__,
  55. description='Instant coding answers via the command line',
  56. long_description=long_description,
  57. long_description_content_type='text/markdown',
  58. classifiers=[
  59. "Development Status :: 5 - Production/Stable",
  60. "Environment :: Console",
  61. "Intended Audience :: Developers",
  62. "Programming Language :: Python :: 3",
  63. "Programming Language :: Python :: 3.7",
  64. "Programming Language :: Python :: 3.8",
  65. "Programming Language :: Python :: 3.9",
  66. "Programming Language :: Python :: 3.10",
  67. "Programming Language :: Python :: 3.11",
  68. "Topic :: Documentation",
  69. ],
  70. keywords='howdoi help console command line answer',
  71. author='Benjamin Gleitzman',
  72. author_email='gleitz@mit.edu',
  73. maintainer='Benjamin Gleitzman',
  74. maintainer_email='gleitz@mit.edu',
  75. url='https://github.com/gleitz/howdoi',
  76. license='MIT',
  77. packages=find_packages(),
  78. entry_points={
  79. 'console_scripts': [
  80. 'howdoi = howdoi.howdoi:command_line_runner',
  81. ]
  82. },
  83. install_requires=[
  84. 'Pygments',
  85. 'cssselect',
  86. 'lxml',
  87. 'pyquery',
  88. 'requests',
  89. 'cachelib',
  90. 'appdirs',
  91. 'keep',
  92. 'rich',
  93. 'colorama'
  94. ],
  95. cmdclass={
  96. 'lint': Lint
  97. }
  98. )