mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 10:23:43 +03:00
Don't build mx.DateTime support if the module can't be imported
Previously we only checked for the existence of the include files, but this doesn't imply the presence of the module. Particularly true in restricted environments such as virtualenv. Closes ticket #53.
This commit is contained in:
parent
c687f1d816
commit
af424821b7
7
NEWS
7
NEWS
|
@ -1,3 +1,10 @@
|
|||
What's new in psycopg 2.4.2
|
||||
---------------------------
|
||||
|
||||
- Don't build mx.DateTime support if the module can't be imported
|
||||
(ticket #53).
|
||||
|
||||
|
||||
What's new in psycopg 2.4.1
|
||||
---------------------------
|
||||
|
||||
|
|
18
setup.py
18
setup.py
|
@ -450,12 +450,18 @@ if parser.has_option('build_ext', 'mx_include_dir'):
|
|||
else:
|
||||
mxincludedir = os.path.join(get_python_inc(plat_specific=1), "mx")
|
||||
if os.path.exists(mxincludedir):
|
||||
include_dirs.append(mxincludedir)
|
||||
define_macros.append(('HAVE_MXDATETIME','1'))
|
||||
sources.append('adapter_mxdatetime.c')
|
||||
depends.extend(['adapter_mxdatetime.h', 'typecast_mxdatetime.c'])
|
||||
have_mxdatetime = True
|
||||
version_flags.append('mx')
|
||||
# Check if mx.datetime is importable at all: see ticket #53
|
||||
try:
|
||||
import mx.DateTime
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
include_dirs.append(mxincludedir)
|
||||
define_macros.append(('HAVE_MXDATETIME','1'))
|
||||
sources.append('adapter_mxdatetime.c')
|
||||
depends.extend(['adapter_mxdatetime.h', 'typecast_mxdatetime.c'])
|
||||
have_mxdatetime = True
|
||||
version_flags.append('mx')
|
||||
|
||||
# now decide which package will be the default for date/time typecasts
|
||||
if have_pydatetime and (use_pydatetime or not have_mxdatetime):
|
||||
|
|
Loading…
Reference in New Issue
Block a user