1#!/usr/bin/env python
2#
3# This file is part of pyasn1 software.
4#
5# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
6# License: http://snmplabs.com/pyasn1/license.html
7#
8import os
9import sys
10
11classifiers = """\
12Development Status :: 5 - Production/Stable
13Environment :: Console
14Intended Audience :: Developers
15Intended Audience :: Education
16Intended Audience :: Information Technology
17Intended Audience :: System Administrators
18Intended Audience :: Telecommunications Industry
19License :: OSI Approved :: BSD License
20Natural Language :: English
21Operating System :: OS Independent
22Programming Language :: Python :: 2
23Programming Language :: Python :: 2.4
24Programming Language :: Python :: 2.5
25Programming Language :: Python :: 2.6
26Programming Language :: Python :: 2.7
27Programming Language :: Python :: 3
28Programming Language :: Python :: 3.2
29Programming Language :: Python :: 3.3
30Programming Language :: Python :: 3.4
31Programming Language :: Python :: 3.5
32Programming Language :: Python :: 3.6
33Topic :: Communications
34Topic :: Software Development :: Libraries :: Python Modules
35"""
36
37
38def howto_install_setuptools():
39    print("""
40   Error: You need setuptools Python package!
41
42   It's very easy to install it, just type:
43
44   wget https://bootstrap.pypa.io/ez_setup.py
45   python ez_setup.py
46
47   Then you could make eggs from this package.
48""")
49
50
51if sys.version_info[:2] < (2, 4):
52    print("ERROR: this package requires Python 2.4 or later!")
53    sys.exit(1)
54
55try:
56    from setuptools import setup, Command
57
58    params = {
59        'zip_safe': True
60    }
61
62except ImportError:
63    for arg in sys.argv:
64        if 'egg' in arg:
65            howto_install_setuptools()
66            sys.exit(1)
67    from distutils.core import setup, Command
68
69    params = {}
70
71params.update({
72    'name': 'pyasn1',
73    'version': open(os.path.join('pyasn1', '__init__.py')).read().split('\'')[1],
74    'description': 'ASN.1 types and codecs',
75    'long_description': 'Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)',
76    'maintainer': 'Ilya Etingof <etingof@gmail.com>',
77    'author': 'Ilya Etingof',
78    'author_email': 'etingof@gmail.com',
79    'url': 'https://github.com/etingof/pyasn1',
80    'platforms': ['any'],
81    'classifiers': [x for x in classifiers.split('\n') if x],
82    'license': 'BSD',
83    'packages': ['pyasn1',
84                 'pyasn1.type',
85                 'pyasn1.compat',
86                 'pyasn1.codec',
87                 'pyasn1.codec.ber',
88                 'pyasn1.codec.cer',
89                 'pyasn1.codec.der',
90                 'pyasn1.codec.native']})
91
92# handle unittest discovery feature
93try:
94    import unittest2 as unittest
95except ImportError:
96    import unittest
97
98
99class PyTest(Command):
100    user_options = []
101
102    def initialize_options(self):
103        pass
104
105    def finalize_options(self):
106        pass
107
108    def run(self):
109        suite = unittest.TestLoader().loadTestsFromNames(
110            ['tests.__main__.suite']
111        )
112
113        unittest.TextTestRunner(verbosity=2).run(suite)
114
115params['cmdclass'] = {
116    'test': PyTest,
117    'tests': PyTest,
118}
119
120setup(**params)
121