forked from TkTech/pysimdjson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
124 lines (112 loc) · 3.5 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 os.path
import platform
from sysconfig import get_config_vars
from setuptools import setup, find_packages, Extension
from distutils.version import LooseVersion
root = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(root, 'README.md'), 'rb') as readme:
long_description = readme.read().decode('utf-8')
class DelayedInclude:
"""We don't know where pybind will get installed, and we can't call it
until *after* our dependencies are installed (which includes pybind)"""
def __str__(self):
import pybind11
return pybind11.get_include()
extra_compile_args = []
extra_link_args = []
system = platform.system()
if system == 'Darwin':
# A trick picked up from a PyTorch ticket. On OS X 10.9, the C++ stdlib was
# changed. distutils will try to use the same one that CPython was compiled
# for, which won't build at all with a recent XCode. We set
# MACOSX_DEPLOYMENT_TARGET ourselves to force it to use the right stdlib.
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
current_version = platform.mac_ver()[0]
target_version = get_config_vars().get(
'MACOSX_DEPLOYMENT_TARGET',
current_version
)
if (LooseVersion(target_version) < '10.9'
and LooseVersion(current_version) >= '10.9'):
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
elif system == 'Windows':
extra_compile_args.extend([
# /Ob3 is only available on MSVC2019+ but will be safely ignored
# on earlier platforms.
'/Ob3'
])
if 'DEBUG' in os.environ:
extra_compile_args.extend([
'/DEBUG:FULL',
'/Z7'
])
extra_link_args.extend(['/DEBUG:FULL'])
if system in ('Linux', 'Darwin', 'FreeBSD'):
extra_compile_args.extend([
'-std=c++11'
])
setup(
name='pysimdjson',
packages=find_packages(),
version='3.1.1',
description='simdjson bindings for python',
long_description=long_description,
long_description_content_type='text/markdown',
author='Tyler Kennedy',
author_email='tk@tkte.ch',
url='http://github.com/TkTech/pysimdjson',
keywords=['json', 'simdjson', 'simd'],
zip_safe=False,
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
],
python_requires='>3.4',
extras_require={
# Dependencies for building from source.
'dev': [
'pybind11'
],
# Dependencies for package release.
'release': [
'm2r',
'sphinx',
'ghp-import',
'bumpversion'
],
# Dependencies for running tests.
'test': [
'pytest'
],
# Dependencies for running benchmarks.
'benchmark': [
'pytest',
'pytest-benchmark',
'orjson',
'python-rapidjson',
'simplejson',
'ujson',
'yyjson',
'numpy'
]
},
ext_modules=[
Extension(
'csimdjson',
[
'simdjson/binding.cpp',
'simdjson/simdjson.cpp'
],
include_dirs=[
DelayedInclude()
],
language='c++',
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
]
)