-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
124 lines (98 loc) · 3.28 KB
/
setup.py
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
118
119
120
121
122
123
124
import os
import sys
import shutil
import subprocess
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
bdist_wheel = None
from setuptools import setup, find_packages, Command
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext
from setuptools.dist import Distribution
# Build with clang if not otherwise specified.
if os.environ.get('LIBAUTHZ_MANYLINUX') == '1':
os.environ.setdefault('CC', 'gcc')
os.environ.setdefault('CXX', 'g++')
else:
os.environ.setdefault('CC', 'clang')
os.environ.setdefault('CXX', 'clang++')
PACKAGE = 'yosai_libauthz'
EXT_EXT = sys.platform == 'darwin' and '.dylib' or '.so'
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info ./target; py.cleanup -d')
def build_yosai_libauthz(base_path):
lib_path = os.path.join(base_path, '_yosai_libauthz.so')
here = os.path.abspath(os.path.dirname(__file__))
cmdline = ['cargo', 'build', '--release']
if not sys.stdout.isatty():
cmdline.append('--color=always')
rv = subprocess.Popen(cmdline, cwd=here).wait()
if rv != 0:
sys.exit(rv)
src_path = os.path.join(here, 'target', 'release',
'libyosai_libauthz' + EXT_EXT)
if os.path.isfile(src_path):
shutil.copy2(src_path, lib_path)
class CustomBuildPy(build_py):
def run(self):
build_py.run(self)
build_yosai_libauthz(os.path.join(self.build_lib, *PACKAGE.split('.')))
class CustomBuildExt(build_ext):
def run(self):
build_ext.run(self)
if self.inplace:
build_py = self.get_finalized_command('build_py')
build_yosai_libauthz(build_py.get_package_dir(PACKAGE))
class BinaryDistribution(Distribution):
"""This is necessary because otherwise the wheel does not know that
we have non pure information.
"""
def has_ext_modules(foo):
return True
cmdclass = {
'build_ext': CustomBuildExt,
'build_py': CustomBuildPy,
'clean': CleanCommand,
}
setup(
name='yosai_libauthz',
version='0.1.0',
url='http://github.com/YosaiProject/yosai_yosai_libauthz',
description='Rust extensions for Yosai',
license='Apache License 2.0',
author='Darin Gordon',
author_email='[email protected]',
packages=find_packages(),
cffi_modules=['build.py:ffi'],
cmdclass=cmdclass,
include_package_data=True,
zip_safe=False,
platforms='any',
install_requires=[
'cffi>=1.6.0',
],
setup_requires=[
'cffi>=1.6.0'
],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Security',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Libraries :: Python Modules',
],
ext_modules=[],
distclass=BinaryDistribution
)