From d21dae637565633f7fa31ae3e33ef0c3828bf52a Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 18 Jan 2019 11:43:44 +0000 Subject: [PATCH] Fix windows build --- MySQLdb/_mysql.c | 13 ++++++------- setup_windows.py | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index cf4566d6..45df37c3 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -917,7 +917,8 @@ _mysql_string_literal( { PyObject *str, *s; char *in, *out; - int len, size; + unsigned long len; + Py_ssize_t size; if (self && PyModule_Check((PyObject*)self)) self = NULL; @@ -1986,12 +1987,10 @@ _mysql_ConnectionObject_repr( { char buf[300]; if (self->open) - sprintf(buf, "<_mysql.connection open to '%.256s' at %lx>", - self->connection.host, - (long)self); + snprintf(buf, 300, "<_mysql.connection open to '%.256s' at %p>", + self->connection.host, self); else - sprintf(buf, "<_mysql.connection closed at %lx>", - (long)self); + snprintf(buf, 300, "<_mysql.connection closed at %p>", self); return PyString_FromString(buf); } @@ -2024,7 +2023,7 @@ _mysql_ResultObject_repr( _mysql_ResultObject *self) { char buf[300]; - sprintf(buf, "<_mysql.result object at %lx>", (long)self); + snprintf(buf, 300, "<_mysql.result object at %p>", self); return PyString_FromString(buf); } diff --git a/setup_windows.py b/setup_windows.py index 5a4d236b..cb2cbab0 100644 --- a/setup_windows.py +++ b/setup_windows.py @@ -11,21 +11,24 @@ def get_config(): extra_objects = [] - if enabled(options, 'embedded'): - client = "mysqld" - else: - client = "mysqlclient" + # client = "mysqlclient" + client = "mariadbclient" vcversion = int(get_build_version()) - library_dirs = [ os.path.join(connector, r'lib\vs%d' % vcversion) ] - libraries = [ 'kernel32', 'advapi32', 'wsock32', client ] - include_dirs = [ os.path.join(connector, r'include') ] - extra_compile_args = [ '/Zl' ] + if client == "mariadbclient": + library_dirs = [os.path.join(connector, 'lib', 'mariadb')] + libraries = ['kernel32', 'advapi32', 'wsock32', 'shlwapi', 'Ws2_32', client ] + include_dirs = [os.path.join(connector, 'include', 'mariadb')] + else: + library_dirs = [os.path.join(connector, r'lib\vs%d' % vcversion), + os.path.join(connector, "lib")] + libraries = ['kernel32', 'advapi32', 'wsock32', client ] + include_dirs = [os.path.join(connector, r'include')] + + extra_compile_args = ['/Zl', '/D_CRT_SECURE_NO_WARNINGS' ] extra_link_args = ['/MANIFEST'] name = "mysqlclient" - if enabled(options, 'embedded'): - name = name + "-embedded" metadata['name'] = name define_macros = [