diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..f2f03d0 --- /dev/null +++ b/README.rst @@ -0,0 +1 @@ +Fork of TwoLaid/python-sqlparser (https://github.com/TwoLaid/python-sqlparser.git). Updated its original setup.py to make this package installable using pip. diff --git a/setup.py b/setup.py index 5aa574a..196b135 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,24 @@ -# coding=utf-8 - -from distutils.core import setup, Extension -import sys +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" + +# Always prefer setuptools over distutils +from __future__ import print_function +from setuptools import setup, find_packages, Extension +# To use a consistent encoding +from codecs import open import os +from os import path +import sys + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the README file +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: + long_description = f.read() ARCH='64' SQLPARSER_DIR = './general_sql_parser/' @@ -28,12 +44,12 @@ def download_library(): if ARCH == '64': url = "http://www.sqlparser.com/dl/gsqlparser_c_linux64_trial_0_3_8.tar.gz" - print "Downloading library from '%s'..." % url + print("Downloading library from '%s'..." % url) urllib.urlretrieve(url, file_name) - print "Done!" - print "Extracting archive..." + print("Done!") + print("Extracting archive...") if os.name == "nt": import zipfile @@ -46,44 +62,40 @@ def download_library(): archive = tarfile.open(file_name) archive.extractall(SQLPARSER_DIR) - print "Done!" - - -if __name__ == '__main__': - if not os.path.isdir(SQLPARSER_DIR): - print "Could not find the general sql parser library in %s" % SQLPARSER_DIR - answer = raw_input("Do you want to download it now? (Y, N): ") - - if answer and answer.upper() == 'Y': - download_library() - - # check again (the user might have downloaded the library) - if os.path.isdir(SQLPARSER_DIR): - parsebridge = Extension('sqlparser', - sources = ['Parser.c', 'Statement.c', 'Node.c', 'ENodeType.c', 'parsebridgemodule.c', - SQLPARSER_DIR + 'ext/node_visitor/node_visitor.c', - SQLPARSER_DIR + 'ext/expr_traverse/expr_traverse.c', - SQLPARSER_DIR + 'ext/modifysql/modifysql.c' ], - include_dirs = [ SQLPARSER_DIR + 'core/', - SQLPARSER_DIR + 'ext/collection/includes/', - SQLPARSER_DIR + 'ext/expr_traverse/', - SQLPARSER_DIR + 'ext/modifysql/', - SQLPARSER_DIR + 'ext/node_visitor/' ], - library_dirs = [ SQLPARSER_DIR + '/lib/' ], - libraries = [ 'gspcollection', 'gspcore' ], - define_macros = [ ('_CRT_SECURE_NO_WARNINGS', None), ('DONT_FIX_FRAGMENTS', None), ], - extra_compile_args = ['-Wno-strict-prototypes'], - - ) - - if sys.platform == 'win32' or sys.platform == 'win64': - parsebridge.extra_link_args = [ '/MANIFEST', '/DEBUG' ] - parsebridge.extra_compile_args = [ '/Zi' ] - - setup (name = 'sqlparser', - version = '1.0', - description = 'A package for parsing SQL queries', - author = 'Timo Djürken', - url = 'https://github.com/TwoLaid/python-sqlparser', - license = 'GPL', - ext_modules = [ parsebridge ]) + print("Done!") + + +if not os.path.isdir(SQLPARSER_DIR): + download_library() + +# check again (the user might have downloaded the library) +if os.path.isdir(SQLPARSER_DIR): + parsebridge = Extension('sqlparser', + sources = ['Parser.c', 'Statement.c', 'Node.c', 'ENodeType.c', 'parsebridgemodule.c', + SQLPARSER_DIR + 'ext/node_visitor/node_visitor.c', + SQLPARSER_DIR + 'ext/expr_traverse/expr_traverse.c', + SQLPARSER_DIR + 'ext/modifysql/modifysql.c' ], + include_dirs = [ SQLPARSER_DIR + 'core/', + SQLPARSER_DIR + 'ext/collection/includes/', + SQLPARSER_DIR + 'ext/expr_traverse/', + SQLPARSER_DIR + 'ext/modifysql/', + SQLPARSER_DIR + 'ext/node_visitor/' ], + library_dirs = [ SQLPARSER_DIR + '/lib/' ], + libraries = [ 'gspcollection', 'gspcore' ], + define_macros = [ ('_CRT_SECURE_NO_WARNINGS', None), ('DONT_FIX_FRAGMENTS', None), ], + extra_compile_args = ['-Wno-strict-prototypes'], + + ) + + if sys.platform == 'win32' or sys.platform == 'win64': + parsebridge.extra_link_args = [ '/MANIFEST', '/DEBUG' ] + parsebridge.extra_compile_args = [ '/Zi' ] + +setup (name = 'sqlparser', + version = '1.0', + description = 'A package for parsing SQL queries', + author = 'Timo Djurken', + url = 'https://github.com/TwoLaid/python-sqlparser', + license = 'GPL', + ext_modules = [ parsebridge ]) +