blob: f742c1ed09319c64fa5e4f438b8215793a8c60cc [file] [log] [blame]
Jean-Paul Calderonecf20dd62008-06-12 16:38:38 -04001#!/usr/bin/env python
Jean-Paul Calderone0db6cdb2008-04-11 11:52:15 -04002# -*- coding: utf-8 -*-
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05003#
Hynek Schlawack76ecf942015-04-14 11:09:44 -04004# Copyright (C) Jean-Paul Calderone 2008-2015, All rights reserved
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05005#
Jean-Paul Calderonee53ccf72008-04-11 11:40:39 -04006
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05007"""
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +02008Installation script for the OpenSSL module.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05009"""
10
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +020011import codecs
12import os
13import re
Hynek Schlawackf982efd2015-04-15 12:08:54 -040014import sys
15
Jean-Paul Calderone5d97b412014-01-10 14:09:20 -050016from setuptools import setup
Hynek Schlawackf982efd2015-04-15 12:08:54 -040017from setuptools.command.test import test as TestCommand
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050018
Hynek Schlawack76ecf942015-04-14 11:09:44 -040019
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +020020HERE = os.path.abspath(os.path.dirname(__file__))
21META_PATH = os.path.join("OpenSSL", "version.py")
22
23
24def read_file(*parts):
25 """
26 Build an absolute path from *parts* and and return the contents of the
27 resulting file. Assume UTF-8 encoding.
28 """
29 with codecs.open(os.path.join(HERE, *parts), "rb", "ascii") as f:
30 return f.read()
31
32
33META_FILE = read_file(META_PATH)
34
35
36def find_meta(meta):
37 """
38 Extract __*meta*__ from META_FILE.
39 """
40 meta_match = re.search(
41 r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
42 META_FILE, re.M
43 )
44 if meta_match:
45 return meta_match.group(1)
46 raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050047
Hynek Schlawackf982efd2015-04-15 12:08:54 -040048
49class PyTest(TestCommand):
50 user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]
51
52 def initialize_options(self):
53 TestCommand.initialize_options(self)
54 self.pytest_args = None
55
56 def finalize_options(self):
57 TestCommand.finalize_options(self)
58 self.test_args = []
59 self.test_suite = True
60
61 def run_tests(self):
62 # import here, cause outside the eggs aren't loaded
63 import pytest
64 errno = pytest.main(self.pytest_args or [] +
65 ["OpenSSL"])
66 sys.exit(errno)
67
68
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +020069setup(
70 name=find_meta("title"),
71 version=find_meta("version"),
72 description=find_meta("summary"),
73 long_description=read_file("README.rst"),
74 author=find_meta("author"),
75 author_email=find_meta("email"),
76 maintainer="Hynek Schlawack",
77 maintainer_email="hs@ox.cx",
78 url=find_meta("uri"),
79 license=find_meta("license"),
80 classifiers=[
Jean-Paul Calderoned59d3bc2011-12-19 13:32:29 -050081 'Development Status :: 6 - Mature',
82 'Intended Audience :: Developers',
83 'License :: OSI Approved :: Apache Software License',
84 'Operating System :: MacOS :: MacOS X',
85 'Operating System :: Microsoft :: Windows',
86 'Operating System :: POSIX',
Jean-Paul Calderone16743132014-03-03 09:12:06 -050087
Jean-Paul Calderone16743132014-03-03 09:12:06 -050088 'Programming Language :: Python :: 2',
Jean-Paul Calderoned59d3bc2011-12-19 13:32:29 -050089 'Programming Language :: Python :: 2.6',
90 'Programming Language :: Python :: 2.7',
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +020091 'Programming Language :: Python :: 3',
Jean-Paul Calderone19ad3712014-01-09 20:40:46 -050092 'Programming Language :: Python :: 3.3',
Jean-Paul Calderone16743132014-03-03 09:12:06 -050093
Jean-Paul Calderoned59d3bc2011-12-19 13:32:29 -050094 'Programming Language :: Python :: Implementation :: CPython',
95 'Programming Language :: Python :: Implementation :: PyPy',
96 'Topic :: Security :: Cryptography',
97 'Topic :: Software Development :: Libraries :: Python Modules',
98 'Topic :: System :: Networking',
Hynek Schlawack5bc17cb2015-04-30 19:21:40 +020099 ],
100
101 packages=['OpenSSL'],
102 package_dir={'OpenSSL': 'OpenSSL'},
103 py_modules=['OpenSSL.__init__',
104 'OpenSSL.tsafe',
105 'OpenSSL.rand',
106 'OpenSSL.crypto',
107 'OpenSSL.SSL',
108 'OpenSSL.version',
109 'OpenSSL.test.__init__',
110 'OpenSSL.test.util',
111 'OpenSSL.test.test_crypto',
112 'OpenSSL.test.test_rand',
113 'OpenSSL.test.test_ssl',
114 'OpenSSL.test.test_tsafe',
115 'OpenSSL.test.test_util',],
116 install_requires=[
117 "cryptography>=0.7",
118 "six>=1.5.2"
119 ],
120 test_suite="OpenSSL",
121 tests_require=[
122 "pytest",
123 ],
124 cmdclass={
125 "test": PyTest,
126 }
127)