How to set resource path in flatpak manifest for pip install?

Since is deprecated in the current Gnome Platform, I had to switch to pip for installing python apps in the manifest. The problem with using pip is that the resource path is no longer getting set correctly. So even though Gramps 5.1.5 flatpak compiles now, the flatpak does not open Gramps and gives an error about unable to determine resource path.

So I looked at Gramps 5.1 Wiki Manual - Command Line - Gramps and 2 questions that involve Linux - Help - The Gramps Project (Discourse Forum & Mailing List) to learn how to set the resource path. There are a couple problems, the flatpak command is different so I don’t know how to set the resource path in the desktop file while launching the app; and the other problem is that the path is different in flatpaks. I’ve been trying variations of /app/lib/ and /app/bin/ in config-settings and build-options for the resource path, and /app/lib/python3.9/site-packages/gramps for the python path. It compiles on both github and my pc, although it throws a “no component node” error at the end when I build on home pc, which I haven’t figured out yet. Here is a sample of what I’ve tried with the Gramps module of the flatpak module. I’ve been alternating between config-opts and build-options, that is why build-options is commented out in this example of what I have been trying. What am I doing wrong?

  - name: Gramps
    buildsystem: simple
      - GRAMPS_RESOURCES=/app/lib
      - PYTHONPATH=/app/lib/python3.9/site-packages/gramps
#    build-options:
#      env:
#        GRAMPS_RESOURCES: /app/lib
#        PYTHONPATH: /app/lib/python3.9/site-packages/gramps
      - pip3 install --no-deps --no-use-pep517 --prefix=/app .
      - install -Dm644 org.gramps_project.Gramps.metainfo.xml -t /app/share/metainfo/
      - mv ${FLATPAK_DEST}/share/mime/packages/gramps.xml ${FLATPAK_DEST}/share/mime/packages/${FLATPAK_ID}.xml
      - type: archive
        sha256:  4045a142a7c3cbe50a41e594bb160dce4112e37ef7dec68d65af42e9269c2df6
      - type: file
        path:  org.gramps_project.Gramps.metainfo.xml

(edit to try fixing format)

If you want to influence the environment at build time, your build-options: env: ... is right. It seems like you need to be influencing the GRAMPS_RESOURCES variable at run time. For this you can add --env=GRAMPS_RESOURCES=/app/lib to your app’s finish-args:. Here’s an example I found with a quick search - - you can have a search around on for examples which might give you some ideas.