forked from Iotic-Labs/py-ubjson
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
149 lines (132 loc) · 5.1 KB
/
setup.py
File metadata and controls
149 lines (132 loc) · 5.1 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Copyright (c) 2020-2025 Qianqian Fang <q.fang at neu.edu>. All rights reserved.
# Copyright (c) 2016-2019 Iotic Labs Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/NeuroJSON/pybj/blob/master/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import sys
import os
import warnings
from glob import glob
from platform import python_implementation
from site import getusersitepackages
from numpy import get_include as numpy_get_include
# Allow for environments without setuptools
try:
from setuptools import setup
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup # pylint: disable=ungrouped-imports
from distutils.core import Extension
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError
from distutils.errors import DistutilsPlatformError, DistutilsExecError
def load_description(filename):
script_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(script_dir, filename), "r") as infile:
return infile.read()
user_site = getusersitepackages()
user_numpy_include = os.path.join(user_site, "numpy", "_core", "include")
# Loosely based on https://github.com/mongodb/mongo-python-driver/blob/master/setup.py
class BuildExtWarnOnFail(build_ext):
"""Allow for extension building to fail."""
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
ex = sys.exc_info()[1]
sys.stdout.write("%s\n" % str(ex))
warnings.warn(
"Extension modules: There was an issue with your platform configuration - see above."
)
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError):
ex = sys.exc_info()[1]
sys.stdout.write("%s\n" % str(ex))
warnings.warn(
"Extension module %s: The output above this warning shows how the compilation failed."
% ext.name
)
BUILD_EXTENSIONS = (
"PYBJDATA_NO_EXTENSION" not in os.environ and python_implementation() != "PyPy"
)
COMPILE_ARGS = ["-std=c99", "-DUSE__BJDATA", "-DNPY_NO_DEPRECATED_API", "-DNPY_1_7_API_VERSION"]
# For testing/debug only - some of these are GCC-specific
# COMPILE_ARGS += ['-Wall', '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual', '-Wstrict-prototypes',
# '-pedantic']
setup(
name="bjdata",
version="0.6.6",
description="Binary JData and UBJSON encoder/decoder",
long_description=load_description("README.md"),
long_description_content_type="text/markdown",
author="Qianqian Fang",
author_email="fangqq@gmail.com",
maintainer="Qianqian Fang",
maintainer_email="fangqq@gmail.com",
url="https://github.com/NeuroJSON/pybj",
license="Apache License 2.0",
packages=["bjdata"],
install_requires=["numpy>=1.8.0"],
extras_require={"dev": ["Pympler>=0.7 ,<0.8", "coverage>=4.5.3,<4.6"]},
zip_safe=False,
ext_modules=(
[
Extension(
"_bjdata",
sorted(glob("src/*.c")),
include_dirs=[user_numpy_include, numpy_get_include()],
extra_compile_args=COMPILE_ARGS,
# undef_macros=['NDEBUG']
)
]
if BUILD_EXTENSIONS
else []
),
cmdclass={"build_ext": BuildExtWarnOnFail},
keywords=[
"JSON",
"JData",
"UBJSON",
"BJData",
"OpenJData",
"NeuroJSON",
"JNIfTI",
"Encoder",
"Decoder",
],
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Programming Language :: C",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)