Resolving Build Dependencies of Python packages

As an example the following Python package has a native dependency which is mandatory (but could be optional) and is not installed:

      CMake Error at /tmp/pip-build-env-qfv9dod5/overlay/lib/python3.11/site-packages/cmake/data/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
        Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
        GTEST_MAIN_LIBRARY)
      Call Stack (most recent call first):
        /tmp/pip-build-env-qfv9dod5/overlay/lib/python3.11/site-packages/cmake/data/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
        /tmp/pip-build-env-qfv9dod5/overlay/lib/python3.11/site-packages/cmake/data/share/cmake-3.28/Modules/FindGTest.cmake:270 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
        src/segments/CMakeLists.txt:20 (find_package)
      
      
      -- Configuring incomplete, errors occurred!
      Traceback (most recent call last):
        File "/tmp/pip-build-env-qfv9dod5/overlay/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 666, in setup
          env = cmkr.configure(
                ^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-qfv9dod5/overlay/lib/python3.11/site-packages/skbuild/cmaker.py", line 357, in configure
          raise SKBuildError(msg)
      
      An error occurred while configuring with CMake.

Can be corrected by either:

  1. Building in correctly configured container
  2. Modification to the build procedure

Streamlit build error

Alpine linux are very minimal images and use musl and pre-built Python wheels for compiled packages are not generally available. Therefore installing a package with compiled components requires full compilation tool chains.

Typical error can be illustrated with following Docker container:

FROM python:3-alpine3.15
RUN pip install --upgrade pip
RUN pip install streamlit

Fails with:

error: command 'cmake' failed: No such file or directory 

The underlying reason is that the cmake program has not been installed, and streamlit requires compiled components which are built using cmake .

Copyright and published by: Software Build Factory (C) 2024 Contact info@softwarebuildfactory.com