Unable to upgrade Home Assistant to 2021.10.x

EDIT: I may have solved it as I found the following then installed normally (not pyenv)

The pkg-config command could not be found.
Most likely, you need to install a pkg-config package for your OS.
Try `apt install pkg-config`, or `yum install pkg-config`, or `pkg install pkg-config`, or `apk add pkgconfig` depending on your distribution.

Original post:
Tried to install the latest Home Assistant 2023.4.0 today, and got the same crypto/rust issue as above. The fix I shared above didn’t help at all this time, or this approach. Hoping someone can help me.

#### Details:
- Date           | Thu Apr  6 11:56:32 NZST 2023
- DietPi version | v8.15.2 (MichaIng/master)
- Image creator  | DietPi Core Team
- Pre-image      | from scratch
- Hardware       | RPi 3 Model B (armv7l) (ID=3)
- Kernel version | `Linux DietPi 6.1.21-v7+ #1642 SMP Mon Apr  3 17:20:52 BST 2023 armv7l GNU/Linux`
- Distro         | bullseye (ID=6,RASPBIAN=0)
- Command        | `sudo -u homeassistant dash -c 
. /home/homeassistant/pyenv-activate.sh
pyenv install 3.10.10
pyenv local 3.10.10
pip3 install -U pip setuptools wheel
[ -z '' ] || pip3 install 
exec pip3 install homeassistant`
- Exit code      | 1
- Software title | DietPi-Software

