Skip to content

Fix error building with --static on debian stretch docker image due to mariadb client name #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2019

Conversation

bitswamp
Copy link
Contributor

@bitswamp bitswamp commented Jun 4, 2019

Scenario

I want to build a statically-linked, binary wheel for the debian stretch-based docker image python:3.6.8-slim (so I don't need to install libmysqlclient-dev on all my images)

Example Dockerfile:

FROM python:3.6.8-slim as build-mysqlclient

RUN apt update && apt install -y build-essential default-libmysqlclient-dev git

RUN git clone https://github.com/PyMySQL/mysqlclient-python

WORKDIR /mysqlclient-python

RUN python setup.py --static bdist_wheel

Problem

The above Dockerfile gives this error:

Step 5/5 : RUN python setup.py --static bdist_wheel
 ---> Running in 1e8aabf66608
Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    metadata, options = get_config()
  File "/mysqlclient-python/setup_posix.py", line 81, in get_config
    raise ValueError("Couldn't identify mysql client library")
ValueError: Couldn't identify mysql client library
The command '/bin/sh -c python setup.py --static bdist_wheel' returned a non-zero code: 1

The output from mysql_config --libs in the container is:

-L/usr/lib/x86_64-linux-gnu  -lmariadbclient -lpthread -lz -lm -ldl

Fix

In setup_posix.py the CLIENT_LIST includes mariadb but not mariadbclient. Adding mariadbclient to this list allows mysqlclient to build successfully (output shortened):

Step 5/5 : RUN python setup.py --static bdist_wheel
 ---> Running in 66163c4e2c6b
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
[...]
Copying mysqlclient.egg-info to build/bdist.linux-x86_64/wheel/mysqlclient-1.4.2.post1-py3.6.egg-info
running install_scripts
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.linux-x86_64/wheel/mysqlclient-1.4.2.post1.dist-info/WHEEL
creating 'dist/mysqlclient-1.4.2.post1-cp36-cp36m-linux_x86_64.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
[...]
removing build/bdist.linux-x86_64/wheel
Removing intermediate container 66163c4e2c6b
 ---> 7234f193aa69
Successfully built 7234f193aa69

Thanks for reading. Let me know if this change is OK, or if it could cause problems for other configurations.

@codecov
Copy link

codecov bot commented Jun 4, 2019

Codecov Report

Merging #357 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #357   +/-   ##
=======================================
  Coverage   87.14%   87.14%           
=======================================
  Files          13       13           
  Lines        1556     1556           
=======================================
  Hits         1356     1356           
  Misses        200      200

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b66971e...65da81b. Read the comment docs.

@methane methane merged commit 3d046ad into PyMySQL:master Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants