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
|
# -*- coding: utf-8; mode: python -*-
# :Project: pglast -- PostgreSQL Languages AST
# :Created: mer 02 ago 2017 15:20:43 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2017, 2018, 2019, 2020, 2021, 2022 Lele Gaifax
#
from pathlib import Path
import subprocess
from setuptools import Extension, setup, find_packages
from setuptools.command.build_ext import build_ext
try:
from Cython.Build import cythonize
except ImportError:
cythonize = lambda e: e
extension_source = 'pglast/parser.c'
else:
extension_source = 'pglast/parser.pyx'
here = Path(__file__).absolute().parent
with (here / 'README.rst').open(encoding='utf-8') as f:
README = f.read()
with (here / 'CHANGES.rst').open(encoding='utf-8') as f:
CHANGES = f.read()
with (here / 'version.txt').open(encoding='utf-8') as f:
VERSION = f.read().strip()
LIBPG_QUERY_DIR = str(Path('libpg_query'))
INCLUDE_DIR = str(Path('libpg_query') / 'src' / 'postgres' / 'include')
INCLUDE_DIR = subprocess.check_output(["/usr/lib/postgresql/15/bin/pg_config", "--includedir-server"]).decode().rstrip()
VENDOR_DIR = str(Path('libpg_query') / 'vendor')
class BuildLibPgQueryFirst(build_ext):
def run(self):
subprocess.check_call(['make', '-s', '-C', LIBPG_QUERY_DIR, 'build'])
super().run()
setup(
name="pglast",
version=VERSION,
url="https://github.com/lelit/pglast",
description="PostgreSQL Languages AST and statements prettifier",
long_description=README + '\n\n' + CHANGES,
long_description_content_type='text/x-rst',
author="Lele Gaifax",
author_email="lele@metapensiero.it",
license="GPLv3+",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"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 :: SQL",
# "Programming Language :: PL/SQL",
"Topic :: Database",
"Topic :: Utilities",
],
keywords="postgresql parser sql prettifier",
packages=find_packages('.'),
#cmdclass={'build_ext': BuildLibPgQueryFirst},
ext_modules=cythonize([
Extension('pglast.parser', [extension_source],
libraries=['pg_query'],
include_dirs=[LIBPG_QUERY_DIR, INCLUDE_DIR, VENDOR_DIR],
library_dirs=[LIBPG_QUERY_DIR]),
]),
install_requires=[
'setuptools',
],
extras_require={
'dev': [
'cython',
'metapensiero.tool.bump_version',
'pycparser',
'readme_renderer',
]
},
entry_points="""\
[console_scripts]
pgpp = pglast.__main__:main
""",
)
|