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