Unable to build cffi, missing wheel utility

I’m using flatpak-pip-generator to create a portable python virtual environment. Many of the pip3 requirements are met but I am stuck at bcrypt requiring cffi and not finding the bdist_wheel program.

How should I proceed?

========================================================================
Building module python3-bcrypt in /home/jreynolds/btbits/x64_btbits/tools/flatpak/ct_flatpak_py3-08/.flatpak-builder/build/python3-bcrypt-1
========================================================================
Running: pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "bcrypt==3.1.3" --no-build-isolation
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/python3-bcrypt --nofilesystem=host:reset --filesystem=/home/jreynolds/btbits/x64_btbits/tools/flatpak/ct_flatpak_py3-08/.fla
tpak-builder/build/python3-bcrypt-1 --bind-mount=/run/build/python3-bcrypt=/home/jreynolds/btbits/x64_btbits/tools/flatpak/ct_flatpak_py3-08/.flatpak-builder/build/python3-bcrypt-1 --build-dir=/run/build/python3
-bcrypt --bind-mount=/run/ccache=/home/jreynolds/btbits/x64_btbits/tools/flatpak/ct_flatpak_py3-08/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1716936933 '--env=CFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -W
p,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer ' '--env=CXXFLAGS=-O2 -g -pipe -W
p,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer ' '--env=
LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgc
onfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=16 /home/jreynolds/btbits/x64_btbits/tools/flatpak/ct_flatpak_py3-08/.flatpak-builder/rofiles/rofiles-YGznuM /bin/sh -c 'pip3 install --
verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "bcrypt==3.1.3" --no-build-isolation'
Using pip 23.0.1 from /app/lib/python3.8/site-packages/pip (python 3.8)
Looking in links: file:///run/build/python3-bcrypt
Processing ./bcrypt-3.1.3.tar.gz
  Running command python setup.py egg_info
  running egg_info
  creating /tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info
  writing /tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/PKG-INFO
  writing dependency_links to /tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/dependency_links.txt
  writing requirements to /tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/requires.txt
  writing top-level names to /tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/top_level.txt
  writing manifest file '/tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/SOURCES.txt'
  adding license file 'LICENSE' (matched pattern 'LICEN[CS]E*')
  reading manifest file '/tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files found matching 'requirements.txt'
  warning: no previously-included files found matching 'tasks.py'
  warning: no previously-included files found matching '.travis.yml'
  warning: no previously-included files found matching 'wheel-scripts'
  warning: no previously-included files matching '*' found under directory 'wheel-scripts'
  no previously-included directories found matching '.travis'
  writing manifest file '/tmp/pip-pip-egg-info-3u5rru6b/bcrypt.egg-info/SOURCES.txt'
  Preparing metadata (setup.py) ... done
Processing ./cffi-1.16.0.tar.gz
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  creating /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info
  writing /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/PKG-INFO
  writing dependency_links to /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/dependency_links.txt
  writing entry points to /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/entry_points.txt
  writing requirements to /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/requires.txt
  writing top-level names to /tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/top_level.txt
  writing manifest file '/tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/SOURCES.txt'
  warning: the 'license_file' option is deprecated, use 'license_files' instead
  adding license file 'LICENSE' (matched pattern 'LICENSE')
  reading manifest file '/tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file '/tmp/pip-modern-metadata-bz5l4asz/cffi.egg-info/SOURCES.txt'
  creating '/tmp/pip-modern-metadata-bz5l4asz/cffi.dist-info'
  error: invalid command 'bdist_wheel'
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /app/bin/python3.8 /app/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp5cf5l786
  cwd: /tmp/pip-install-m0579kkg/cffi_30dd7ea396c24848be0f16e03b847b15
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Error: module python3-bcrypt: Child process exited with code 1
make: *** [Makefile:64: com.candelatech.py3-08.flatpak] Error 1

Requirements txt:

 $ cat requirements.0.txt ; echo "----"; cat requirements.1.txt 
wheel==0.43.0
requirements-parser==0.9.0
pipdeptree==2.16.0
pybind11==2.12.0
----
wheel==0.43.0
bcrypt==3.1.3

There are no errors running flatpak-pip-generator. The problem comes with the bundle step when it is building the cffi dependency of bcrypt. The resulting requirements.json file does not list wheel because it finds it as a system tool.

