forked from ultrajson/ultrajson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
60 lines (50 loc) · 1.45 KB
/
Copy pathsetup.py
File metadata and controls
60 lines (50 loc) · 1.45 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
import platform
import shlex
from glob import glob
from os import environ, pathsep
from setuptools import Extension, setup
from setuptools_scm import get_version
dconv_includes = [
dir
for dir in environ.get(
"UJSON_BUILD_DC_INCLUDES",
"./src/ujson/deps/double-conversion/double-conversion",
).split(pathsep)
if dir
]
dconv_libs = shlex.split(environ.get("UJSON_BUILD_DC_LIBS", ""))
dconv_source_files = []
if not dconv_libs:
dconv_source_files.extend(
glob("./src/ujson/deps/double-conversion/double-conversion/*.cc")
)
dconv_source_files.append("./src/ujson/dconv_wrapper.cc")
if platform.system() == "Linux" and environ.get("UJSON_BUILD_NO_STRIP", "0") not in (
"1",
"True",
):
strip_flags = ["-Wl,--strip-all"]
else:
strip_flags = []
def local_scheme(version):
"""Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2)
to be able to upload to Test PyPI"""
return ""
version = get_version(local_scheme=local_scheme)
module1 = Extension(
"ujson",
sources=dconv_source_files
+ [
"./src/ujson/ujson.c",
"./src/ujson/encode.c",
"./src/ujson/decode.c",
],
include_dirs=["./src/ujson"] + dconv_includes,
define_macros=[("UJSON_VERSION", f'"{version}"')],
extra_compile_args=["-D_GNU_SOURCE"],
extra_link_args=["-lstdc++", "-lm"] + dconv_libs + strip_flags,
)
setup(
ext_modules=[module1],
use_scm_version={"local_scheme": local_scheme},
)