123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- from glob import glob
- from os import environ
- from setuptools import Extension, find_packages, setup
- from setuptools.command.install import install
- from subprocess import check_output
- 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"
- sources = (
- 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") +
- [
- f"{EXT_DIR}/hashmap/hashmap.c",
- f"{EXT_DIR}/tpl/src/tpl.c",
- f"{EXT_DIR}/log/src/log.c",
- ]
- )
- 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 = [
- "-std=gnu11",
- "-Wall",
- # "-Wextra",
- "-fPIC",
- "-MMD",
- ]
- if debug:
- print("Compiling with debug flags.")
- compile_args.extend([
- "-UNDEBUG", "-U_FORTIFY_SOURCE",
- "-DDEBUG", "-g3", "-O1"
- ])
- else:
- compile_args.extend(["-g0", "-O3"])
- # with open(path.join(ROOT_DIR, "README.md"), "r") as fh:
- # long_description = fh.read()
- class LSUPInstallCmd(install):
- """
- Run LSUP-specific hooks in extension build phase.
- TODO Extending the Extension class may be best to narrow the scope to the
- C module.
- """
- def run(self):
- print("Generating parsers.")
- target = "codec_dbg" if debug else "codec"
- print(f"Making {target}.")
- check_output(["make", target])
- install.run(self)
- setup(
- name="lsup_rdf",
- version="1.0a5",
- 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={"lsup_rdf": "cpython/lsup_rdf"},
- packages=find_packages(where="cpython"),
- 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,
- language="c",
- include_dirs=include_dirs,
- libraries=["xxhash", "lmdb", "uuid"],
- extra_compile_args=compile_args,
- ),
- ],
- python_requires=">=3.8",
- )
|