1
0
Fork 0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-06-03 11:36:06 +02:00
ultrajson/setup.py

89 lines
2.3 KiB
Python
Raw Normal View History

import os.path
import re
from glob import glob
2020-03-24 08:59:47 +01:00
from setuptools import Extension, setup
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
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
"""
2012-02-07 09:00:52 +01:00
dconv_source_files = glob("./deps/double-conversion/double-conversion/*.cc")
dconv_source_files.append("./lib/dconv_wrapper.cc")
module1 = Extension(
"ujson",
sources=dconv_source_files
+ [
"./python/ujson.c",
"./python/objToJSON.c",
"./python/JSONtoObj.c",
"./lib/ultrajsonenc.c",
"./lib/ultrajsondec.c",
],
include_dirs=["./python", "./lib", "./deps/double-conversion/double-conversion"],
extra_compile_args=["-D_GNU_SOURCE"],
extra_link_args=["-lstdc++", "-lm"],
)
def get_version():
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)
f = open("README.rst")
2012-10-01 10:36:38 +02:00
try:
README = f.read()
finally:
f.close()
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 ""
setup(
name="ujson",
description="Ultra fast JSON encoder and decoder for Python",
long_description=README,
ext_modules=[module1],
author="Jonas Tarnstrom",
2020-02-25 20:19:36 +01:00
download_url="https://github.com/ultrajson/ultrajson",
platforms=["any"],
2020-02-25 20:19:36 +01:00
url="https://github.com/ultrajson/ultrajson",
project_urls={"Source": "https://github.com/ultrajson/ultrajson"},
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",
classifiers=[x for x in CLASSIFIERS.split("\n") if x],
)