Building wheels for collected packages: cryptography
  Building wheel for cryptography (pyproject.toml): started
  Building wheel for cryptography (pyproject.toml): still running...
  Building wheel for cryptography (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building wheel for cryptography (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [337 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-cpython-310
      creating build/lib.linux-armv7l-cpython-310/cryptography
      copying src/cryptography/utils.py -> build/lib.linux-armv7l-cpython-310/cryptography
      copying src/cryptography/fernet.py -> build/lib.linux-armv7l-cpython-310/cryptography
      copying src/cryptography/exceptions.py -> build/lib.linux-armv7l-cpython-310/cryptography
     --snip--
      running egg_info
      writing src/cryptography.egg-info/PKG-INFO
      writing dependency_links to src/cryptography.egg-info/dependency_links.txt
      writing requirements to src/cryptography.egg-info/requires.txt
      writing top-level names to src/cryptography.egg-info/top_level.txt
      reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'docs/_build'
      warning: no previously-included files found matching 'vectors'
      warning: no previously-included files matching '*' found under directory 'vectors'
      warning: no previously-included files matching '*' found under directory '.github'
      warning: no previously-included files found matching 'release.py'
      warning: no previously-included files found matching '.readthedocs.yml'
      warning: no previously-included files found matching 'ci-constraints-requirements.txt'
      warning: no previously-included files found matching 'mypy.ini'
      adding license file 'LICENSE'
      adding license file 'LICENSE.APACHE'
      adding license file 'LICENSE.BSD'
      adding license file 'LICENSE.PSF'
      writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
      /tmp/pip-build-env-2h7gdj63/overlay/lib/python3.10/site-packages/setuptools/command/build_py.py:202: SetuptoolsDeprecationWarning:     Installing 'cryptography.hazmat.bindings._rust' as data is deprecated, please list it in `packages`.
          !!
      
      
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'cryptography.hazmat.bindings._rust' as an importable package,
          but it is not listed in the `packages` configuration of setuptools.
      
          'cryptography.hazmat.bindings._rust' has been automatically added to the distribution only
          because it may contain data files, but this behavior is likely to change
          in future versions of setuptools (and therefore is considered deprecated).
      
          Please make sure that 'cryptography.hazmat.bindings._rust' is included as a package by using
          the `packages` configuration field or the proper discovery methods
          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).
      
          You can read more about "package discovery" and "data files" on setuptools
          documentation page.
      
      
      !!
      
        check.warn(importable)
      /tmp/pip-build-env-2h7gdj63/overlay/lib/python3.10/site-packages/setuptools/command/build_py.py:202: SetuptoolsDeprecationWarning:     Installing 'cryptography.hazmat.bindings._rust.openssl' as data is deprecated, please list it in `packages`.
          !!
      
      
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'cryptography.hazmat.bindings._rust.openssl' as an importable package,
          but it is not listed in the `packages` configuration of setuptools.
      
          'cryptography.hazmat.bindings._rust.openssl' has been automatically added to the distribution only
          because it may contain data files, but this behavior is likely to change
          in future versions of setuptools (and therefore is considered deprecated).
      
          Please make sure that 'cryptography.hazmat.bindings._rust.openssl' is included as a package by using
          the `packages` configuration field or the proper discovery methods
          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).
      
          You can read more about "package discovery" and "data files" on setuptools
          documentation page.
      
      
      !!
      
-- snip --
        
           Running `/tmp/pip-install-9s4hmwol/cryptography_806eb94fd0874d70bb27682eecb16099/src/rust/target/release/build/num-traits-7be47f3277aa0d8c/build-script-build`
      error: failed to run custom build command for `openssl-sys v0.9.83`
      
      Caused by:
        process didn't exit successfully: `/tmp/pip-install-9s4hmwol/cryptography_806eb94fd0874d70bb27682eecb16099/src/rust/target/release/build/openssl-sys-e53b5fac3dc6b785/build-script-main` (exit status: 101)
        --- stdout
        cargo:rustc-cfg=const_fn
        cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR
        ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR unset
        cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
        OPENSSL_LIB_DIR unset
        cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR
        ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR unset
        cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
        OPENSSL_INCLUDE_DIR unset
        cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR
        ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR unset
        cargo:rerun-if-env-changed=OPENSSL_DIR
        OPENSSL_DIR unset
        cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
        cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
        cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
        cargo:rerun-if-env-changed=HOST_PKG_CONFIG
        cargo:rerun-if-env-changed=PKG_CONFIG
        cargo:rerun-if-env-changed=OPENSSL_STATIC
        cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
        cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
        cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
        cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf
        cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
        cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
        cargo:rerun-if-env-changed=PKG_CONFIG_PATH
        cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
        cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
        cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
        cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
        cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
        cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
        cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
        cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
        run pkg_config fail: Could not run `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "openssl"`
        The pkg-config command could not be found.
      
        Most likely, you need to install a pkg-config package for your OS.
        Try `apt install pkg-config`, or `yum install pkg-config`,
        or `pkg install pkg-config`, or `apk add pkgconfig` depending on your distribution.
      
        If you've already installed it, ensure the pkg-config command is one of the
        directories in the PATH environment variable.
      
        If you did not expect this build to link to a pre-installed system library,
        then check documentation of the openssl-sys crate for an option to
        build the library from source, or disable features or dependencies
        that require pkg-config.
      
        --- stderr
        thread 'main' panicked at '
      
        Could not find directory of OpenSSL installation, and this `-sys` crate cannot
        proceed without this knowledge. If OpenSSL is installed and this crate had
        trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
        compilation process.
      
        Make sure you also have the development packages of openssl installed.
        For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
      
        If you're in a situation where you think the directory *should* be found
        automatically, please open a bug at https://github.com/sfackler/rust-openssl
        and include information about your system as well as this message.
      
        $HOST = armv7-unknown-linux-gnueabihf
        $TARGET = armv7-unknown-linux-gnueabihf
        openssl-sys = 0.9.83
      
      
        It looks like you're compiling on Linux and also targeting Linux. Currently this
        requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
        could not be found. If you have OpenSSL installed you can likely fix this by
        installing `pkg-config`.
      
        ', /home/homeassistant/.cargo/registry/src/github.com-1285ae84e5963aae/openssl-sys-0.9.83/build/find_normal.rs:190:5
        note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      warning: build failed, waiting for other jobs to finish...
      
          =============================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/ for specific
             instructions for your platform.
          3) Check our frequently asked questions for more information:
             https://cryptography.io/en/latest/faq/
          4) Ensure you have a recent Rust toolchain installed:
             https://cryptography.io/en/latest/installation/#rust
      
          Python: 3.10.10
          platform: Linux-6.1.21-v7+-armv7l-with-glibc2.31
          pip: n/a
          setuptools: 67.6.1
          setuptools_rust: 1.5.2
          rustc: 1.68.2 (9eb3afe9e 2023-03-27)
          =============================DEBUG ASSISTANCE=============================
      
      error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path src/rust/Cargo.toml --release -v --features 'pyo3/extension-module pyo3/abi3-py36' -- --crate-type cdylib` failed with code 101
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects