Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on MinGW #1169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 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,14 @@ def get_compiler_settings():
'define_macros': [('PYODBC_VERSION', VERSION)]
}

if os.name == 'nt':
if 'mingw' in sysconfig.get_platform():
# Windows mingw (note that os.name == 'nt' is True)
settings['extra_compile_args'].extend([
'-Wno-write-strings',
])
settings['libraries'].append('odbc32')

elif os.name == 'nt':
settings['extra_compile_args'].extend([
'/Wall',
'/wd4514', # unreference inline function removed
Expand Down
5 changes: 3 additions & 2 deletions 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 All @@ -45,7 +46,7 @@ typedef unsigned long long UINT64;
#include <structmember.h>
#include <bytesobject.h>

#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MINGW32__)
#include <windows.h>
#endif

Expand Down
3 changes: 2 additions & 1 deletion src/pyodbcmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ static bool AllocateEnv()
}

SQLPOINTER defaultVersion = (SQLPOINTER)SQL_OV_ODBC3;
#ifdef SQL_OV_ODBC3_80
PyObject* odbcversion = PyObject_GetAttrString(pModule, "odbcversion");
if (PyObject_TypeCheck(odbcversion, &PyUnicode_Type)) {
if (PyUnicode_CompareWithASCIIString(odbcversion, "3.8") == 0)
Expand All @@ -311,7 +312,7 @@ static bool AllocateEnv()
}
}
Py_DECREF(odbcversion);

#endif
if (!SQL_SUCCEEDED(SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, defaultVersion, sizeof(int))))
{
PyErr_SetString(PyExc_RuntimeError, "Unable to set SQL_ATTR_ODBC_VERSION attribute.");
Expand Down