-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
90 lines (77 loc) · 2.6 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
import os
import shlex
import subprocess
import sys
from setuptools import setup
from setuptools.extension import Extension
try:
from Cython.Build import cythonize
except ImportError:
def cythonize(extensions, **kwargs):
for extension in extensions:
for i, filename in enumerate(extension.sources):
if filename.endswith('.pxy'):
extension.sources = filename[:-4] + '.c'
return extensions
test_requires = ['pytest']
test_pep8_requires = ['flake8', 'flake8-import-order', 'pep8-naming']
test_docs_requires = ['docutils', 'markdown']
extra_compile_args = []
extra_link_args = []
def pkgconfig(flags, *pkgs):
cmd = ['pkg-config', flags]
cmd.extend(pkgs)
out = subprocess.check_output(cmd)
if isinstance(out, bytes):
out = out.decode(sys.getfilesystemencoding())
return shlex.split(out)
JOSE_DIR = os.environ.get('JOSE_DIR')
if JOSE_DIR and os.path.isdir(JOSE_DIR):
JOSE_DIR = os.path.abspath(JOSE_DIR)
JOSE_LIBRARY_DIR = os.path.join(JOSE_DIR, '.libs')
os.environ['PKG_CONFIG_PATH'] = JOSE_DIR
extra_compile_args.append('-I' + JOSE_DIR)
extra_link_args.append('-L' + JOSE_LIBRARY_DIR)
extra_link_args.append('-Wl,-rpath,' + JOSE_LIBRARY_DIR)
extra_compile_args.extend(
pkgconfig('--cflags', 'jose-openssl', 'jose-zlib'))
extra_link_args.extend(
pkgconfig('--libs', 'jose-openssl', 'jose-zlib'))
extensions = [
Extension(
'jose._jose',
sources=['_jose.pyx'],
depends=['src/jose/jansson.pxd', 'src/jose/jose.pxd', 'setup.py'],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
]
setup(
name='jose',
description='Cython wrapper for libjose',
ext_modules=cythonize(extensions, include_path=['src/jose']),
version='4',
license='Apache 2.0',
maintainer='Latchset Contributors',
maintainer_email='[email protected]',
url='https://github.com/latchset/pyjose',
packages=['jose'],
package_dir={'jose': 'src/jose'},
package_data={'jose': ['*.pxd']},
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Programming Language :: Cython',
'Programming Language :: C',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Intended Audience :: Developers',
'Topic :: Security',
'Topic :: Software Development :: Libraries :: Python Modules'
],
tests_require=test_requires,
extras_require={
'test': test_requires,
'test_docs': test_docs_requires,
'test_pep8': test_pep8_requires,
},
)