blob: a053fe61be7f78eb8ebb604a975c86025261bc7b [file] [log] [blame]
Alex Gaynorbfc06bc2013-08-06 19:36:19 -07001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
Alex Gaynorf51f2c12014-01-03 07:33:01 -080013import os
Alex Gaynor9a00f052014-01-02 13:09:34 -080014from distutils.command.build import build
15
Donald Stufft9ebb8ff2013-08-11 17:05:03 -040016from setuptools import setup, find_packages
Alex Gaynorc62e91f2013-08-06 19:25:52 -070017
Donald Stufft446a4572013-08-11 17:38:13 -040018
Alex Gaynor7630d6c2014-01-03 07:34:43 -080019base_dir = os.path.dirname(__file__)
20
Donald Stufft5f12a1b2013-08-11 16:37:43 -040021about = {}
Alex Gaynor7630d6c2014-01-03 07:34:43 -080022with open(os.path.join(base_dir, "cryptography", "__about__.py")) as f:
23 exec(f.read(), about)
Donald Stufft5f12a1b2013-08-11 16:37:43 -040024
25
26CFFI_DEPENDENCY = "cffi>=0.6"
Paul Kehrerc0242552013-09-10 18:54:13 -050027SIX_DEPENDENCY = "six>=1.4.1"
Donald Stufft5f12a1b2013-08-11 16:37:43 -040028
Alex Gaynor91f119e2014-01-02 13:12:59 -080029requirements = [
Donald Stufft5f12a1b2013-08-11 16:37:43 -040030 CFFI_DEPENDENCY,
Paul Kehrerc0242552013-09-10 18:54:13 -050031 SIX_DEPENDENCY
Donald Stufft5f12a1b2013-08-11 16:37:43 -040032]
33
Alex Gaynor9a00f052014-01-02 13:09:34 -080034
35class cffi_build(build):
Alex Gaynor49697512014-01-03 15:08:45 -080036 """
37 This class exists, instead of just providing ``ext_modules=[...]`` directly
38 in ``setup()`` because importing cryptography requires we have several
39 packages installed first.
40
41 By doing the imports here we ensure that packages listed in
42 ``setup_requires`` are already installed.
43 """
44
Alex Gaynor9a00f052014-01-02 13:09:34 -080045 def finalize_options(self):
46 from cryptography.hazmat.bindings.openssl.binding import Binding
47 from cryptography.hazmat.primitives import constant_time, padding
48
49 self.distribution.ext_modules = [
Alex Gaynor9a00f052014-01-02 13:09:34 -080050 constant_time._ffi.verifier.get_extension(),
51 padding._ffi.verifier.get_extension()
52 ]
Alex Gaynor50f233e2014-01-06 11:10:40 -080053 if Binding.is_available():
Alex Gaynorffa8b4d2014-01-06 11:19:11 -080054 self.distribution.ext_modules.append(
55 Binding().ffi.verifier.get_extension()
56 )
Alex Gaynor50f233e2014-01-06 11:10:40 -080057
Alex Gaynor9a00f052014-01-02 13:09:34 -080058 build.finalize_options(self)
59
60
Alex Gaynor7630d6c2014-01-03 07:34:43 -080061with open(os.path.join(base_dir, "README.rst")) as f:
Alex Gaynorf51f2c12014-01-03 07:33:01 -080062 long_description = f.read()
63
64
Alex Gaynorc62e91f2013-08-06 19:25:52 -070065setup(
Donald Stufft5f12a1b2013-08-11 16:37:43 -040066 name=about["__title__"],
67 version=about["__version__"],
68
69 description=about["__summary__"],
Alex Gaynorf51f2c12014-01-03 07:33:01 -080070 long_description=long_description,
Donald Stufft5f12a1b2013-08-11 16:37:43 -040071 license=about["__license__"],
72 url=about["__uri__"],
73
74 author=about["__author__"],
75 author_email=about["__email__"],
76
Christian Heimesf83ed1d2013-08-10 23:28:29 +020077 classifiers=[
78 "Development Status :: 2 - Pre-Alpha",
79 "Intended Audience :: Developers",
80 "License :: OSI Approved :: Apache Software License",
81 "Natural Language :: English",
82 "Operating System :: MacOS :: MacOS X",
83 "Operating System :: POSIX",
84 "Operating System :: POSIX :: BSD",
85 "Operating System :: POSIX :: Linux",
86 "Operating System :: Microsoft :: Windows",
Christian Heimesf83ed1d2013-08-10 23:28:29 +020087 "Programming Language :: Python",
88 "Programming Language :: Python :: 2",
89 "Programming Language :: Python :: 2.6",
90 "Programming Language :: Python :: 2.7",
91 "Programming Language :: Python :: 3",
92 "Programming Language :: Python :: 3.2",
93 "Programming Language :: Python :: 3.3",
94 "Programming Language :: Python :: Implementation :: CPython",
95 "Programming Language :: Python :: Implementation :: PyPy",
96 "Topic :: Security :: Cryptography",
97 ],
Donald Stufft5f12a1b2013-08-11 16:37:43 -040098
Donald Stufft9ebb8ff2013-08-11 17:05:03 -040099 packages=find_packages(exclude=["tests", "tests.*"]),
100
Alex Gaynor91f119e2014-01-02 13:12:59 -0800101 install_requires=requirements,
102 setup_requires=requirements,
Donald Stufft5f12a1b2013-08-11 16:37:43 -0400103
104 # for cffi
105 zip_safe=False,
Alex Gaynor9a00f052014-01-02 13:09:34 -0800106 ext_package="cryptography",
107 cmdclass={
108 "build": cffi_build,
109 }
Alex Gaynorc62e91f2013-08-06 19:25:52 -0700110)