| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| elie | 71ba606 | 2015-12-29 23:14:22 +0000 | [diff] [blame] | 2 | # |
| 3 | # This file is part of pyasn1-modules software. |
| 4 | # |
| Ilya Etingof | b961419 | 2018-12-29 21:59:05 +0100 | [diff] [blame] | 5 | # Copyright (c) 2005-2019, Ilya Etingof <[email protected]> |
| Ilya Etingof | 66122a9 | 2018-03-29 08:08:34 +0200 | [diff] [blame] | 6 | # License: http://snmplabs.com/pyasn1/license.html |
| elie | 71ba606 | 2015-12-29 23:14:22 +0000 | [diff] [blame] | 7 | # |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 8 | import sys |
| 9 | |
| 10 | doclines = """A collection of ASN.1-based protocols modules. |
| elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 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 | |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 17 | doclines = [x.strip() for x in doclines.split('\n') if x] |
| 18 | |
| 19 | |
| elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 20 | classifiers = """\ |
| 21 | Development Status :: 5 - Production/Stable |
| 22 | Environment :: Console |
| 23 | Intended Audience :: Developers |
| 24 | Intended Audience :: Education |
| 25 | Intended Audience :: Information Technology |
| elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 26 | Intended Audience :: System Administrators |
| 27 | Intended Audience :: Telecommunications Industry |
| 28 | License :: OSI Approved :: BSD License |
| 29 | Natural Language :: English |
| 30 | Operating System :: OS Independent |
| 31 | Programming Language :: Python :: 2 |
| Ilya Etingof | c918789 | 2016-12-23 21:18:25 +0100 | [diff] [blame] | 32 | Programming Language :: Python :: 2.4 |
| 33 | Programming Language :: Python :: 2.5 |
| 34 | Programming Language :: Python :: 2.6 |
| 35 | Programming Language :: Python :: 2.7 |
| elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 36 | Programming Language :: Python :: 3 |
| Ilya Etingof | c918789 | 2016-12-23 21:18:25 +0100 | [diff] [blame] | 37 | Programming Language :: Python :: 3.2 |
| 38 | Programming Language :: Python :: 3.3 |
| 39 | Programming Language :: Python :: 3.4 |
| 40 | Programming Language :: Python :: 3.5 |
| 41 | Programming Language :: Python :: 3.6 |
| Ilya Etingof | 1acfe30 | 2018-06-28 10:09:39 +0200 | [diff] [blame] | 42 | Programming Language :: Python :: 3.7 |
| Aliaksei Urbanski | a9139ec | 2019-10-17 07:57:05 +0300 | [diff] [blame] | 43 | Programming Language :: Python :: 3.8 |
| elie | 8549b5d | 2012-07-23 16:54:31 +0000 | [diff] [blame] | 44 | Topic :: Communications |
| Ilya Etingof | c918789 | 2016-12-23 21:18:25 +0100 | [diff] [blame] | 45 | Topic :: System :: Monitoring |
| 46 | Topic :: System :: Networking :: Monitoring |
| elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 47 | Topic :: Software Development :: Libraries :: Python Modules |
| 48 | """ |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 49 | |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 50 | |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 51 | def howto_install_setuptools(): |
| elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 52 | print(""" |
| 53 | Error: You need setuptools Python package! |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 54 | |
| elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 55 | It's very easy to install it, just type (as root on Linux): |
| elie | 1536a5e | 2012-07-23 16:35:59 +0000 | [diff] [blame] | 56 | |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 57 | wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 58 | python ez_setup.py |
| elie | 1536a5e | 2012-07-23 16:35:59 +0000 | [diff] [blame] | 59 | |
| 60 | Then you could make eggs from this package. |
| elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 61 | """) |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 62 | |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 63 | |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 64 | if sys.version_info[:2] < (2, 4): |
| 65 | print("ERROR: this package requires Python 2.4 or later!") |
| 66 | sys.exit(1) |
| 67 | |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 68 | try: |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 69 | from setuptools import setup, Command |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 70 | |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 71 | params = { |
| Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 72 | 'zip_safe': True, |
| Ilya Etingof | 213c0f4 | 2019-08-01 07:47:31 +0200 | [diff] [blame] | 73 | 'install_requires': ['pyasn1>=0.4.6,<0.5.0'] |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 74 | } |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 75 | |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 76 | except ImportError: |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 77 | for arg in sys.argv: |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 78 | if 'egg' in arg: |
| 79 | howto_install_setuptools() |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 80 | sys.exit(1) |
| Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 81 | |
| Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 82 | from distutils.core import setup, Command |
| Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 83 | |
| elie | b4c9322 | 2012-04-17 19:41:47 +0000 | [diff] [blame] | 84 | if sys.version_info[:2] > (2, 4): |
| Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 85 | params = { |
| Ilya Etingof | 213c0f4 | 2019-08-01 07:47:31 +0200 | [diff] [blame] | 86 | 'requires': ['pyasn1(>=0.4.6,<0.5.0)'] |
| Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 87 | } |
| 88 | else: |
| 89 | params = { |
| 90 | 'requires': ['pyasn1'] |
| 91 | } |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 92 | |
| elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 93 | params.update( |
| 94 | {'name': 'pyasn1-modules', |
| 95 | 'version': open('pyasn1_modules/__init__.py').read().split('\'')[1], |
| 96 | 'description': doclines[0], |
| 97 | 'long_description': ' '.join(doclines[1:]), |
| Ilya Etingof | f212084 | 2016-12-04 12:06:34 +0100 | [diff] [blame] | 98 | 'maintainer': 'Ilya Etingof <[email protected]>', |
| elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 99 | 'author': 'Ilya Etingof', |
| Ilya Etingof | f212084 | 2016-12-04 12:06:34 +0100 | [diff] [blame] | 100 | 'author_email': '[email protected]', |
| 101 | 'url': 'https://github.com/etingof/pyasn1-modules', |
| elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 102 | 'platforms': ['any'], |
| 103 | 'classifiers': [x for x in classifiers.split('\n') if x], |
| Ilya Etingof | 213c0f4 | 2019-08-01 07:47:31 +0200 | [diff] [blame] | 104 | 'license': 'BSD-2-Clause', |
| elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 105 | 'packages': ['pyasn1_modules']} |
| 106 | ) |
| elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 107 | |
| Ilya Etingof | 7ef2060 | 2017-08-05 12:12:08 +0200 | [diff] [blame] | 108 | |
| 109 | # handle unittest discovery feature |
| 110 | try: |
| 111 | import unittest2 as unittest |
| 112 | except ImportError: |
| 113 | import unittest |
| 114 | |
| 115 | |
| 116 | class PyTest(Command): |
| 117 | user_options = [] |
| 118 | |
| 119 | def initialize_options(self): |
| 120 | pass |
| 121 | |
| 122 | def finalize_options(self): |
| 123 | pass |
| 124 | |
| 125 | def run(self): |
| 126 | suite = unittest.TestLoader().loadTestsFromNames( |
| 127 | ['tests.__main__.suite'] |
| 128 | ) |
| 129 | |
| 130 | unittest.TextTestRunner(verbosity=2).run(suite) |
| 131 | |
| 132 | params['cmdclass'] = { |
| 133 | 'test': PyTest, |
| 134 | 'tests': PyTest |
| 135 | } |
| 136 | |
| elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 137 | setup(**params) |