Unable to compile an OpenWrt 21.02.1 image with Docker due to python-cryptography

Dear all,
I am writing as I am currently trying to compile an image of OpenWrt 21.02.1, for an ARM target and with musl as default C standard library.
I was able to successfully select all the needed packages with make menuconfig, and to start the build procedure with make.
As I need to use Docker on the target platform, I also included Docker, which, through a chain of dependencies, seems to select also the python-cryptography package.

This package, however, is always failing to compile, apparently due to an error caused by setuptools.
The error is the following (I report here the output of make V=s):

Requirement already satisfied: cffi==1.14.6 in /mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages (from -r ../host-pip-requirements/cffi.txt (line 1)) (1.14.6)
Requirement already satisfied: pycparser==2.20 in /mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages (from -r ../host-pip-requirements/cffi.txt (line 2)) (2.20)
install -d -m0755 /mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/ipkg-install//usr/lib/python3.9/site-packages
cd "/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/" && CC="arm-openwrt-linux-muslgnueabi-gcc" CCSHARED="arm-openwrt-linux-muslgnueabi-gcc -DPIC -fpic" CXX="arm-openwrt-linux-muslgnueabi-g++" LD="arm-openwrt-linux-muslgnueabi-gcc" LDSHARED="arm-openwrt-linux-muslgnueabi-gcc -shared" CFLAGS=" -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -fmacro-prefix-map=/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8=cryptography-3.4.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" CPPFLAGS="-I/mnt/xtra/openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi/usr/include -I/mnt/xtra/openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi/include/fortify -I/mnt/xtra/openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi/include -I/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/usr/include/python3.9" LDFLAGS="-L/mnt/xtra/openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi/usr/lib -L/mnt/xtra/openwrt/staging_dir/toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi/lib -znow -zrelro -lpython3.9" _PYTHON_HOST_PLATFORM="linux-arm" __PYVENV_LAUNCHER__="/usr/bin/python3.9" PYTHONPATH="/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/usr/lib/python3.9:/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi//usr/lib/python3.9/site-packages:/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/ipkg-install//usr/lib/python3.9/site-packages" PYTHONDONTWRITEBYTECODE=1 PYTHONOPTIMIZE="" _python_sysroot="/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi" _python_prefix="/usr" _python_exec_prefix="/usr"     /mnt/xtra/openwrt/staging_dir/hostpkg/bin/python3.9  setup.py   install --prefix="/usr" --root="/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/ipkg-install" --single-version-externally-managed
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.

    =============================DEBUG ASSISTANCE=============================
    If you are seeing a compilation error please try the following steps to
    successfully install cryptography:
    1) Upgrade to the latest pip and try again. This will fix errors for most
       users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
    2) Read https://cryptography.io/en/latest/installation.html for specific
       instructions for your platform.
    3) Check our frequently asked questions for more information:
       https://cryptography.io/en/latest/faq.html
    4) Ensure you have a recent Rust toolchain installed:
       https://cryptography.io/en/latest/installation.html#rust
    5) If you are experiencing issues with Rust for *this release only* you may
       set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
    =============================DEBUG ASSISTANCE=============================
    
Traceback (most recent call last):
  File "/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/setup.py", line 71, in <module>
    setup(
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/usr/lib/python3.9/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/setuptools/dist.py", line 455, in __init__
    _Distribution.__init__(self, {
  File "/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/usr/lib/python3.9/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/setuptools/dist.py", line 807, in finalize_options
    ep(self)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/setuptools/dist.py", line 814, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 219, in cffi_modules
    add_cffi_module(dist, cffi_module)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
    execfile(build_file_name, mod_vars)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile
    exec(code, glob, glob)
  File "src/_cffi_src/build_openssl.py", line 119, in <module>
    extra_link_args=extra_link_args(compiler_type()),
  File "/mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/src/_cffi_src/utils.py", line 106, in compiler_type
    cmd = dist.get_command_obj("build")
  File "/mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/usr/lib/python3.9/distutils/dist.py", line 857, in get_command_obj
    klass = self.get_command_class(command)
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/setuptools/dist.py", line 854, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/mnt/xtra/openwrt/staging_dir/hostpkg/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'setuptools.command.build'
make[3]: *** [Makefile:57: /mnt/xtra/openwrt/build_dir/target-arm_cortex-a9+neon_musl_eabi/pypi/cryptography-3.4.8/.built] Error 1
make[3]: Leaving directory '/mnt/xtra/openwrt/feeds/packages/lang/python/python-cryptography'
time: package/feeds/packages/python-cryptography/compile#0.89#0.05#0.94
    ERROR: package/feeds/packages/python-cryptography failed to build.
make[2]: *** [package/Makefile:114: package/feeds/packages/python-cryptography/compile] Error 1
make[2]: Leaving directory '/mnt/xtra/openwrt'
make[1]: *** [package/Makefile:108: /mnt/xtra/openwrt/staging_dir/target-arm_cortex-a9+neon_musl_eabi/stamp/.package_compile] Error 2
make[1]: Leaving directory '/mnt/xtra/openwrt'
make: *** [/mnt/xtra/openwrt/include/toplevel.mk:230: world] Error 2

After some unsuccesful debugging, as a last resort, I tried upgrading pip on the device in which I am running the build system (with Ubuntu 20 LTS and gcc/g++ 9.4.0), but, unfortunately, this did not solve the issue.

Do you know if this could possibly be a bug which should be reported? Or could this be due to some misconfiguration when selecting all the packages with make menuconfig?

Thank you very much in advance!

I am facing with the same issue! Did you solved this?
I also build docker for openwrt-22.03 and master and I do not see this issue.
So I think this must have to do with the branch openwrt-21.02

There is already a issue on github about this https://github.com/openwrt/packages/issues/18876