setup.py 2.8 KB

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