setup.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/usr/bin/env python
  2. #
  3. # This file is part of pyasn1-modules software.
  4. #
  5. # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. import sys
  9. doclines = """A collection of ASN.1-based protocols modules.
  10. A collection of ASN.1 modules expressed in form of pyasn1 classes.
  11. Includes protocols PDUs definition (SNMP, LDAP etc.) and various
  12. data structures (X.509, PKCS etc.).
  13. """
  14. doclines = [x.strip() for x in doclines.split('\n') if x]
  15. classifiers = """\
  16. Development Status :: 5 - Production/Stable
  17. Environment :: Console
  18. Intended Audience :: Developers
  19. Intended Audience :: Education
  20. Intended Audience :: Information Technology
  21. Intended Audience :: System Administrators
  22. Intended Audience :: Telecommunications Industry
  23. License :: OSI Approved :: BSD License
  24. Natural Language :: English
  25. Operating System :: OS Independent
  26. Programming Language :: Python :: 2
  27. Programming Language :: Python :: 2.4
  28. Programming Language :: Python :: 2.5
  29. Programming Language :: Python :: 2.6
  30. Programming Language :: Python :: 2.7
  31. Programming Language :: Python :: 3
  32. Programming Language :: Python :: 3.2
  33. Programming Language :: Python :: 3.3
  34. Programming Language :: Python :: 3.4
  35. Programming Language :: Python :: 3.5
  36. Programming Language :: Python :: 3.6
  37. Programming Language :: Python :: 3.7
  38. Topic :: Communications
  39. Topic :: System :: Monitoring
  40. Topic :: System :: Networking :: Monitoring
  41. Topic :: Software Development :: Libraries :: Python Modules
  42. """
  43. def howto_install_setuptools():
  44. print("""
  45. Error: You need setuptools Python package!
  46. It's very easy to install it, just type (as root on Linux):
  47. wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
  48. python ez_setup.py
  49. Then you could make eggs from this package.
  50. """)
  51. if sys.version_info[:2] < (2, 4):
  52. print("ERROR: this package requires Python 2.4 or later!")
  53. sys.exit(1)
  54. try:
  55. from setuptools import setup, Command
  56. params = {
  57. 'zip_safe': True,
  58. 'install_requires': ['pyasn1>=0.4.6,<0.5.0']
  59. }
  60. except ImportError:
  61. for arg in sys.argv:
  62. if 'egg' in arg:
  63. howto_install_setuptools()
  64. sys.exit(1)
  65. from distutils.core import setup, Command
  66. if sys.version_info[:2] > (2, 4):
  67. params = {
  68. 'requires': ['pyasn1(>=0.4.6,<0.5.0)']
  69. }
  70. else:
  71. params = {
  72. 'requires': ['pyasn1']
  73. }
  74. params.update(
  75. {'name': 'pyasn1-modules',
  76. 'version': open('pyasn1_modules/__init__.py').read().split('\'')[1],
  77. 'description': doclines[0],
  78. 'long_description': ' '.join(doclines[1:]),
  79. 'maintainer': 'Ilya Etingof <etingof@gmail.com>',
  80. 'author': 'Ilya Etingof',
  81. 'author_email': 'etingof@gmail.com',
  82. 'url': 'https://github.com/etingof/pyasn1-modules',
  83. 'platforms': ['any'],
  84. 'classifiers': [x for x in classifiers.split('\n') if x],
  85. 'license': 'BSD-2-Clause',
  86. 'packages': ['pyasn1_modules']}
  87. )
  88. # handle unittest discovery feature
  89. try:
  90. import unittest2 as unittest
  91. except ImportError:
  92. import unittest
  93. class PyTest(Command):
  94. user_options = []
  95. def initialize_options(self):
  96. pass
  97. def finalize_options(self):
  98. pass
  99. def run(self):
  100. suite = unittest.TestLoader().loadTestsFromNames(
  101. ['tests.__main__.suite']
  102. )
  103. unittest.TextTestRunner(verbosity=2).run(suite)
  104. params['cmdclass'] = {
  105. 'test': PyTest,
  106. 'tests': PyTest
  107. }
  108. setup(**params)