1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# This file is part of python-gnupg, a Python interface to GnuPG.
5# Copyright © 2013 Isis Lovecruft, <isis@leap.se> 0xA3ADB67A2CDB8B35
6#           © 2013 Andrej B.
7#           © 2013 LEAP Encryption Access Project
8#           © 2008-2012 Vinay Sajip
9#           © 2005 Steve Traugott
10#           © 2004 A.M. Kuchling
11#
12# This program is free software: you can redistribute it and/or modify it
13# under the terms of the GNU General Public License as published by the Free
14# Software Foundation, either version 3 of the License, or (at your option)
15# any later version.
16#
17# This program is distributed in the hope that it will be useful, but WITHOUT
18# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19# FITNESS FOR A PARTICULAR PURPOSE. See the included LICENSE file for details.
20#______________________________________________________________________________
21
22from __future__ import absolute_import
23from __future__ import print_function
24
25import platform
26import setuptools
27import sys
28import os
29import versioneer
30
31try:
32    import __pypy__
33except ImportError:
34    _isPyPy = False
35else:
36    _isPyPy = True
37
38
39versioneer.versionfile_source = 'pretty_bad_protocol/_version.py'
40versioneer.versionfile_build  = 'pretty_bad_protocol/_version.py'
41versioneer.tag_prefix = ''
42versioneer.parentdir_prefix = 'pretty-bad-protocol-'
43
44__author__ = "Isis Agora Lovecruft"
45__contact__ = 'isis@patternsinthevoid.net'
46__url__ = 'https://github.com/isislovecruft/python-gnupg'
47
48
49def python26():
50    """Returns True if we're running on Python2.6."""
51    if sys.version[:3] == "2.6":
52        return True
53    return False
54
55def get_requirements():
56    """Extract the list of requirements from our requirements.txt.
57
58    :rtype: 2-tuple
59    :returns: Two lists, the first is a list of requirements in the form of
60        pkgname==version. The second is a list of URIs or VCS checkout strings
61        which specify the dependency links for obtaining a copy of the
62        requirement.
63    """
64    requirements_file = os.path.join(os.getcwd(), 'requirements.txt')
65    requirements = []
66    links=[]
67    try:
68        with open(requirements_file) as reqfile:
69            for line in reqfile.readlines():
70                line = line.strip()
71                if line.startswith('#'):
72                    continue
73                elif line.startswith(
74                        ('https://', 'git://', 'hg://', 'svn://')):
75                    links.append(line)
76                else:
77                    requirements.append(line)
78
79    except (IOError, OSError) as error:
80        print(error)
81
82    if python26():
83        # Required to make `collections.OrderedDict` available on Python<=2.6
84        requirements.append('ordereddict==1.1#a0ed854ee442051b249bfad0f638bbec')
85
86    # Don't try to install psutil on PyPy:
87    if _isPyPy:
88        for line in requirements[:]:
89            if line.startswith('psutil'):
90                print("Not installing %s on PyPy..." % line)
91                requirements.remove(line)
92
93    return requirements, links
94
95
96requires, deplinks = get_requirements()
97
98
99setuptools.setup(
100    name = "pretty-bad-protocol",
101    description="A Python wrapper for GnuPG",
102    long_description = """\
103This module allows easy access to GnuPG's key management, encryption and \
104signature functionality from Python programs, by interacting with GnuPG \
105through file descriptors. Input arguments are strictly checked and sanitised, \
106and therefore this module should be safe to use in networked applications \
107requiring direct user input. It is intended for use on Windows, MacOS X, BSD, \
108or Linux, with Python 2.6, Python 2.7, Python 3.3, Python 3.4, or PyPy.
109""",
110    license="GPLv3+",
111
112    version=versioneer.get_version(),
113    cmdclass=versioneer.get_cmdclass(),
114
115    author=__author__,
116    author_email=__contact__,
117    maintainer=__author__,
118    maintainer_email=__contact__,
119    url=__url__,
120
121    package_dir={
122        'pretty_bad_protocol': 'pretty_bad_protocol',
123    },
124    packages=['pretty_bad_protocol'],
125    package_data={'': ['README', 'LICENSE', 'TODO', 'requirements.txt']},
126    scripts=['versioneer.py'],
127    test_suite='pretty_bad_protocol.test.test_gnupg',
128
129    install_requires=requires,
130    dependency_links=deplinks,
131    extras_require={'docs': ["Sphinx>=1.1",
132                             "sphinxcontrib-fulltoc==1.0"]},
133
134    platforms="Linux, BSD, OSX, Windows",
135    download_url="https://github.com/isislovecruft/python-gnupg/archive/master.zip",
136    classifiers=[
137        "Development Status :: 5 - Production/Stable",
138        "Intended Audience :: Developers",
139        "Intended Audience :: System Administrators",
140        "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
141        "Operating System :: Android",
142        "Operating System :: MacOS :: MacOS X",
143        "Operating System :: Microsoft :: Windows",
144        "Operating System :: POSIX :: BSD",
145        "Operating System :: POSIX :: Linux",
146        "Programming Language :: Python",
147        "Programming Language :: Python :: 2",
148        "Programming Language :: Python :: 3",
149        "Programming Language :: Python :: 2.7",
150        "Programming Language :: Python :: 3.3",
151        "Programming Language :: Python :: 3.4",
152        "Programming Language :: Python :: 3.5",
153        "Programming Language :: Python :: 3.6",
154        "Programming Language :: Python :: Implementation :: CPython",
155        "Programming Language :: Python :: Implementation :: PyPy",
156        "Topic :: Security :: Cryptography",
157        "Topic :: Software Development :: Libraries :: Python Modules",
158        "Topic :: Utilities",]
159)
160