Skip to content

Commit 8d6ea75

Browse files
author
Geert Vanderkelen
committed
Merge branch 'fix-BUG20098583' into release-2.1.1
2 parents fc3b703 + a080394 commit 8d6ea75

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lib/cpy_distutils.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"""
2626

2727
from distutils.command.build_ext import build_ext
28-
from distutils.command.build import build
2928
from distutils.command.install import install
3029
from distutils.command.install_lib import install_lib
3130
from distutils.errors import DistutilsExecError
@@ -223,16 +222,25 @@ def _finalize_connector_c(self, connc_loc):
223222
self._mysql_config_info = None
224223
min_version = BuildMySQLExt.min_connector_c_version
225224

225+
err_invalid_loc = "MySQL C API location is invalid; was %s"
226+
226227
mysql_config = None
227228
err_version = "MySQL C API {0}.{1}.{2} or later required".format(
228229
*BuildMySQLExt.min_connector_c_version)
229230

231+
if not os.path.exists(connc_loc):
232+
log.error(err_invalid_loc, connc_loc)
233+
sys.exit(1)
234+
230235
if os.path.isdir(connc_loc):
231-
# if directory, and no mysql_config is availble, figure out the
236+
# if directory, and no mysql_config is available, figure out the
232237
# lib/ and include/ folders from the the filesystem
233238
mysql_config = os.path.join(connc_loc, 'bin', 'mysql_config')
234-
if not (os.path.isfile(mysql_config) and
235-
os.access(mysql_config, os.X_OK)):
239+
if os.path.isfile(mysql_config) and \
240+
os.access(mysql_config, os.X_OK):
241+
connc_loc = mysql_config
242+
else:
243+
# Probably using MS Windows
236244
myconfigh = os.path.join(connc_loc, 'include', 'my_config.h')
237245

238246
if not os.path.exists(myconfigh):
@@ -280,11 +288,10 @@ def _finalize_connector_c(self, connc_loc):
280288
else:
281289
self.arch = 'i386'
282290

283-
# We were given the mysql_config, or we discovered it
284-
if not mysql_config:
291+
# We were given the location of the mysql_config tool (not on Windows)
292+
if not os.name == 'nt' and os.path.isfile(connc_loc) \
293+
and os.access(connc_loc, os.X_OK):
285294
mysql_config = connc_loc
286-
287-
if os.path.isfile(mysql_config) and os.access(mysql_config, os.X_OK):
288295
# Check mysql_config
289296
myc_info = get_mysql_config_info(mysql_config)
290297

@@ -299,8 +306,8 @@ def _finalize_connector_c(self, connc_loc):
299306
self.arch = self._mysql_config_info['arch']
300307
connc_64bit = self.arch == 'x86_64'
301308

302-
else:
303-
log.error("MySQL tool mysql_config not available")
309+
if not os.path.exists(include_dir):
310+
log.error(err_invalid_loc, connc_loc)
304311
sys.exit(1)
305312

306313
# Set up the build_ext class
@@ -404,6 +411,7 @@ def finalize_options(self):
404411
install_lib.finalize_options(self)
405412
self.set_undefined_options('install',
406413
('byte_code_only', 'byte_code_only'))
414+
self.set_undefined_options('build', ('build_base', 'build_dir'))
407415

408416
def run(self):
409417
self.build()
@@ -456,4 +464,6 @@ def run(self):
456464
# We install pure Python code in purelib location when no
457465
# extension is build
458466
self.install_lib = self.install_purelib
467+
else:
468+
log.info("installing C Extension")
459469
install.run(self)

0 commit comments

Comments
 (0)