2011-08-16 14:55:32 +02:00
|
|
|
import os.path
|
|
|
|
import re
|
2017-02-14 12:20:04 +01:00
|
|
|
from glob import glob
|
2011-08-16 14:55:32 +02:00
|
|
|
|
2020-03-24 08:59:47 +01:00
|
|
|
from setuptools import Extension, setup
|
|
|
|
|
2020-02-21 10:59:32 +01:00
|
|
|
CLASSIFIERS = """
|
2012-02-07 09:00:52 +01:00
|
|
|
Development Status :: 5 - Production/Stable
|
|
|
|
Intended Audience :: Developers
|
|
|
|
License :: OSI Approved :: BSD License
|
|
|
|
Programming Language :: C
|
2012-06-26 14:08:43 +02:00
|
|
|
Programming Language :: Python :: 3
|
2017-12-25 23:48:27 +01:00
|
|
|
Programming Language :: Python :: 3.5
|
|
|
|
Programming Language :: Python :: 3.6
|
2020-02-14 20:00:55 +01:00
|
|
|
Programming Language :: Python :: 3.7
|
|
|
|
Programming Language :: Python :: 3.8
|
2020-03-15 09:51:19 +01:00
|
|
|
Programming Language :: Python :: 3 :: Only
|
2020-02-21 10:59:32 +01:00
|
|
|
"""
|
2012-02-07 09:00:52 +01:00
|
|
|
|
2020-02-29 11:26:52 +01:00
|
|
|
dconv_source_files = glob("./deps/double-conversion/double-conversion/*.cc")
|
|
|
|
dconv_source_files.append("./lib/dconv_wrapper.cc")
|
2017-02-14 12:20:04 +01:00
|
|
|
|
|
|
|
module1 = Extension(
|
2020-02-23 20:33:39 +01:00
|
|
|
"ujson",
|
2020-02-29 11:26:52 +01:00
|
|
|
sources=dconv_source_files
|
|
|
|
+ [
|
2020-02-23 20:33:39 +01:00
|
|
|
"./python/ujson.c",
|
|
|
|
"./python/objToJSON.c",
|
|
|
|
"./python/JSONtoObj.c",
|
|
|
|
"./lib/ultrajsonenc.c",
|
|
|
|
"./lib/ultrajsondec.c",
|
|
|
|
],
|
2020-02-29 11:26:52 +01:00
|
|
|
include_dirs=["./python", "./lib", "./deps/double-conversion/double-conversion"],
|
2020-02-23 20:33:39 +01:00
|
|
|
extra_compile_args=["-D_GNU_SOURCE"],
|
|
|
|
extra_link_args=["-lstdc++", "-lm"],
|
2017-02-14 12:20:04 +01:00
|
|
|
)
|
|
|
|
|
2011-08-16 14:55:32 +02:00
|
|
|
|
|
|
|
def get_version():
|
2020-02-23 20:33:39 +01:00
|
|
|
filename = os.path.join(os.path.dirname(__file__), "./python/version.h")
|
2012-06-11 19:41:56 +02:00
|
|
|
file = None
|
|
|
|
try:
|
|
|
|
file = open(filename)
|
|
|
|
header = file.read()
|
|
|
|
finally:
|
|
|
|
if file:
|
|
|
|
file.close()
|
|
|
|
m = re.search(r'#define\s+UJSON_VERSION\s+"(\d+\.\d+(?:\.\d+)?)"', header)
|
|
|
|
assert m, "version.h must contain UJSON_VERSION macro"
|
|
|
|
return m.group(1)
|
2011-08-16 14:55:32 +02:00
|
|
|
|
2017-02-14 12:20:04 +01:00
|
|
|
|
2020-02-23 20:33:39 +01:00
|
|
|
f = open("README.rst")
|
2012-10-01 10:36:38 +02:00
|
|
|
try:
|
|
|
|
README = f.read()
|
|
|
|
finally:
|
2020-02-23 20:33:39 +01:00
|
|
|
f.close()
|
|
|
|
|
2017-02-14 12:20:04 +01:00
|
|
|
|
2020-02-26 17:37:41 +01:00
|
|
|
with open("python/version_template.h") as f:
|
|
|
|
version_template = f.read()
|
|
|
|
|
|
|
|
|
|
|
|
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 ""
|
|
|
|
|
|
|
|
|
2017-02-14 12:20:04 +01:00
|
|
|
setup(
|
2020-02-23 20:33:39 +01:00
|
|
|
name="ujson",
|
|
|
|
description="Ultra fast JSON encoder and decoder for Python",
|
|
|
|
long_description=README,
|
|
|
|
ext_modules=[module1],
|
2017-02-14 12:20:04 +01:00
|
|
|
author="Jonas Tarnstrom",
|
2020-02-25 20:19:36 +01:00
|
|
|
download_url="https://github.com/ultrajson/ultrajson",
|
2020-02-23 20:33:39 +01:00
|
|
|
platforms=["any"],
|
2020-02-25 20:19:36 +01:00
|
|
|
url="https://github.com/ultrajson/ultrajson",
|
|
|
|
project_urls={"Source": "https://github.com/ultrajson/ultrajson"},
|
2020-02-26 17:37:41 +01:00
|
|
|
use_scm_version={
|
|
|
|
"local_scheme": local_scheme,
|
|
|
|
"write_to": "python/version.h",
|
|
|
|
"write_to_template": version_template,
|
|
|
|
},
|
|
|
|
setup_requires=["setuptools_scm"],
|
2020-03-15 09:51:19 +01:00
|
|
|
python_requires=">=3.5",
|
2020-02-21 10:59:32 +01:00
|
|
|
classifiers=[x for x in CLASSIFIERS.split("\n") if x],
|
2017-02-14 12:20:04 +01:00
|
|
|
)
|