Installing universal2 python with pyenv

Hi everybody

I’ve developed an app for macOS with Tkinter and wanted to be able to distribute a universal2 version of it. I’m on an M1 mac, so I just build the app first for arm64 with pyinstaller just to be able to use it myself.
But as soon as I wanted to build a universal version, pyinstaller threw an error:

AssertionError: /Users/tifrueh/.pyenv/versions/3.9.7/lib/python3.9/lib-dynload/_struct.cpython-39-darwin.so is not a fat binary!

So I figured I somehow had to install a universal version of python and tried to do that with pyenv, because I already use it to organise my python installations as you can see above.
This was my attempt:

env PYTHON_CONFIGURE_OPTS="--enable-shared --enable-universalsdk=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --with-universal-archs=universal2" pyenv install 3.9.7

But this doesn’t seem to work. The following is the output I get:

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.7.tar.xz...
-> https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz
Installing Python-3.9.7...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/hx/7cs5w9t10tq5tp2qr2ypc8cm0000gn/T/python-build.20211016234823.74852
Results logged to /var/folders/hx/7cs5w9t10tq5tp2qr2ypc8cm0000gn/T/python-build.20211016234823.74852.log

Last 10 log lines:
checking if we can turn off clang missing field initializers warning... yes
checking if we can turn on clang mixed sign comparison warning... yes
checking if we can turn on clang unreachable code warning... yes
checking if we can turn on clang strict-prototypes warning... yes
checking if we can make implicit function declaration an error in clang... yes
checking if we can use visibility in clang... yes
checking which MACOSX_DEPLOYMENT_TARGET to use... 11.6
checking if specified universal architectures work... no
configure: error: check config.log and use the '--with-universal-archs' option
make: *** No targets specified and no makefile found.  Stop.

Have I missed something? What did I do wrong?

It seems pyenv always overrides --with-universal-archs to intel, which is why that didn’t work. But they fixed it by now.