marcelotduarte/cx_Freeze

PyGObject hook broke in 7.1.0

black-sliver opened this issue · 4 comments

Describe the bug
Freezing in a venv that has pygobject installed via pip will fail.

  • It looks for a .typelib (Atk, see below) that I think is not required, at least it worked without on 7.0.0
  • Installing gir1.2-atk-1.0 does not fix it, because additionally cx_freeze 7.1.0 looks in the wrong folder.

Running DISTUTILS_DEBUG=1 python setup.py build_exe gives

cx_Freeze.exception.OptionError: cannot find file/directory named /home/<user>/<project>/venv/lib/girepository-1.0/Atk-1.0.typelib

To Reproduce
On a fresh Ubuntu 20.04 (have not tested others, but likely independent of OS version) run

sudo apt install python3-venv
sudo apt install python3-dev python3-gi libgirepository1.0-dev libcairo2-dev  # this pulls all dependencies for pip install pygobject
sudo apt install gir1.2-atk-1.0  # this would provide the atk .typelib, but was not required with 7.0.0
python3 -m venv venv
source venv/bin/activate
pip install pygobject
echo 'import gi; print("Hello World!")' > main.py
pip install cx_freeze==7.1.0
cxfreeze --script main.py build_exe  # fails with error shown above
pip install cx_freeze==7.0.0
cxfreeze --script main.py build_exe  # succeeds

Expected behavior
Most likely correct would be to not include the atk typelib, but if this is by choice, then the lookup path should be fixed, so freezing does not fail.

Desktop (please complete the following information):

  • Platform information: Ubuntu Linux 20.04
  • OS architecture: amd64
  • cx_Freeze version: 7.1.0
  • Python version: 3.8 (local), 3.11 (actions/setup-python)

Please test the patch:

pip uninstall cx_Freeze
pip install git+https://github.com/marcelotduarte/cx_Freeze.git@refs/pull/2425/head

The application successfully builds and runs now.

As a side note
find build/exe.linux* -name "*.typelib"
does not find anything with either 6.15.2, 7.0.0 or 7.2.0.dev0 with the setup we have.

It however seems to pick up system-wide installed typelibs, which I believe is fine for our application, because pygobject is an optional/alternative dependency for some functionality, depending on which system it ends up running on.
But I wanted to put that here in case the expectation is that all typelibs are included now.

The expectation is that some typelibs will be installed, more precisely those on this list, if available:

common_namespaces = [
"Atk-1.0",
"GLib-2.0",
"GModule-2.0",
"GObject-2.0",
"Gdk-3.0",
"GdkPixbuf-2.0",
"Gio-2.0",
"Gtk-3.0",
"Pango-1.0",
"cairo-1.0",
"HarfBuzz-0.0",
"freetype2-2.0",
]