Skip to content

Commit

Permalink
Issue 227: Fix Python 2.5 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
mkleehammer committed Jan 13, 2012
1 parent 404a3ba commit 6a457c3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 36 deletions.
72 changes: 37 additions & 35 deletions setup.py
Expand Up @@ -67,43 +67,45 @@ def main():
if exists('MANIFEST'): if exists('MANIFEST'):
os.remove('MANIFEST') os.remove('MANIFEST')


options = {} kwargs = {
'name': "pyodbc",
'version': version_str,
'description': "DB API Module for ODBC",

'long_description': ('A Python DB API 2 module for ODBC. This project provides an up-to-date, '
'convenient interface to ODBC using native data types like datetime and decimal.'),

'maintainer': "Michael Kleehammer",
'maintainer_email': "michael@kleehammer.com",

'ext_modules': [Extension('pyodbc', files, **settings)],

'license': 'MIT',

'classifiers': ['Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Database',
],

'url': 'http://code.google.com/p/pyodbc',
'download_url': 'http://code.google.com/p/pyodbc/downloads/list',
'cmdclass': { 'version' : VersionCommand,
'tags' : TagsCommand }
}

if sys.hexversion >= 0x02060000: if sys.hexversion >= 0x02060000:
options['bdist_wininst'] = {'user_access_control' : 'auto'} kwargs['options'] = {

'bdist_wininst': {'user_access_control' : 'auto'}
setup (name = "pyodbc", }
version = version_str,
description = "DB API Module for ODBC",

long_description = ('A Python DB API 2 module for ODBC. This project provides an up-to-date, '
'convenient interface to ODBC using native data types like datetime and decimal.'),

maintainer = "Michael Kleehammer",
maintainer_email = "michael@kleehammer.com",

ext_modules = [Extension('pyodbc', files, **settings)],

options = options,

license = 'MIT',

classifiers = ['Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Database',
],

url = 'http://code.google.com/p/pyodbc',
download_url = 'http://code.google.com/p/pyodbc/downloads/list',
cmdclass = { 'version' : VersionCommand,
'tags' : TagsCommand })


setup(**kwargs)




def get_compiler_settings(version_str): def get_compiler_settings(version_str):
Expand Down
1 change: 0 additions & 1 deletion src/pyodbc.h
Expand Up @@ -44,7 +44,6 @@ typedef unsigned long long UINT64;
#include <boolobject.h> #include <boolobject.h>
#include <unicodeobject.h> #include <unicodeobject.h>
#include <structmember.h> #include <structmember.h>
#include <bytesobject.h>


#include <sql.h> #include <sql.h>
#include <sqlext.h> #include <sqlext.h>
Expand Down
13 changes: 13 additions & 0 deletions src/pyodbccompat.h
Expand Up @@ -16,6 +16,19 @@
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif #endif


// Macros were introduced in 2.6 to map "bytes" to "str" in Python 2. Back port to 2.5.
#if PY_VERSION_HEX >= 0x02060000
#include <bytesobject.h>
#else
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define PyBytes_Size PyString_Size
#define _PyBytes_Resize _PyString_Resize
#endif

// Used for items that are ANSI in Python 2 and Unicode in Python 3 or in int 2 and long in 3. // Used for items that are ANSI in Python 2 and Unicode in Python 3 or in int 2 and long in 3.


#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
Expand Down

0 comments on commit 6a457c3

Please sign in to comment.