Pyatspi module is installed in CI but cannot be loaded

My CI file below

GuiTest:
  stage: test
  dependencies:
    - build
  before_script:
    - apt-get update && apt-get install libcairo2-dev libgirepository1.0-dev libgtk-3-dev python3-pyatspi python3-dogtail gnome-icon-theme gsettings-desktop-schemas xvfb -y
    - gsettings set org.gnome.desktop.interface toolkit-accessibility true
    - pip3 install pycairo PyGObject
    - pip3 install setuptools
    - pip3 install dogtail
  script:
    - cd tests/gui
    - apt list | grep pyatspi
    - python3 -c "help('modules pyatspi')"
    - xvfb-run python3 test.py

installs the module pyatspi and the log shows that it has been installed yet, as shown below, it is not visible to Python???

$ apt list | grep pyatspi
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
python3-pyatspi/stable,now 2.38.1-1 all [installed,automatic]
...
$ python3 -c "help('modules pyatspi')"
Here is a list of modules whose name or summary contains 'pyatspi'.
If there are any, enter a module name to get more help.

How can this be?

Solved it!

Added the line following lines in gitlab-ci.yml

before_script:
    - updatedb
    - locate pyatspi

script:
    - python3 -c 'import site; print(site.getsitepackages())'

The site packages check returned
['/usr/local/lib/python3.10/site-packages']

But locate pyatspi returned (see the locate command)

/usr/lib/python3/dist-packages/pyatspi
/usr/lib/python3/dist-packages/pyatspi/Accessibility.py
/usr/lib/python3/dist-packages/pyatspi/__init__.py
/usr/lib/python3/dist-packages/pyatspi/__pycache__
/usr/lib/python3/dist-packages/pyatspi/action.py
/usr/lib/python3/dist-packages/pyatspi/appevent.py
/usr/lib/python3/dist-packages/pyatspi/application.py
/usr/lib/python3/dist-packages/pyatspi/atspienum.py
/usr/lib/python3/dist-packages/pyatspi/collection.py
...

Clearly apt-get installed python3-pyatspi in a location unknown to Python, so I added a sym-link

script:
  - ln -s /usr/lib/python3/dist-packages/pyatspi /usr/local/lib/python3.10/site-packages/pyatspi

Of course the symbolic link is a hack. There’s a proper solution on stackoverflow. Still trying to wrap my mind around it.

1 Like