Skip to content

import error 'setuptools.build_meta' cryptography #3330

Closed

Description

@CluckyMedia

Getting ERROR Backend 'setuptools.build_meta' for cryptography package 42.0.1

STDERR:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1246, in <module>
    main()
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 677, in __init__
    getattr(self, command)(args)
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 104, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 163, in     build_dist_from_args
    build_recipes(build_order, python_modules, ctx,
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 504, in build_recipes
    recipe.build_arch(arch)
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 1452, in build_arch
    super().build_arch(arch)
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 1289, in build_arch
    shprint(
  File "/home/runner/work/app/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
    for line in output:
  File "/home/runner/.local/lib/python3.11/site-packages/sh.py", line 879, in __next__
    self.wait()
  File "/home/runner/.local/lib/python3.11/site-packages/sh.py", line 796, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/runner/.local/lib/python3.11/site-packages/sh.py", line 823, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /home/runner/work/app/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-     v8a__ndk_target_24/python3/android-build/python3 -m build --wheel --config-setting     builddir=/home/runner/work/app/.buildozer/android/platform/build-arm64-v8a/build/other_builds/cryptography/arm64-v8a__ndk_target_24/cryptography/p4a_android_build

  STDOUT:
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - cffi>=1.12; platform_python_implementation != 'PyPy'
  - setuptools-rust>=1.7.0
  - setuptools>=61.0.0
  - wheel
* Getting build dependencies for wheel...
Ignoring "sys._home = value" override

Traceback (most recent call last):
  File "/home/runner/work/app/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-    build/Lib/site-packages/pyproject_hooks/_impl.py", line 402, in _call_hook
    raise BackendUnavailable(
pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'

ERROR Backend 'setuptools.build_meta' is not available.

Cause: p4a's hostpython has a patched sys._home that breaks virtual environment creation. When python -m build creates an isolated venv to build cryptography, the hostpython's embedded sys._home override prevents setuptools.build_meta from being importable in that venv (hence the "Ignoring sys._home = value" override message).

Pinning cryptography to an older version alone won't fix this — the p4a recipe uses python -m build --wheel for ALL versions, which always creates the broken isolated venv.

Activity

  1. changed the title [-]import error 'setuptools.build_meta'[/-] [+]import error 'setuptools.build_meta' cryptography[/+] on May 15, 2026
  2. T-Dynamos commented on May 16, 2026

    @T-Dynamos
    Member

    @CluckyMedia Are you on latest p4a?

    This error was recently fixed, is caused by build package not accepting custom PYTHONPATH.

  3. CluckyMedia commented on May 16, 2026

    @CluckyMedia
    Author

    I have pinned to commit 5aa9732 in my buildozer since late last year, had been working fine until a recent build attempt.

  4. T-Dynamos commented on May 16, 2026

    @T-Dynamos
    Member

    Yes this is expected, you can modify and specify build==1.4.2 in recipe.py for a fix if you want to use same commit.

  5. CluckyMedia commented on May 16, 2026

    @CluckyMedia
    Author

    "Yes this is expected, you can modify and specify build==1.4.2 in recipe.py for a fix if you want to use same commit." - sorry how do I do that??

  6. T-Dynamos commented on May 16, 2026

    @T-Dynamos
    Member

    @CluckyMedia Are you unwilling to use the latest commit?

    Issue you are facing is caused by the recipe.py always using build's latest version, so after 1.4.2 this broke and was fixed recently in p4a.

  7. CluckyMedia commented on May 16, 2026

    @CluckyMedia
    Author

    I will pin to HEAD and see if all good. Thanks

  8. CluckyMedia commented on May 16, 2026

    @CluckyMedia
    Author

    At what point did python version change to 3.14?

  9. T-Dynamos commented on May 16, 2026

    @T-Dynamos
    Member

    A while back? You can use 3.11 by pinning it.

  10. CluckyMedia commented on May 18, 2026

    @CluckyMedia
    Author

    I pinned to 3.11.9 but still having issues with cryptography and the latest develop of p4a.

    05-18 18:14:04.979 13057 13135 I python  :  ImportError: dlopen failed: cannot locate symbol "_Py_NoneStruct" referenced by "/data/data/com.app/files/app/_python_bundle/site-packages/cryptography/hazmat/bindings/_rust.abi3.so"...
    

    _rust.abi3.so extension module for the cryptography package is trying to reference the internal CPython symbol _Py_NoneStruct. While standard ABI3 (stable ABI) wheels should not depend on internal C-API symbols like _Py_NoneStruct, this error indicates that the .so file was either compiled incorrectly without the proper ABI3 restrictions, or it was built against a different Python version/ABI than the 3.11 runtime being used by the app.

  11. T-Dynamos commented on May 18, 2026

    @T-Dynamos
    Member

    Duplicate #3329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions