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 | 0ff3127 | 2017-01-11 23:20:21 +0100 | [diff] [blame] | 5 | # Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com> |
elie | 71ba606 | 2015-12-29 23:14:22 +0000 | [diff] [blame] | 6 | # License: http://pyasn1.sf.net/license.html |
| 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 |
elie | 8549b5d | 2012-07-23 16:54:31 +0000 | [diff] [blame] | 42 | Topic :: Communications |
Ilya Etingof | c918789 | 2016-12-23 21:18:25 +0100 | [diff] [blame] | 43 | Topic :: System :: Monitoring |
| 44 | Topic :: System :: Networking :: Monitoring |
elie | a8dd018 | 2012-07-04 12:39:21 +0000 | [diff] [blame] | 45 | Topic :: Software Development :: Libraries :: Python Modules |
| 46 | """ |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 47 | |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 48 | |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 49 | def howto_install_setuptools(): |
elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 50 | print(""" |
| 51 | Error: You need setuptools Python package! |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 52 | |
elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 53 | It's very easy to install it, just type (as root on Linux): |
elie | 1536a5e | 2012-07-23 16:35:59 +0000 | [diff] [blame] | 54 | |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 55 | wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 56 | python ez_setup.py |
elie | 1536a5e | 2012-07-23 16:35:59 +0000 | [diff] [blame] | 57 | |
| 58 | Then you could make eggs from this package. |
elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 59 | """) |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 60 | |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 61 | |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 62 | if sys.version_info[:2] < (2, 4): |
| 63 | print("ERROR: this package requires Python 2.4 or later!") |
| 64 | sys.exit(1) |
| 65 | |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 66 | try: |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 67 | from setuptools import setup, Command |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 68 | |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 69 | params = { |
Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 70 | 'zip_safe': True, |
Ilya Etingof | 46b4080 | 2017-09-26 22:25:10 +0200 | [diff] [blame] | 71 | 'install_requires': ['pyasn1>=0.4.1,<0.5.0'] |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 72 | } |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 73 | |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 74 | except ImportError: |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 75 | for arg in sys.argv: |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 76 | if 'egg' in arg: |
| 77 | howto_install_setuptools() |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 78 | sys.exit(1) |
Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 79 | |
Ilya Etingof | cd2de07 | 2017-06-01 22:36:02 +0200 | [diff] [blame] | 80 | from distutils.core import setup, Command |
Ilya Etingof | 2a5c89c | 2016-03-27 23:45:18 +0200 | [diff] [blame] | 81 | |
elie | b4c9322 | 2012-04-17 19:41:47 +0000 | [diff] [blame] | 82 | if sys.version_info[:2] > (2, 4): |
Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 83 | params = { |
Ilya Etingof | 46b4080 | 2017-09-26 22:25:10 +0200 | [diff] [blame] | 84 | 'requires': ['pyasn1(>=0.4.1,<0.5.0)'] |
Ilya Etingof | 061aac0 | 2017-09-07 17:12:24 +0200 | [diff] [blame] | 85 | } |
| 86 | else: |
| 87 | params = { |
| 88 | 'requires': ['pyasn1'] |
| 89 | } |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 90 | |
elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 91 | params.update( |
| 92 | {'name': 'pyasn1-modules', |
| 93 | 'version': open('pyasn1_modules/__init__.py').read().split('\'')[1], |
| 94 | 'description': doclines[0], |
| 95 | 'long_description': ' '.join(doclines[1:]), |
Ilya Etingof | f212084 | 2016-12-04 12:06:34 +0100 | [diff] [blame] | 96 | 'maintainer': 'Ilya Etingof <etingof@gmail.com>', |
elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 97 | 'author': 'Ilya Etingof', |
Ilya Etingof | f212084 | 2016-12-04 12:06:34 +0100 | [diff] [blame] | 98 | 'author_email': 'etingof@gmail.com', |
| 99 | 'url': 'https://github.com/etingof/pyasn1-modules', |
elie | 35eec0d | 2015-10-10 18:09:59 +0000 | [diff] [blame] | 100 | 'platforms': ['any'], |
| 101 | 'classifiers': [x for x in classifiers.split('\n') if x], |
| 102 | 'license': 'BSD', |
| 103 | 'packages': ['pyasn1_modules']} |
| 104 | ) |
elie | 8b51389 | 2011-02-17 18:35:16 +0000 | [diff] [blame] | 105 | |
Ilya Etingof | 7ef2060 | 2017-08-05 12:12:08 +0200 | [diff] [blame] | 106 | |
| 107 | # handle unittest discovery feature |
| 108 | try: |
| 109 | import unittest2 as unittest |
| 110 | except ImportError: |
| 111 | import unittest |
| 112 | |
| 113 | |
| 114 | class PyTest(Command): |
| 115 | user_options = [] |
| 116 | |
| 117 | def initialize_options(self): |
| 118 | pass |
| 119 | |
| 120 | def finalize_options(self): |
| 121 | pass |
| 122 | |
| 123 | def run(self): |
| 124 | suite = unittest.TestLoader().loadTestsFromNames( |
| 125 | ['tests.__main__.suite'] |
| 126 | ) |
| 127 | |
| 128 | unittest.TextTestRunner(verbosity=2).run(suite) |
| 129 | |
| 130 | params['cmdclass'] = { |
| 131 | 'test': PyTest, |
| 132 | 'tests': PyTest |
| 133 | } |
| 134 | |
elie | 367753c | 2011-10-04 11:36:10 +0000 | [diff] [blame] | 135 | setup(**params) |