Python API: Failed assertion 'm_choices.GetCount() > 0' on headless Linux
Description
When the pcbnew
module is imported on headless Linux systems, the following assertion failure is traced on stderr:
$ python3 -c 'import pcbnew; print(pcbnew.GetBuildVersion())'
./kicad/include/properties/property.h(474): assert "m_choices.GetCount() > 0" failed in PROPERTY_ENUM(): No enum choices defined
7.0.0-rc2-unknown-5beb79bbdc~164~ubuntu22.04.1
This is confusing for the users as it clutters the program output and also, prevents machine processing of errors on stderr.
Steps to reproduce
The simplest way I found to reproduce this error is to try run KiCAD in docker:
docker run -it ubuntu:22.04 /bin/bash
- Then install the nightly version:
add-apt-repository --yes ppa:kicad/kicad-dev-nightly
apt-get update
apt-get install --yes --no-install-recommends kicad-nightly
export PYTHONPATH=/usr/lib/kicad-nightly/lib/python3/dist-packages/
export LD_LIBRARY_PATH=/usr/lib/kicad-nightly/lib/x86_64-linux-gnu:/usr/lib/kicad-nightly/lib/:${LD_LIBRARY_PATH}
- Run
python3 -c 'import pcbnew; print(pcbnew.GetBuildVersion())'
and observe assertion failure.
KiCad Version
Application: KiCad PCB Editor x86_64 on x86_64
Version: 7.0.0-rc2-unknown-5beb79bbdc~164~ubuntu20.04.1, release build
Libraries:
wxWidgets 3.2.1
FreeType 2.10.1
HarfBuzz 2.6.4
FontConfig 2.13.1
libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Platform: Ubuntu 20.04.5 LTS, 64 bit, Little endian, wxGTK, regolith, x11
Build Info:
Date: Jan 29 2023 20:32:53
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.71.0
OCC: 7.5.2
Curl: 7.68.0
ngspice: 38
Compiler: GCC 9.4.0 with C++ ABI 1013
Build settings:
KICAD_USE_EGL=ON
KICAD_SPICE=ON