setup.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import re
  5. import sys
  6. from setuptools import find_packages, setup
  7. def get_version(package):
  8. """
  9. Return package version as listed in `__version__` in `init.py`.
  10. """
  11. with open(os.path.join(package, '__init__.py'), 'rb') as init_py:
  12. src = init_py.read().decode('utf-8')
  13. return re.search("__version__ = ['\"]([^'\"]+)['\"]", src).group(1)
  14. version = get_version('jwt')
  15. with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
  16. long_description = readme.read()
  17. if sys.argv[-1] == 'publish':
  18. if os.system("pip freeze | grep twine"):
  19. print("twine not installed.\nUse `pip install twine`.\nExiting.")
  20. sys.exit()
  21. os.system("python setup.py sdist bdist_wheel")
  22. os.system("twine upload dist/*")
  23. print('You probably want to also tag the version now:')
  24. print(" git tag -a {0} -m 'version {0}'".format(version))
  25. print(' git push --tags')
  26. sys.exit()
  27. tests_require = [
  28. 'pytest>=4.0.1,<5.0.0',
  29. 'pytest-cov>=2.6.0,<3.0.0',
  30. 'pytest-runner>=4.2,<5.0.0',
  31. ]
  32. needs_pytest = set(('pytest', 'test', 'ptr')).intersection(sys.argv)
  33. pytest_runner = ['pytest-runner'] if needs_pytest else []
  34. setup(
  35. name='PyJWT',
  36. version=version,
  37. author='Jose Padilla',
  38. author_email='hello@jpadilla.com',
  39. description='JSON Web Token implementation in Python',
  40. license='MIT',
  41. keywords='jwt json web token security signing',
  42. url='http://github.com/jpadilla/pyjwt',
  43. packages=find_packages(
  44. exclude=["*.tests", "*.tests.*", "tests.*", "tests"]
  45. ),
  46. long_description=long_description,
  47. classifiers=[
  48. 'Development Status :: 5 - Production/Stable',
  49. 'Intended Audience :: Developers',
  50. 'Natural Language :: English',
  51. 'License :: OSI Approved :: MIT License',
  52. 'Programming Language :: Python',
  53. 'Programming Language :: Python :: 2.7',
  54. 'Programming Language :: Python :: 3.4',
  55. 'Programming Language :: Python :: 3.5',
  56. 'Programming Language :: Python :: 3.6',
  57. 'Programming Language :: Python :: 3.7',
  58. 'Topic :: Utilities',
  59. ],
  60. test_suite='tests',
  61. setup_requires=pytest_runner,
  62. tests_require=tests_require,
  63. extras_require=dict(
  64. test=tests_require,
  65. crypto=['cryptography >= 1.4'],
  66. flake8=[
  67. 'flake8',
  68. 'flake8-import-order',
  69. 'pep8-naming'
  70. ]
  71. ),
  72. entry_points={
  73. 'console_scripts': [
  74. 'pyjwt = jwt.__main__:main'
  75. ]
  76. }
  77. )