From 05345ac55918840489d79f0f4ff2b79a8dfde8b1 Mon Sep 17 00:00:00 2001 From: RoDuth Date: Mon, 20 Feb 2023 09:56:34 +1000 Subject: [PATCH] Building on MinGW mkleehammer/pyodbc/#1168 --- setup.py | 15 +++++++++++++-- src/pyodbc.h | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index be5ac895..328bc501 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, os, shlex, re +import sys, os, re, shlex, sysconfig from os.path import exists, join, isdir, relpath, expanduser from pathlib import Path from inspect import cleandoc @@ -83,7 +83,18 @@ def get_compiler_settings(): 'define_macros': [('PYODBC_VERSION', VERSION)] } - if os.name == 'nt': + if 'mingw' in sysconfig.get_platform(): + # Windows MinGW NOTE os.name = 'nt' and output from + # `odbc_config --cflags --libs` does not work as expected, excluding + # C:/msys64/ from begining of paths + settings['extra_compile_args'].extend([ + '-Wno-write-strings', + ]) + unixodbc_headers = os.getenv("MSYSTEM_PREFIX") + "/include/unixodbc" + settings['include_dirs'] = [unixodbc_headers] + settings['libraries'].append('odbc32') + + elif os.name == 'nt': settings['extra_compile_args'].extend([ '/Wall', '/wd4514', # unreference inline function removed diff --git a/src/pyodbc.h b/src/pyodbc.h index febcc677..7c8946d0 100644 --- a/src/pyodbc.h +++ b/src/pyodbc.h @@ -28,7 +28,8 @@ typedef long long INT64; typedef unsigned long long UINT64; #define _strcmpi strcasecmp #define _strdup strdup - inline int max(int lhs, int rhs) { return (rhs > lhs) ? rhs : lhs; } +inline int max(int lhs, int rhs) { return (rhs > lhs) ? rhs : lhs; } +inline int min(int lhs, int rhs) { return (rhs < lhs) ? rhs : lhs; } #endif #ifdef __SUN__