Requirements.0.json:


    "name": "requirements.0",
    "buildsystem": "simple",
    "build-commands": [], 
    "modules": [
        {   
            "name": "python3-cffi",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"cffi>=1.1\" --no-build-isolation"
            ],  
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/68/ce/95b0bae7968c65473e1298efb042e10cafc7bafc14d9e4f154008241c91d/cffi-1.16.0.tar.gz",
                    "sha256": "bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/13/a3/a812df4e2dd5696d1f351d58b8fe16a405b234ad2886a0dab9183fb78109/pycparser-2.22-py3-none-any.whl",
                    "sha256": "c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc"
                }
            ]
        },  
        {
            "name": "python3-requirements-parser",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"requirements-parser==0.9.0\" --no-build-isolation"
            ],  
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/2d/2e/d83d239cbf8a18f9400de46b9204c2fa8899f9347e771009aafb27858def/requirements_parser-0.9.0-py3-none-any.whl",
                    "sha256": "40298fd2bb423798fc52ca4550adf1944d75c998fd2316b5b6959842dbc70a32"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/18/2e/4843f4c64fc0d4b238ab3ebd548bb878e9c827ab2546da46d8e7ad530bfa/types_setuptools-70.0.0.20240524-py3-none-any.whl",
                    "sha256": "8f5379b9948682d72a9ab531fbe52932e84c4f38deda570255f9bae3edd766bc"
                }
            ]
        },
        {   
            "name": "python3-pipdeptree",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"pipdeptree==2.16.0\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/ed/4b/bf2a5530acfe55dd0350486c421549cf4a5411e331affbb2f00fdfd15bb7/pipdeptree-2.16.0-py3-none-any.whl",
                    "sha256": "77b5f8a942eaea83599b76459ad8ff908e60065a3055e09d49dcab3eb0077f3c"
                }
            ]
        },
        {
            "name": "python3-pybind11",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"pybind11==2.12.0\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/26/55/e776489172f576b782e616f58273e1f3de56a91004b0d20504169dd345af/pybind11-2.12.0-py3-none-any.whl",
                    "sha256": "df8d60b94f9e714d81013db233393d430ebf9f3551642b82291cf1b14d1afdbd"
                }
            ]
        }
    ]
}

I figured this out! I had to force a wheel into a requirements.json for it to build. This included forcing six, tomli-w, docutils, and requests to all build at the same time:

{
    "name": "requirements.wheel",
    "buildsystem": "simple",
    "build-commands": [],
    "modules": [
        {
            "name": "python3-docutils",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"docutils==0.17.0\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/9a/65/76aea825b59727b556cca74e28d68e4d73244d2e1e8a8945c29d6d3d5e11/docutils-0.17-py2.py3-none-any.whl",
                    "sha256": "a71042bb7207c03d5647f280427f14bfbd1a65c9eb84f4b341d85fafb6bb4bdf"
                }
            ]
        },
        {
            "name": "python3-requests",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"requests==2.32.3\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/ba/06/a07f096c664aeb9f01624f858c3add0a4e913d6c96257acb4fce61e7de14/certifi-2024.2.2-py3-none-any.whl",
                    "sha256": "dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz",
                    "sha256": "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/e5/3e/741d8c82801c347547f8a2a06aa57dbb1992be9e948df2ea0eda2c8b79e8/idna-3.7-py3-none-any.whl",
                    "sha256": "82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl",
                    "sha256": "70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl",
                    "sha256": "450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"
                }
            ]
        },
        {
            "name": "python3-tomli-w",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"tomli-w\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/bb/01/1da9c66ecb20f31ed5aa5316a957e0b1a5e786a0d9689616ece4ceaf1321/tomli_w-1.0.0-py3-none-any.whl",
                    "sha256": "9f2a07e8be30a0729e533ec968016807069991ae2fd921a78d42f429ae5f4463"
                }
            ]
        },
        {
            "name": "python3-flit",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"flit==3.7.1\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/ba/06/a07f096c664aeb9f01624f858c3add0a4e913d6c96257acb4fce61e7de14/certifi-2024.2.2-py3-none-any.whl",
                    "sha256": "dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz",
                    "sha256": "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/8f/d7/9322c609343d929e75e7e5e6255e614fcc67572cfd083959cdef3b7aad79/docutils-0.21.2-py3-none-any.whl",
                    "sha256": "dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/f8/81/5281e3f50a238d1169cc5c4c3acec91c631da79962d387ea843083bd151e/flit-3.7.1-py3-none-any.whl",
                    "sha256": "06a93a6737fa9380ba85fe8d7f28efb6c93c4f4ee9c7d00cc3375a81f33b91a4"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/38/45/618e84e49a6c51e5dd15565ec2fcd82ab273434f236b8f108f065ded517a/flit_core-3.9.0-py3-none-any.whl",
                    "sha256": "7aada352fb0c7f5538c4fafeddf314d3a6a92ee8e2b1de70482329e42de70301"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/e5/3e/741d8c82801c347547f8a2a06aa57dbb1992be9e948df2ea0eda2c8b79e8/idna-3.7-py3-none-any.whl",
                    "sha256": "82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl",
                    "sha256": "70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl",
                    "sha256": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/bb/01/1da9c66ecb20f31ed5aa5316a957e0b1a5e786a0d9689616ece4ceaf1321/tomli_w-1.0.0-py3-none-any.whl",
                    "sha256": "9f2a07e8be30a0729e533ec968016807069991ae2fd921a78d42f429ae5f4463"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/a2/73/a68704750a7679d0b6d3ad7aa8d4da8e14e151ae82e6fee774e6e0d05ec8/urllib3-2.2.1-py3-none-any.whl",
                    "sha256": "450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"
                }
            ]

        },
        {
            "name": "python3-wheel",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"wheel==0.43.0\" --no-build-isolation"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/b8/d6/ac9cd92ea2ad502ff7c1ab683806a9deb34711a1e2bd8a59814e8fc27e69/wheel-0.43.0.tar.gz",
                    "md5": "387af15d51367a19d834d6db413547d0"
                }
            ]
        },
        {
            "name": "python3-six",
            "buildsystem": "simple",
            "build-commands":[
                "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"six==1.16.0\" --no-build-isolation"
            ],
            "sources":[
                {
                  "type": "file",
                  "url": "https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl",
                  "sha256": "8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
                }
            ]
        }
    ]
}