Skip to content

Commit 664850a

Browse files
committed
Change name of the header file to detect libmysql version
As of MySQL 8.0.2-dmr, my_config.h is not available for server version detection in Connector/Python distutils. This patch uses mysql_version.h to parse the libmysql version.
1 parent 7c60a3e commit 664850a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/cpy_distutils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from distutils.command.install_lib import install_lib
3030
from distutils.errors import DistutilsExecError
3131
from distutils.util import get_platform
32+
from distutils.version import LooseVersion
3233
from distutils.dir_util import copy_tree
3334
from distutils import log
3435
from glob import glob
@@ -327,21 +328,19 @@ def _finalize_connector_c(self, connc_loc):
327328
log.debug("# connc_loc: {0}".format(connc_loc))
328329
else:
329330
# Probably using MS Windows
330-
myconfigh = os.path.join(connc_loc, 'include', 'my_config.h')
331+
myversionh = os.path.join(connc_loc, 'include',
332+
'mysql_version.h')
331333

332-
if not os.path.exists(myconfigh):
334+
if not os.path.exists(myversionh):
333335
log.error("MySQL C API installation invalid "
334-
"(my_config.h not found)")
336+
"(mysql_version.h not found)")
335337
sys.exit(1)
336338
else:
337-
with open(myconfigh, 'rb') as fp:
339+
with open(myversionh, 'rb') as fp:
338340
for line in fp.readlines():
339-
if b'#define VERSION' in line:
340-
version = tuple([
341-
int(v) for v in
342-
line.split()[2].replace(
343-
b'"', b'').split(b'.')
344-
])
341+
if '#define LIBMYSQL_VERSION' in line:
342+
version = LooseVersion(
343+
line.split()[2].replace('"', '')).version
345344
if version < min_version:
346345
log.error(err_version);
347346
sys.exit(1)

0 commit comments

Comments
 (0)