forked from wolfSSL/wolfssl-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·117 lines (95 loc) · 3.98 KB
/
setup.py
File metadata and controls
executable file
·117 lines (95 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2006-2020 wolfSSL Inc.
#
# This file is part of wolfSSL. (formerly known as CyaSSL)
#
# wolfSSL is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# wolfSSL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# pylint: disable=wrong-import-position
import os
import sys
from setuptools import setup
from setuptools.command.build_ext import build_ext
# Adding src folder to the include path in order to import from wolfssl
package_dir = os.path.join(os.path.dirname(__file__), "src")
sys.path.insert(0, package_dir)
import wolfssl
from wolfssl._build_wolfssl import build_wolfssl
from wolfssl._build_wolfssl import wolfssl_inc_path, wolfssl_lib_path
# long_description
with open("README.rst") as readme_file:
long_description = readme_file.read()
with open("LICENSING.rst") as licensing_file:
long_description = long_description.replace(".. include:: LICENSING.rst\n",
licensing_file.read())
def verify_wolfssl_config():
# verify wolfSSL library has been configured correctly, so that cffi
# binding work correctly.
# open <wolfssl/options.h> header to parse for #define's
# This will throw a FileNotFoundError if not able to find options.h
optionsHeaderPath = wolfssl_inc_path() + "/wolfssl/options.h"
optionsHeader = open(optionsHeaderPath, 'r')
optionsHeaderStr = optionsHeader.read()
optionsHeader.close()
# require HAVE_SNI (--enable-sni) in native lib
if '#define HAVE_SNI' not in optionsHeaderStr:
raise RuntimeError("wolfSSL needs to be compiled with --enable-sni")
# require OPENSSL_EXTRA (--enable-opensslextra) in native lib
if '#define OPENSSL_EXTRA' not in optionsHeaderStr:
raise RuntimeError("wolfSSL needs to be compiled with "
"--enable-opensslextra")
class cffiBuilder(build_ext, object):
def build_extension(self, ext):
""" Compile manually the wolfssl-py extension, bypass setuptools
"""
# if USE_LOCAL_WOLFSSL environment variable has been defined,
# do not clone and compile wolfSSL from GitHub
if os.environ.get("USE_LOCAL_WOLFSSL") is None:
build_wolfssl(wolfssl.__wolfssl_version__)
verify_wolfssl_config()
super(cffiBuilder, self).build_extension(ext)
setup(
name=wolfssl.__title__,
version=wolfssl.__version__,
description=wolfssl.__summary__,
long_description=long_description,
author=wolfssl.__author__,
author_email=wolfssl.__email__,
url=wolfssl.__uri__,
license=wolfssl.__license__,
packages=["wolfssl"],
package_dir={"":package_dir},
zip_safe=False,
cffi_modules=["./src/wolfssl/_build_ffi.py:ffi"],
keywords="wolfssl, wolfcrypt, security, cryptography",
classifiers=[
u"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
u"License :: Other/Proprietary License",
u"Operating System :: OS Independent",
u"Programming Language :: Python :: 2.7",
u"Programming Language :: Python :: 3.4",
u"Programming Language :: Python :: 3.5",
u"Programming Language :: Python :: 3.6",
u"Topic :: Security",
u"Topic :: Security :: Cryptography",
u"Topic :: Software Development"
],
setup_requires=["cffi"],
install_requires=["cffi"],
test_suite="tests",
tests_require=["tox", "pytest"],
cmdclass={"build_ext" : cffiBuilder}
)