Python install prefix

Hi, I have a python app that I can’t figure out how make it install into $SNAP/usr/bin instead of $SNAP/bin.

Installing into /usr prefix will prevent me from moving/merging directories at build time so that icons are in /usr/share instead of /share and I have default config files that should be at /usr/share/my_app but are located at /share/my_app

For a C/C++ autotools based app I just use autotools-configure-parameters: ['--prefix=/usr']

Looking at https://github.com/snapcore/snapcraft/blob/main/snapcraft_legacy/plugins/v2/python.py I dont see anything obvious. Thanks!

I realize I missed some potentially important information. The project is using the core18 base and python2 interpreter. There’s a setup.py script that utilizes distutils for the app and it works great (as intended) outside the snap ecosystem.

I’m going to answer myself and say the choices are either:

  • copy/pasting the python plugin to a custom plugin and adding support for prefix dir
    • This isn’t hard but then we lose any changes in the future to the python plugin
  • rsync the files in override-build to where we want them to be

I chose the rsync method because I only needed the ${SNAPCRAFT_PART_INSTALL}/share/ dir to be copied to ${SNAPCRAFT_PART_INSTALL}/usr/share/and it’s a one line change since I already was using override-build.