|
@@ -1,46 +1,64 @@
|
|
|
from glob import glob
|
|
|
-from os import path
|
|
|
-from setuptools import Extension, setup
|
|
|
+from os import environ
|
|
|
+from setuptools import Extension, find_packages, setup
|
|
|
from setuptools.command.install import install
|
|
|
-from subprocess import check_output, CalledProcessError
|
|
|
+from subprocess import check_output
|
|
|
|
|
|
|
|
|
-ROOT_DIR = path.dirname(path.realpath(__file__))
|
|
|
-MOD_DIR = path.join(ROOT_DIR, 'cpython')
|
|
|
-SRC_DIR = path.join(ROOT_DIR, 'src')
|
|
|
-CODEC_DIR = path.join(SRC_DIR, 'codec')
|
|
|
-INCL_DIR = path.join(ROOT_DIR, 'include')
|
|
|
-EXT_DIR = path.join(ROOT_DIR, 'ext')
|
|
|
+ROOT_DIR = "."
|
|
|
+SRC_DIR = f"{ROOT_DIR}/src"
|
|
|
+CODEC_DIR = f"{SRC_DIR}/codec"
|
|
|
+CPY_DIR = f"{ROOT_DIR}/cpython"
|
|
|
+INCL_DIR = f"{ROOT_DIR}/include"
|
|
|
+EXT_DIR = f"{ROOT_DIR}/ext"
|
|
|
|
|
|
-LEXER = 're2c'
|
|
|
-PARSER = 'lemon'
|
|
|
+LEXER = "re2c"
|
|
|
+PARSER = "lemon"
|
|
|
|
|
|
|
|
|
sources = (
|
|
|
- glob(path.join(SRC_DIR, '*.c')) +
|
|
|
- glob(path.join(CODEC_DIR, '*_grammar.c')) +
|
|
|
- glob(path.join(SRC_DIR, 'codec', '*_parser.c')) +
|
|
|
- glob(path.join(MOD_DIR, '*.c')) +
|
|
|
+ glob(f"{SRC_DIR}/*.c") +
|
|
|
+ glob(f"{CODEC_DIR}/grammar_*.c") +
|
|
|
+ glob(f"{CODEC_DIR}/parser_*.c") +
|
|
|
+ glob(f"{CODEC_DIR}/codec_*.c") +
|
|
|
+ glob(f"{CPY_DIR}/*.c") +
|
|
|
[
|
|
|
- path.join(EXT_DIR, 'openldap', 'libraries', 'liblmdb', 'mdb.c'),
|
|
|
- path.join(EXT_DIR, 'openldap', 'libraries', 'liblmdb', 'midl.c'),
|
|
|
- path.join(EXT_DIR, 'xxHash', 'xxhash.c'),
|
|
|
- path.join(EXT_DIR, 'hashmap', 'hashmap.c'),
|
|
|
- path.join(EXT_DIR, 'tpl', 'src', 'tpl.c'),
|
|
|
- path.join(EXT_DIR, 'log', 'src', 'log.c'),
|
|
|
+ f"{EXT_DIR}/openldap/libraries/liblmdb/mdb.c",
|
|
|
+ f"{EXT_DIR}/openldap/libraries/liblmdb/midl.c",
|
|
|
+ f"{EXT_DIR}/xxHash/xxhash.c",
|
|
|
+ f"{EXT_DIR}/hashmap/hashmap.c",
|
|
|
+ f"{EXT_DIR}/tpl/src/tpl.c",
|
|
|
+ f"{EXT_DIR}/log/src/log.c",
|
|
|
]
|
|
|
)
|
|
|
|
|
|
-debug = True
|
|
|
+include_dirs = [
|
|
|
+ # ROOT_DIR,
|
|
|
+ INCL_DIR,
|
|
|
+ f"{INCL_DIR}/codec",
|
|
|
+ CPY_DIR,
|
|
|
+ f"{EXT_DIR}/hashmap",
|
|
|
+ f"{EXT_DIR}/tpl/src",
|
|
|
+ f"{EXT_DIR}/log/src",
|
|
|
+]
|
|
|
+
|
|
|
+debug = bool(environ.get("DEBUG"))
|
|
|
|
|
|
compile_args = [
|
|
|
- '-DLOG_USE_COLOR',
|
|
|
- # '-std=c99',
|
|
|
+ "-std=gnu11",
|
|
|
+ "-Wall",
|
|
|
+ # "-Wextra",
|
|
|
+ "-fPIC",
|
|
|
+ "-MMD",
|
|
|
]
|
|
|
if debug:
|
|
|
- compile_args.extend(['-DDEBUG', '-g3', '-O0'])
|
|
|
+ print("Compiling with debug flags.")
|
|
|
+ compile_args.extend(["-DDEBUG", "-g3", "-O1"])
|
|
|
else:
|
|
|
- compile_args.extend(['-g0', '-O3'])
|
|
|
+ compile_args.extend(["-g0", "-O3"])
|
|
|
+
|
|
|
+# with open(path.join(ROOT_DIR, "README.md"), "r") as fh:
|
|
|
+# long_description = fh.read()
|
|
|
|
|
|
|
|
|
class LSUPInstallCmd(install):
|
|
@@ -52,30 +70,9 @@ class LSUPInstallCmd(install):
|
|
|
"""
|
|
|
|
|
|
def run(self):
|
|
|
- # Run grammar and parser generators.
|
|
|
- try:
|
|
|
- lexer_ex_path = check_output(['which', LEXER])
|
|
|
- except CalledProcessError:
|
|
|
- raise SystemError(f'Lexer program `{LEXER}` is not installed.')
|
|
|
-
|
|
|
- try:
|
|
|
- parser_ex_path = check_output(['which', PARSER])
|
|
|
- except CalledProcessError:
|
|
|
- raise SystemError(f'Lexer program `{PARSER}` is not installed.')
|
|
|
-
|
|
|
- print("Generating grammar.")
|
|
|
- for fpath in glob(path.join(CODEC_DIR, '*_grammar.y')):
|
|
|
- check_output([
|
|
|
- parser_ex_path, fpath, 'q', '-m',
|
|
|
- '-T' + fpath.join(CODEC_DIR, 'lempar.c'), f'-d{CODEC_DIR}'
|
|
|
- ])
|
|
|
-
|
|
|
- print("Generating parser.")
|
|
|
- for fpath in glob(path.join(CODEC_DIR, '*_lexer.re')):
|
|
|
- check_output([
|
|
|
- lexer_ex_path, fpath, '-o',
|
|
|
- fpath.replace('_lexer.re', '_parser.c'), '-T', '--case-ranges',
|
|
|
- ])
|
|
|
+ print("Generating parsers.")
|
|
|
+ target = "debug" if debug else "codec"
|
|
|
+ check_output(["make", "-C", CODEC_DIR, target])
|
|
|
|
|
|
install.run(self)
|
|
|
|
|
@@ -83,26 +80,46 @@ class LSUPInstallCmd(install):
|
|
|
setup(
|
|
|
name="lsup_rdf",
|
|
|
version="1.0a2",
|
|
|
- description='Ultra-compact RDF library.',
|
|
|
- author='Stefano Cossu <https://notabug.org/scossu>',
|
|
|
- url='https://notabug.org/scossu/lsup_rdf',
|
|
|
- license='https://notabug.org/scossu/lsup_rdf/src/master/LICENSE',
|
|
|
- package_dir={'lsup_rdf': path.join(MOD_DIR, 'lsup_rdf')},
|
|
|
- packages=['lsup_rdf'],
|
|
|
- cmdclasss={'install': LSUPInstallCmd},
|
|
|
+ description="Ultra-compact RDF library.",
|
|
|
+ # long_description=long_description,
|
|
|
+ # long_description_content_type="text/markdown",
|
|
|
+ author="Stefano Cossu <https://git.knowledgetx.com/scossu>",
|
|
|
+ url="https://git.knowledgetx.com/scossu/lsup_rdf",
|
|
|
+ license="https://git.knowledgetx.com/scossu/lsup_rdf/src/master/LICENSE",
|
|
|
+ package_dir={"": "."},
|
|
|
+ packages=find_packages(where="."),
|
|
|
+ include_package_data=True,
|
|
|
+ cmdclass={"install": LSUPInstallCmd},
|
|
|
+ classifiers=[
|
|
|
+ "Development Status :: 3 - Alpha",
|
|
|
+ "Environment :: Console",
|
|
|
+ "Intended Audience :: Developers",
|
|
|
+ "Intended Audience :: Information Technology",
|
|
|
+ "Intended Audience :: Science/Research",
|
|
|
+ "Intended Audience :: Telecommunications Industry",
|
|
|
+ "License :: Public Domain",
|
|
|
+ "Natural Language :: English",
|
|
|
+ "Operating System :: POSIX :: BSD",
|
|
|
+ "Operating System :: POSIX :: Linux",
|
|
|
+ "Operating System :: POSIX :: Other",
|
|
|
+ "Programming Language :: C",
|
|
|
+ "Programming Language :: Python :: 3",
|
|
|
+ "Programming Language :: Python :: Implementation :: CPython",
|
|
|
+ "Topic :: Database :: Database Engines/Servers",
|
|
|
+ "Topic :: Internet",
|
|
|
+ "Topic :: Scientific/Engineering",
|
|
|
+ "Topic :: Software Development :: Embedded Systems",
|
|
|
+ "Topic :: Software Development :: Libraries",
|
|
|
+ ],
|
|
|
ext_modules=[
|
|
|
Extension(
|
|
|
"_lsup_rdf",
|
|
|
sources,
|
|
|
- include_dirs=[
|
|
|
- ROOT_DIR,
|
|
|
- INCL_DIR,
|
|
|
- path.join(EXT_DIR, 'hashmap'),
|
|
|
- path.join(EXT_DIR, 'tpl', 'src'),
|
|
|
- path.join(EXT_DIR, 'log', 'src'),
|
|
|
- ],
|
|
|
- libraries=['uuid'],
|
|
|
+ language="c",
|
|
|
+ include_dirs=include_dirs,
|
|
|
+ libraries=["xxhash", "lmdb", "uuid"],
|
|
|
extra_compile_args=compile_args,
|
|
|
),
|
|
|
],
|
|
|
+ python_requires=">=3.8",
|
|
|
)
|