blob: 378a851a8b9fa0495a09ffd87d8c457e3e19aded [file] [log] [blame]
elie8b513892011-02-17 18:35:16 +00001#!/usr/bin/env python
elie71ba6062015-12-29 23:14:22 +00002#
3# This file is part of pyasn1-modules software.
4#
Ilya Etingof0ff31272017-01-11 23:20:21 +01005# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
elie71ba6062015-12-29 23:14:22 +00006# License: http://pyasn1.sf.net/license.html
7#
Ilya Etingofcd2de072017-06-01 22:36:02 +02008import sys
9
10doclines = """A collection of ASN.1-based protocols modules.
eliea8dd0182012-07-04 12:39:21 +000011
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 Etingofcd2de072017-06-01 22:36:02 +020017doclines = [x.strip() for x in doclines.split('\n') if x]
18
19
eliea8dd0182012-07-04 12:39:21 +000020classifiers = """\
21Development Status :: 5 - Production/Stable
22Environment :: Console
23Intended Audience :: Developers
24Intended Audience :: Education
25Intended Audience :: Information Technology
eliea8dd0182012-07-04 12:39:21 +000026Intended Audience :: System Administrators
27Intended Audience :: Telecommunications Industry
28License :: OSI Approved :: BSD License
29Natural Language :: English
30Operating System :: OS Independent
31Programming Language :: Python :: 2
Ilya Etingofc9187892016-12-23 21:18:25 +010032Programming Language :: Python :: 2.4
33Programming Language :: Python :: 2.5
34Programming Language :: Python :: 2.6
35Programming Language :: Python :: 2.7
eliea8dd0182012-07-04 12:39:21 +000036Programming Language :: Python :: 3
Ilya Etingofc9187892016-12-23 21:18:25 +010037Programming Language :: Python :: 3.2
38Programming Language :: Python :: 3.3
39Programming Language :: Python :: 3.4
40Programming Language :: Python :: 3.5
41Programming Language :: Python :: 3.6
elie8549b5d2012-07-23 16:54:31 +000042Topic :: Communications
Ilya Etingofc9187892016-12-23 21:18:25 +010043Topic :: System :: Monitoring
44Topic :: System :: Networking :: Monitoring
eliea8dd0182012-07-04 12:39:21 +000045Topic :: Software Development :: Libraries :: Python Modules
46"""
elie8b513892011-02-17 18:35:16 +000047
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020048
elie8b513892011-02-17 18:35:16 +000049def howto_install_setuptools():
elie367753c2011-10-04 11:36:10 +000050 print("""
51 Error: You need setuptools Python package!
elie8b513892011-02-17 18:35:16 +000052
elie367753c2011-10-04 11:36:10 +000053 It's very easy to install it, just type (as root on Linux):
elie1536a5e2012-07-23 16:35:59 +000054
Ilya Etingofcd2de072017-06-01 22:36:02 +020055 wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
elie8b513892011-02-17 18:35:16 +000056 python ez_setup.py
elie1536a5e2012-07-23 16:35:59 +000057
58 Then you could make eggs from this package.
elie367753c2011-10-04 11:36:10 +000059""")
elie8b513892011-02-17 18:35:16 +000060
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020061
Ilya Etingofcd2de072017-06-01 22:36:02 +020062if sys.version_info[:2] < (2, 4):
63 print("ERROR: this package requires Python 2.4 or later!")
64 sys.exit(1)
65
elie8b513892011-02-17 18:35:16 +000066try:
Ilya Etingofcd2de072017-06-01 22:36:02 +020067 from setuptools import setup, Command
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020068
elie8b513892011-02-17 18:35:16 +000069 params = {
Ilya Etingof061aac02017-09-07 17:12:24 +020070 'zip_safe': True,
Ilya Etingof46b40802017-09-26 22:25:10 +020071 'install_requires': ['pyasn1>=0.4.1,<0.5.0']
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020072 }
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020073
Ilya Etingofcd2de072017-06-01 22:36:02 +020074except ImportError:
elie8b513892011-02-17 18:35:16 +000075 for arg in sys.argv:
Ilya Etingofcd2de072017-06-01 22:36:02 +020076 if 'egg' in arg:
77 howto_install_setuptools()
elie8b513892011-02-17 18:35:16 +000078 sys.exit(1)
Ilya Etingof061aac02017-09-07 17:12:24 +020079
Ilya Etingofcd2de072017-06-01 22:36:02 +020080 from distutils.core import setup, Command
Ilya Etingof2a5c89c2016-03-27 23:45:18 +020081
elieb4c93222012-04-17 19:41:47 +000082 if sys.version_info[:2] > (2, 4):
Ilya Etingof061aac02017-09-07 17:12:24 +020083 params = {
Ilya Etingof46b40802017-09-26 22:25:10 +020084 'requires': ['pyasn1(>=0.4.1,<0.5.0)']
Ilya Etingof061aac02017-09-07 17:12:24 +020085 }
86 else:
87 params = {
88 'requires': ['pyasn1']
89 }
elie8b513892011-02-17 18:35:16 +000090
elie35eec0d2015-10-10 18:09:59 +000091params.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 Etingoff2120842016-12-04 12:06:34 +010096 'maintainer': 'Ilya Etingof <etingof@gmail.com>',
elie35eec0d2015-10-10 18:09:59 +000097 'author': 'Ilya Etingof',
Ilya Etingoff2120842016-12-04 12:06:34 +010098 'author_email': 'etingof@gmail.com',
99 'url': 'https://github.com/etingof/pyasn1-modules',
elie35eec0d2015-10-10 18:09:59 +0000100 'platforms': ['any'],
101 'classifiers': [x for x in classifiers.split('\n') if x],
102 'license': 'BSD',
103 'packages': ['pyasn1_modules']}
104)
elie8b513892011-02-17 18:35:16 +0000105
Ilya Etingof7ef20602017-08-05 12:12:08 +0200106
107# handle unittest discovery feature
108try:
109 import unittest2 as unittest
110except ImportError:
111 import unittest
112
113
114class 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
130params['cmdclass'] = {
131 'test': PyTest,
132 'tests': PyTest
133}
134
elie367753c2011-10-04 11:36:10 +0000135setup(**params)