Installing wxPython on gitlab runner

I’m working on a project that uses wxPython to create a simple GUI with the help of Gooey.

I’d like to run the tests using a pipeline in gitlab. But I’m having troubles to install wxPython there.

When I install my package with pip, wxPython is pulled as a dependency and the installation fails with:

  Building wheel for wxpython ( started
  Building wheel for wxpython ( finished with status 'error'
  error: subprocess-exited-with-error
  × python bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [140 lines of output]
      /usr/local/lib/python3.9/site-packages/setuptools/ UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
      /usr/local/lib/python3.9/site-packages/setuptools/ DistDeprecationWarning: use_2to3 is ignored.
        warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
      running bdist_wheel
      running build
      WARNING: Building this way assumes that all generated files have been
      generated already.  If that is not the case then use directly
      to generate the source and perform the build stage.  You can use
      --skip-build with the bdist_* or install commands to avoid this
      message and the wxWidgets and Phoenix build steps in the future.
      "/usr/local/bin/python" -u build
      Will build using: "/usr/local/bin/python"
      3.9.12 (main, May 11 2022, 07:56:18)
      [GCC 10.2.1 20210110]
      Python's architecture is 64bit
      cfg.VERSION: 4.1.1
      Running command: build
      Running command: build_wx
      wxWidgets build options: ['--wxpython', '--unicode', '--gtk3']
      Configure options: ['--enable-unicode', '--with-gtk=3', '--enable-sound', '--enable-graphics_ctx', '--enable-display', '--enable-geometry', '--enable-debug_flag', '--enable-optimise', '--disable-debugreport', '--enable-uiactionsim', '--enable-autoidman', '--with-sdl']
      /tmp/pip-install-4zmrlcg5/wxpython_11e4c0ff53434f4e95185142c9fee041/ext/wxWidgets/configure --enable-unicode --with-gtk=3 --enable-sound --enable-graphics_ctx --enable-display --enable-geometry --enable-debug_flag --enable-optimise --disable-debugreport --enable-uiactionsim --enable-autoidman --with-sdl
      checking build system type... x86_64-pc-linux-gnu
      checking host system type... x86_64-pc-linux-gnu
      checking for toolkit... gtk
      checking for gcc... gcc
      checking whether the C compiler works... yes
      checking for C compiler default output file name... a.out
      checking for suffix of executables...
      checking whether we are cross compiling... no
      checking for suffix of object files... o
      checking whether we are using the GNU C compiler... yes
      checking whether gcc accepts -g... yes
      checking for gcc option to accept ISO C89... none needed
      checking whether we are using the Intel C compiler... no
      checking how to run the C preprocessor... gcc -E
      checking for grep that handles long lines and -e... /bin/grep
      checking for egrep... /bin/grep -E
      checking whether gcc needs -traditional... no
      checking for g++... g++
      checking whether we are using the GNU C++ compiler... yes
      checking whether g++ accepts -g... yes
      checking whether we are using the Intel C++ compiler... no
      checking whether we are using the Sun C++ compiler... no
      checking for ar... ar
      checking for ANSI C header files... yes
      checking for sys/types.h... yes
      checking for sys/stat.h... yes
      checking for stdlib.h... yes
      checking for string.h... yes
      checking for memory.h... yes
      checking for strings.h... yes
      checking for inttypes.h... yes
      checking for stdint.h... yes
      checking for unistd.h... yes
      checking for langinfo.h... yes
      checking for wchar.h... yes
      checking for sys/select.h... yes
      checking for cxxabi.h... yes
      checking for an ANSI C-conforming const... yes
      checking for inline... inline
      checking size of short... 2
      checking size of void *... 8
      checking size of int... 4
      checking size of long... 8
      checking size of size_t... 8
      checking size of long long... 8
      checking size of wchar_t... 4
      checking for va_copy... yes
      checking for _FILE_OFFSET_BITS value needed for large files... 64
      checking if large file support is available... yes
      checking for _LARGEFILE_SOURCE value needed for large files... no
      checking whether byte ordering is bigendian... no
      checking for std::wstring in <string>... yes
      checking for std::istream... yes
      checking for std::ostream... yes
      checking for type_traits... yes
      checking for __sync_fetch_and_add and __sync_sub_and_fetch builtins... yes
      checking for libraries directories... /usr/lib/x86_64-linux-gnu /usr/lib
      checking for cos... no
      checking for floor... no
      checking if floating point functions link without -lm... no
      checking for sin... yes
      checking for ceil... yes
      checking if floating point functions link with -lm... yes
      checking for strtoull... yes
      checking for pkg-config... /usr/bin/pkg-config
      checking pkg-config is at least version 0.9.0... yes
      configure: WARNING: Defaulting to the builtin regex library for Unicode build.
      checking for zlib.h >= 1.1.4... yes
      checking for zlib.h... (cached) yes
      checking for deflate in -lz... yes
      checking for png.h > 0.90... yes
      checking for png.h... (cached) yes
      checking for png_sig_cmp in -lpng... yes
      checking for jpeglib.h... yes
      checking for jpeg_read_header in -ljpeg... yes
      checking lzma.h usability... yes
      checking lzma.h presence... yes
      checking for lzma.h... yes
      checking for lzma_code in -llzma... yes
      checking for jbg_dec_init in -ljbig... yes
      checking for LIBTIFF... yes
      checking for expat.h... yes
      checking if expat.h is valid C++ header... yes
      checking for XML_ParserCreate in -lexpat... yes
      checking for GTK+ version...
      checking for pkg-config... (cached) /usr/bin/pkg-config
      checking pkg-config is at least version 0.16... yes
      checking for GTK+ - version >= 3.0.0... Package gtk+-3.0 was not found in the pkg-config search path.
      Perhaps you should add the directory containing `gtk+-3.0.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'gtk+-3.0' found
      *** Could not run GTK+ test program, checking why...
      *** The test program failed to compile or link. See the file config.log for the
      *** exact error that occurred. This usually means GTK+ is incorrectly installed.
      configure: error:
      The development files for GTK+ were not found. For GTK+ 2, please
      ensure that pkg-config is in the path and that gtk+-2.0.pc is
      installed. For GTK+ 1.2 please check that gtk-config is in the path,
      and that the version is 1.2.3 or above. Also check that the
      libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
      --libs' are in the LD_LIBRARY_PATH or equivalent.
      Error running configure
      ERROR: failed building wxWidgets
      Traceback (most recent call last):
        File "/tmp/pip-install-4zmrlcg5/wxpython_11e4c0ff53434f4e95185142c9fee041/", line 1510, in cmd_build_wx
          wxbuild.main(wxDir(), build_options)
        File "/tmp/pip-install-4zmrlcg5/wxpython_11e4c0ff53434f4e95185142c9fee041/buildtools/", line 372, in main
          exitIfError(wxBuilder.configure(dir=wxRootDir, options=configure_opts),
        File "/tmp/pip-install-4zmrlcg5/wxpython_11e4c0ff53434f4e95185142c9fee041/buildtools/", line 85, in exitIfError
          raise builder.BuildError(msg)
      buildtools.builder.BuildError: Error running configure
      Finished command: build_wx (0m5.401s)
      Finished command: build (0m5.402s)
      Command '"/usr/local/bin/python" -u build' failed with exit code 1.
      [end of output]

But as far as I can tell, gtk±3.0 is there:

$ pkg-config gtk+-3.0 --cflags
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include

I also got this:

$ cat $(locate gtk+-3.0.pc)
targets=x11 broadway wayland
Name: GTK+
Description: GTK+ Graphical UI Library
Version: 3.24.5
Requires: gdk-3.0 atk >= 2.15.1 cairo >= 1.14.0 cairo-gobject >= 1.14.0 gdk-pixbuf-2.0 >= 2.30.0 gio-2.0 >= 2.53.4
Requires.private: atk atk-bridge-2.0 wayland-client >= 1.9.91 wayland-protocols >= 1.12 xkbcommon >= 0.2.0 wayland-cursor >= 1.9.91 wayland-egl  epoxy >= 1.4 pangoft2 gio-unix-2.0 >= 2.53.4
Libs: -L${libdir} -lgtk-3 
Cflags: -I${includedir}/gtk-3.0 

which I’m not sure if it’s correct…

BTW, the target OS is debian 10:

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION="10 (buster)"

Any idea?


Not sure - perhaps check config.log to see what is being reported there.

Note: if you are installing wxPython via pip as part of a CI pipeline, you
will probably want to build your own wheel and cache it somewhere, because
otherwise your pipeline is going to take a long time as wxPython will be
recompiled every time your pipeline runs.

Note 2: if wxPython 4.0 works for you, you could install the Debian
package for wxPython (python3-wxgtk4.0), which would be much faster. It’s
wxPython 4.0.4 in Debian Buster, though.

Thank you for the answer!

Unfortunately it does not help: same error. Although wxPython is installed as a debian package, pip does not seem to see it, and it tries to make a wheel from the sources.

Are you using the Python 3.7 that Debian 10 comes with? If so, you can
probably install this wheel which will get you wxPython 4.1.1:

No, I’m using Python 3.9

In that case, I recommend building your own wheel offline and then loading
it from somewhere during your CI runs.

Yes, I ended up doing that. Of course it worked and makes sense: although I managed to start building wxPython, the time limit in gitlab interrupted the process.
My own wheel is not my favourite solution, but it is a solution.
Thank you for the support!