summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin 't Hart <colin@bandicoot.favoptic.com>2020-05-04 18:59:37 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2020-05-06 14:42:10 +1200
commitf9442744af6dc59f110973490e765e0d66dd603d (patch)
treea0fb7ba9ab75ef1e4e642619c21d59317a7058dc
parent1ec0bb5633003f16107af68da5baec6e950930d5 (diff)
downloadpsycopg2-f9442744af6dc59f110973490e765e0d66dd603d.tar.gz
Fixed search of mxDateTime headers
- Find mxDateTime.h automatically on path directories. - Prefer mxDateTime.h found in venv over one found in /usr/include.
-rw-r--r--setup.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/setup.py b/setup.py
index 6768cb5..fb745d0 100644
--- a/setup.py
+++ b/setup.py
@@ -525,19 +525,21 @@ parser = configparser.ConfigParser()
parser.read('setup.cfg')
# check for mx package
-have_mxdatetime = False
mxincludedir = ''
if parser.has_option('build_ext', 'mx_include_dir'):
mxincludedir = parser.get('build_ext', 'mx_include_dir')
if not mxincludedir:
- mxincludedir = os.path.join(get_python_inc(plat_specific=1), "mx")
+ # look for mxDateTime.h; prefer one located in venv
+ candidate_dirs = [os.path.join(d, 'mx', 'DateTime', 'mxDateTime') for d in sys.path] \
+ + [os.path.join(get_python_inc(plat_specific=1), "mx")]
+ candidate_dirs = [d for d in candidate_dirs if os.path.exists(os.path.join(d, 'mxDateTime.h'))] or ['']
+ mxincludedir = candidate_dirs[0]
if mxincludedir.strip() and os.path.exists(mxincludedir):
# Build the support for mx: we will check at runtime if it can be imported
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')
# generate a nice version string to avoid confusion when users report bugs