setup.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/env python
  2. """ASN.1 types and codecs
  3. A pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208).
  4. """
  5. import os
  6. import sys
  7. classifiers = """\
  8. Development Status :: 5 - Production/Stable
  9. Environment :: Console
  10. Intended Audience :: Developers
  11. Intended Audience :: Education
  12. Intended Audience :: Information Technology
  13. Intended Audience :: Science/Research
  14. Intended Audience :: System Administrators
  15. Intended Audience :: Telecommunications Industry
  16. License :: OSI Approved :: BSD License
  17. Natural Language :: English
  18. Operating System :: OS Independent
  19. Programming Language :: Python :: 2
  20. Programming Language :: Python :: 3
  21. Topic :: Communications
  22. Topic :: Security :: Cryptography
  23. Topic :: Software Development :: Libraries :: Python Modules
  24. """
  25. def howto_install_setuptools():
  26. print("""
  27. Error: You need setuptools Python package!
  28. It's very easy to install it, just type (as root on Linux):
  29. wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
  30. python ez_setup.py
  31. Then you could make eggs from this package.
  32. """)
  33. if sys.version_info[:2] < (2, 4):
  34. print("ERROR: this package requires Python 2.4 or later!")
  35. sys.exit(1)
  36. try:
  37. from setuptools import setup, Command
  38. params = {
  39. 'zip_safe': True
  40. }
  41. except ImportError:
  42. for arg in sys.argv:
  43. if 'egg' in arg:
  44. howto_install_setuptools()
  45. sys.exit(1)
  46. from distutils.core import setup, Command
  47. params = {}
  48. doclines = [ x.strip() for x in __doc__.split('\n') if x ]
  49. params.update( {
  50. 'name': 'pyasn1',
  51. 'version': open(os.path.join('pyasn1','__init__.py')).read().split('\'')[1],
  52. 'description': doclines[0],
  53. 'long_description': ' '.join(doclines[1:]),
  54. 'maintainer': 'Ilya Etingof <ilya@glas.net>',
  55. 'author': 'Ilya Etingof',
  56. 'author_email': 'ilya@glas.net',
  57. 'url': 'http://sourceforge.net/projects/pyasn1/',
  58. 'platforms': ['any'],
  59. 'classifiers': [ x for x in classifiers.split('\n') if x ],
  60. 'license': 'BSD',
  61. 'packages': [ 'pyasn1',
  62. 'pyasn1.type',
  63. 'pyasn1.compat',
  64. 'pyasn1.codec',
  65. 'pyasn1.codec.ber',
  66. 'pyasn1.codec.cer',
  67. 'pyasn1.codec.der' ]
  68. } )
  69. # handle unittest discovery feature
  70. if sys.version_info[0:2] < (2, 7) or \
  71. sys.version_info[0:2] in ( (3, 0), (3, 1) ):
  72. try:
  73. import unittest2 as unittest
  74. except ImportError:
  75. unittest = None
  76. else:
  77. import unittest
  78. if unittest:
  79. class PyTest(Command):
  80. user_options = []
  81. def initialize_options(self): pass
  82. def finalize_options(self): pass
  83. def run(self):
  84. suite = unittest.defaultTestLoader.discover('.')
  85. unittest.TextTestRunner(verbosity=2).run(suite)
  86. params['cmdclass'] = { 'test': PyTest }
  87. setup(**params)