• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) Jean-Paul Calderone 2008-2015, All rights reserved
5#
6
7"""
8Installation script for the OpenSSL package.
9"""
10
11import codecs
12import os
13import re
14
15from setuptools import setup, find_packages
16
17
18HERE = os.path.abspath(os.path.dirname(__file__))
19META_PATH = os.path.join("src", "OpenSSL", "version.py")
20
21
22def read_file(*parts):
23    """
24    Build an absolute path from *parts* and and return the contents of the
25    resulting file.  Assume UTF-8 encoding.
26    """
27    with codecs.open(os.path.join(HERE, *parts), "rb", "ascii") as f:
28        return f.read()
29
30
31META_FILE = read_file(META_PATH)
32
33
34def find_meta(meta):
35    """
36    Extract __*meta*__ from META_FILE.
37    """
38    meta_match = re.search(
39        r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
40        META_FILE, re.M
41    )
42    if meta_match:
43        return meta_match.group(1)
44    raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
45
46
47URI = find_meta("uri")
48LONG = (
49    read_file("README.rst") + "\n\n" +
50    "Release Information\n" +
51    "===================\n\n" +
52    re.search(r"(\d{2}.\d.\d \(.*?\)\n.*?)\n\n\n----\n",
53              read_file("CHANGELOG.rst"), re.S).group(1) +
54    "\n\n`Full changelog " +
55    "<{uri}en/stable/changelog.html>`_.\n\n"
56).format(uri=URI)
57
58
59if __name__ == "__main__":
60    setup(
61        name=find_meta("title"),
62        version=find_meta("version"),
63        description=find_meta("summary"),
64        long_description=LONG,
65        author=find_meta("author"),
66        author_email=find_meta("email"),
67        maintainer="Hynek Schlawack",
68        maintainer_email="hs@ox.cx",
69        url=URI,
70        license=find_meta("license"),
71        classifiers=[
72            'Development Status :: 6 - Mature',
73            'Intended Audience :: Developers',
74            'License :: OSI Approved :: Apache Software License',
75            'Operating System :: MacOS :: MacOS X',
76            'Operating System :: Microsoft :: Windows',
77            'Operating System :: POSIX',
78
79            'Programming Language :: Python :: 2',
80            'Programming Language :: Python :: 2.7',
81            'Programming Language :: Python :: 3',
82            'Programming Language :: Python :: 3.4',
83            'Programming Language :: Python :: 3.5',
84            'Programming Language :: Python :: 3.6',
85            'Programming Language :: Python :: 3.7',
86
87            'Programming Language :: Python :: Implementation :: CPython',
88            'Programming Language :: Python :: Implementation :: PyPy',
89            'Topic :: Security :: Cryptography',
90            'Topic :: Software Development :: Libraries :: Python Modules',
91            'Topic :: System :: Networking',
92        ],
93
94        packages=find_packages(where="src"),
95        package_dir={"": "src"},
96        install_requires=[
97            # Fix cryptographyMinimum in tox.ini when changing this!
98            "cryptography>=2.3",
99            "six>=1.5.2"
100        ],
101        extras_require={
102            "test": [
103                "flaky",
104                "pretend",
105                "pytest>=3.0.1",
106            ],
107            "docs": [
108                "sphinx",
109                "sphinx_rtd_theme",
110            ]
111        },
112    )
113