Bug #87578 IndexError: list index out of range --with-mysql-capi=mysql_config
Submitted: 29 Aug 2017 10:37 Modified: 9 May 2022 22:17
Reporter: Shahriyar Rzayev Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:8.0.4 OS:CentOS (7)
Assigned to: CPU Architecture:Any

[29 Aug 2017 10:37] Shahriyar Rzayev
Description:
$ python setup.py install --with-protobuf-include-dir=/usr/include/google/protobuf --with-protobuf-lib-dir=/usr/lib/x86_64-linux-gnu --with-protoc=/usr/bin/protoc --with-mysql-capi=/home/shahriyar.rzaev/MYROCKS/PS250817-percona-server-5.7.19-17-linux-x86_64-debug/bin/mysql_config
running install
Installing MySQL C Extension
running build
running build_py
running build_ext
# Python architecture: 64-bit
# Python ARCH_64BIT: True
# Looking mysqlclient_lib at path: /home/shahriyar.rzaev/MYROCKS/PS250817-percona-server-5.7.19-17-linux-x86_64-debug/lib/mysql/libperconaserverclient*
Traceback (most recent call last):
  File "setup.py", line 64, in <module>
    ext_modules=setupinfo.extensions,
  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/shahriyar.rzaev/mysql-connector-python/lib/cpy_distutils.py", line 822, in run
    install.run(self)
  File "/usr/lib64/python2.7/distutils/command/install.py", line 563, in run
    self.run_command('build')
  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.7/distutils/dist.py", line 971, in run_command
    cmd_obj.ensure_finalized()
  File "/usr/lib64/python2.7/distutils/cmd.py", line 109, in ensure_finalized
    self.finalize_options()
  File "/home/shahriyar.rzaev/mysql-connector-python/lib/cpy_distutils.py", line 435, in finalize_options
    self._finalize_connector_c(self.with_mysql_capi)
  File "/home/shahriyar.rzaev/mysql-connector-python/lib/cpy_distutils.py", line 383, in _finalize_connector_c
    myc_info = get_mysql_config_info(mysql_config)
  File "/home/shahriyar.rzaev/mysql-connector-python/lib/cpy_distutils.py", line 232, in get_mysql_config_info
    log.debug("# mysqlclient_lib: {0}".format(mysqlclient_libs[-1]))
IndexError: list index out of range

How to repeat:
Looking at failed code line:

File "/home/shahriyar.rzaev/mysql-connector-python/lib/cpy_distutils.py", line 232, in get_mysql_config_info

mysqlclient_libs = []
        for filepath in libs:
            _, filename = os.path.split(filepath)
            log.debug("#  filename {0}".format(filename))
            if filename.startswith('libmysqlclient') and \
               not os.path.islink(filepath) and \
               '_r' not in filename and \
               '.a' not in filename:
                mysqlclient_libs.append(filepath)
        mysqlclient_libs.sort()

        stdout = None
        try:
            log.debug("# mysqlclient_lib: {0}".format(mysqlclient_libs[-1]))

It seems to be the mysqlclient_libs list is empty due to filename.startswith('libmysqlclient') check.
So maybe it will be great, not to limit clients to mysql or to check if len(mysqlclient_libs) > 0 prior accessing index.
[29 Aug 2017 11:52] MySQL Verification Team
Hello  Shahriyar,

Thank you for the report and feedback.
Issue observed only when non-oracle builds involved.

Thanks,
Umesh
[7 Nov 2017 13:35] Yoichi Nakayama
> Issue observed only when non-oracle builds involved.

No.  I've confirmed the problem exists in oracle build mysql-connector-c-6.1.11-macos10.12-x86_64.tar.gz too.

bin/mysql_config outputs wrong library option since:

# Create options
libs="-L$pkglibdir"
libs="$libs -l "
embedded_libs="-L$pkglibdir"
embedded_libs="$embedded_libs -l "
[7 Nov 2017 15:46] Yoichi Nakayama
It's not a bug of mysql-connector-python. It is a bug of mysql-connector-c.

Regards,
[23 Mar 2020 22:38] Nuno Mariz
Posted by developer:
 
Fixed by BUG#29181907
[9 May 2022 22:17] Philip Olson
Note: this bug was fixed with MySQL Bug #93846 back in 8.0.21.

Setting this status to closed; we're sorry for the delayed response, thank you for the bug report.