Skip to content

Commit

Permalink
Building on MinGW
Browse files Browse the repository at this point in the history
mkleehammer/pyodbc/#1168
  • Loading branch information
RoDuth committed Dec 19, 2024
1 parent 12fe42e commit 05345ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 13 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/pyodbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down

0 comments on commit 05345ac

Please sign in to comment.