cloudfoundry / python-buildpack

Cloud Foundry buildpack for the Python Language
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
119 stars 277 forks source link

Build fails with mysqlclient #799

Closed zach-morris closed 2 months ago

zach-morris commented 1 year ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? cf cli version 7.5.0+0ad1d6398.2022-06-04 Running on: VMware TAS for VMs v2.13.16

What version of the buildpack you are using? v1.8.11 (python_buildpack_latest)

If you were attempting to accomplish a task, what was it you were attempting to do? Push app / build python application using the noted buildpack with a requirements.txt file containing (no version limitation):

mysqlclient

Manifest.yml:

applications:
- name:test
  instances: 1
  disk_quota: 1GB
  memory: 1GB
  stack: cflinuxfs3
  no-route: true
  health-check-type: process
  buildpacks:
    - python_buildpack_latest

requirements.txt:

mysqlclient

What did you expect to happen? The app succeeds to build using the latest python buildpack

What was the actual behavior? The app fails to build with error:

Error: subprocess-exited-with-error
            × Getting requirements to build wheel did not run successfully.
            │ exit code: 1
            ╰─> [25 lines of output]
                Trying pkg-config --exists mysqlclient
                Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
                Trying pkg-config --exists mariadb
                Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
                Traceback (most recent call last):
                  File "/tmp/contents1426358164/deps/0/python/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
                    main()
, in main
                    json_out['return_val'] = hook(**hook_input['kwargs'])
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  File "/tmp/contents1426358164/deps/0/python/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118                    return hook(config_settings)
                           ^^^^^^^^^^^^^^^^^^^^^
                  File "/tmp/pip-build-env-qp22x82t/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
                    return self._get_build_requires(config_settings, requirements=['wheel'])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  File "/tmp/pip-build-env-qp22x82t/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
                    self.run_setup()
                  File "/tmp/pip-build-env-qp22x82t/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
                    exec(code, locals())
                  File "<string>", line 154, in <module>
                  File "<string>", line 48, in get_config_posix
                  File "<string>", line 27, in find_package_name
                Exception: Can not find valid pkg-config name.
                Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
                [end of output]

I'll note that the build succeeds if i update the requirements.txt file to:

mysqlclient==2.1.1 

After further investigation, i see that the latest version of mysqlclient (2.2.0 released June 21,2023), has been updated and now uses pkg-config instead of mysql_config (ref https://github.com/PyMySQL/mysqlclient/pull/586), which is the root cause of the failure. I assume the python_buildpack would have to include pkg-config to allow this to succeed with the newest versions of mysqlclient, or define the environment variables for the buildpack as suggested here: https://github.com/PyMySQL/mysqlclient#customize-build-posix

Please confirm where necessary:

robdimsdale commented 1 year ago

pkg-config is available on the cflinuxfs4 stack:

→ docker run -it --rm cloudfoundry/cflinuxfs4 pkg-config --version
0.29.2

So it sounds like we're missing some config. Can you try adding some environment variables to staging to validate what the buildpack could add?

robdimsdale commented 2 months ago

I'm going to close this out as there's been no response in over a year.