C++ application with python modules requirement

Hello, I am trying to package Gnome Referencer as snap. Referencer is written in C++ and depends on gtk2. More over Referencer comes with plugins that are written in python. This snap almost works except some of the python plugins. When I launch the snap, plugins failed to load and I get these messages :

Explanation: No module named gtk
Explanation: No module named gobject

Inside python plugins code, I found this :

indent preformatted text by 4 spaces
import gtk # for dialogs
import gobject

These modules exist on my system. I found them in /usr/lib/python2.7/dist-packages/gi/overrides/ What are these dependencies ? How can I add it to my snap package ?

You can watch my yaml files bellow :

Thank you :slight_smile:

name: referencer # you probably want to 'snapcraft register <name>'
version: '1.2.2' # just for humans, typically '1.2+git' or '1.3.2'
summary: manage your bibliograpy # 79 char long summary
description: manage your bibliograpy

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
icon: ./referencer-1.2.2/data/referencer.svg
apps:
  referencer:
    command: desktop-launch $SNAP/bin/referencer
    desktop: share/applications/referencer.desktop
    environment:
      PYTHONPATH: $SNAP/lib/x86_64-linux-gnu/:$SNAP/usr/lib/python2.7/:$SNAP/usr/lib/python2.7/plat-x86_64-linux-gnu/:$SNAP/lib/referencer/:$PYTHONPATH
      PYTHONHOME: $SNAP/lib/x86_64-linux-gnu/:$SNAP/usr/lib/python2.7/:/$SNAP/usr/lib/python2.7/plat-x86_64-linux-gnu/:/$SNAP/lib/referencer/:$PYTHONHOME

    plugs: 
        - x11
        - home
        - desktop
        - network
 parts:
  referencer:
    # See 'snapcraft plugins'
    plugin: autotools   
    source: ./referencer-1.2.2/
   
    after: 
        - desktop-gtk2
    build-packages:
        - build-essential
        - gnome-doc-utils
        - intltool
        - python2.7-dev
        - libpython2.7-dev
        - libxml2-dev
        - libpoppler-glib-dev
        - libgconfmm-2.6-dev
        - libgtkmm-2.4-dev
        - libboost-regex-dev
        - rarian-compat
        
    stage-packages:
        - libc6
        - libatkmm-1.6-1v5
        - libcairomm-1.0-1v5
        - libdbus-glib-1-2
        - libgconf-2-4
        - libdb5.3
        - libgconfmm-2.6-1v5
        - libpangomm-1.4-1v5
        - libglibmm-2.4-1v5
        - libpoppler-glib8
        - libpoppler58
        - python2.7
        - libpython2.7
        - libgtkmm-2.4-1v5
        - libboost-regex1.58.0
        - libsigc++-2.0-0v5

You can get those two with their respective packages from the repository. Add the following two packages to your stage-packages block:

...
parts:
  referencer:
    ...
    stage-packages:
      ...
      - python-gtk2
      - python-gobject-2
      ...

Thank you,
However, in that case Referencer failed to build… for some reason, the path used to check all the python dependencies is different : It was previously searching python on my system, and now it search python in the local parts folder (where snapcraft run).

fatal error: Python.h: Aucun fichier ou dossier de ce type
In file included from Preferences.h:22:0

Hearders files are missing in the parts folder. Do we have to specify something to add these files ?

UPDATE :
I find a workaround of my trouble by creating a new part with the plugin nil, that stage all python packages.

pythonsource:
plugin: nil
stage-packages:
    - python2.7-dev
    - libpython2.7-dev
    - python-gtk2
    - python-gobject-2

By this way the /usr/include/python2.7/… directory is copied inside the parts folder.

Last question :slight_smile
Referencer start in english. How to tell the snap to use the local language settings ?

Thank you very much !!