mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-06-06 06:03:12 +03:00
Run-time check for Decimal on Python 2.3.
This commit is contained in:
parent
d67b171eed
commit
f03b94d84b
|
@ -1,3 +1,8 @@
|
||||||
|
2005-11-03 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* Applied patch from Daniele Varazzo to enablÃeDecimal on Python
|
||||||
|
2.3 when the module is available (run-time check, nice.)
|
||||||
|
|
||||||
2005-10-26 Federico Di Gregorio <fog@initd.org>
|
2005-10-26 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* setup.cfg: added include_dirs line for SUSE 9.3.
|
* setup.cfg: added include_dirs line for SUSE 9.3.
|
||||||
|
|
|
@ -363,6 +363,11 @@ psyco_decimal_init(void)
|
||||||
if (decimal) {
|
if (decimal) {
|
||||||
decimalType = PyObject_GetAttrString(decimal, "Decimal");
|
decimalType = PyObject_GetAttrString(decimal, "Decimal");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
PyErr_Clear();
|
||||||
|
decimalType = (PyObject *)&PyFloat_Type;
|
||||||
|
Py_INCREF(decimalType);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ define=PSYCOPG_EXTENSIONS,PSYCOPG_DISPLAY_SIZE,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3
|
||||||
# Set to 1 to use Python datatime objects for default date/time representation
|
# Set to 1 to use Python datatime objects for default date/time representation
|
||||||
use_pydatetime=1
|
use_pydatetime=1
|
||||||
|
|
||||||
|
# Set to 1 if you want to enable "Decimal" type on python 2.3.
|
||||||
|
# If the "decimal" module is found in the PYTHONPATH it will be used,
|
||||||
|
# else fall back on the float type.
|
||||||
|
use_decimal=0
|
||||||
|
|
||||||
# "include_dirs" is the preferred method for locating postgresql headers,
|
# "include_dirs" is the preferred method for locating postgresql headers,
|
||||||
# but some extra checks on sys.platform will still be done in setup.py.
|
# but some extra checks on sys.platform will still be done in setup.py.
|
||||||
# The next line is the default as used on psycopg author Debian laptop:
|
# The next line is the default as used on psycopg author Debian laptop:
|
||||||
|
|
17
setup.py
17
setup.py
|
@ -81,11 +81,13 @@ class psycopg_build_ext(build_ext):
|
||||||
('use-pg-dll', None,
|
('use-pg-dll', None,
|
||||||
"Build against libpq.dll"),
|
"Build against libpq.dll"),
|
||||||
('use-pydatetime', None,
|
('use-pydatetime', None,
|
||||||
"Use Python datatime objects for date and time representation.")
|
"Use Python datatime objects for date and time representation."),
|
||||||
|
('use-decimal', None,
|
||||||
|
"Use Decimal type even on Python 2.3 if the module is provided."),
|
||||||
])
|
])
|
||||||
|
|
||||||
boolean_options = build_ext.boolean_options[:]
|
boolean_options = build_ext.boolean_options[:]
|
||||||
boolean_options.extend(('use-pg-dll', 'use-pydatetime'))
|
boolean_options.extend(('use-pg-dll', 'use-pydatetime', 'use-decimal'))
|
||||||
|
|
||||||
# libpq directory in win32 source distribution: compiler dependant.
|
# libpq directory in win32 source distribution: compiler dependant.
|
||||||
libpqdir = None
|
libpqdir = None
|
||||||
|
@ -246,9 +248,7 @@ define_macros.append(('PY_MINOR_VERSION', str(sys.version_info[1])))
|
||||||
# some macros related to python versions and features
|
# some macros related to python versions and features
|
||||||
if sys.version_info[0] >= 2 and sys.version_info[1] >= 3:
|
if sys.version_info[0] >= 2 and sys.version_info[1] >= 3:
|
||||||
define_macros.append(('HAVE_PYBOOL','1'))
|
define_macros.append(('HAVE_PYBOOL','1'))
|
||||||
if sys.version_info[0] >= 2 and sys.version_info[1] >= 4:
|
|
||||||
define_macros.append(('HAVE_DECIMAL','1'))
|
|
||||||
|
|
||||||
# gather information to build the extension module
|
# gather information to build the extension module
|
||||||
ext = [] ; data_files = []
|
ext = [] ; data_files = []
|
||||||
|
|
||||||
|
@ -265,6 +265,13 @@ from ConfigParser import ConfigParser
|
||||||
parser = ConfigParser()
|
parser = ConfigParser()
|
||||||
parser.read('setup.cfg')
|
parser.read('setup.cfg')
|
||||||
|
|
||||||
|
# Choose if to use Decimal type
|
||||||
|
use_decimal = int(parser.get('build_ext', 'use_decimal'))
|
||||||
|
if sys.version_info[0] >= 2 and (
|
||||||
|
sys.version_info[1] >= 4 or (sys.version_info[1] == 3 and use_decimal)):
|
||||||
|
define_macros.append(('HAVE_DECIMAL','1'))
|
||||||
|
version_flags.append('dec')
|
||||||
|
|
||||||
# Choose a datetime module
|
# Choose a datetime module
|
||||||
have_pydatetime = False
|
have_pydatetime = False
|
||||||
have_mxdatetime = False
|
have_mxdatetime = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user