From dff55616f1e40ec0f655afce989d9f625cb3ec4e Mon Sep 17 00:00:00 2001 From: oreh Date: Thu, 17 Dec 2015 06:06:14 +0000 Subject: [PATCH 1/3] Use setuptools instead of distutils --- setup.py | 93 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/setup.py b/setup.py index 5aa574a..60fe424 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,23 @@ -# coding=utf-8 +"""A setuptools based setup module. -from distutils.core import setup, Extension -import sys +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" + +# Always prefer setuptools over distutils +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/' @@ -49,41 +64,37 @@ def download_library(): 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 ]) +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 ]) + From 127d06c765d58b4b606d2664939080b3a5f3cf34 Mon Sep 17 00:00:00 2001 From: oreh Date: Thu, 17 Dec 2015 06:12:39 +0000 Subject: [PATCH 2/3] Add a rst version of readme --- README.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.rst 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. From 711b82f241cc8c72ee250cb66b0d81a58fd331a0 Mon Sep 17 00:00:00 2001 From: oreh Date: Sun, 20 Dec 2015 17:20:11 +0000 Subject: [PATCH 3/3] use print function --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 60fe424..196b135 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ """ # 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 @@ -43,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 @@ -61,7 +62,7 @@ def download_library(): archive = tarfile.open(file_name) archive.extractall(SQLPARSER_DIR) - print "Done!" + print("Done!") if not os.path.isdir(SQLPARSER_DIR):