Creating Python app that runs behind the module

Hi,

I am working on deploying a python app to snap.

The problem is the app is not just some python code that can be build and that’s it.

Here’s how I run my app in the normal linux environment. I install a library from whl python file.
Then I go to write some code and ini file that tells the library where my code is.
Then I run a module from this library and pass the ini file as a configuration file.

Let’s say the whl installed library is called x, and I need to install module y, then I write the following to run my app in the normal environment:

/usr/bin/python -m x.y --configfile=custom_app.ini

I am unable to make this using snaps.

here’s my snap file structure:

name: myapp
version: '0.1'
summary: 
description:

grade: devel
confinement: strict

parts:
  x:
    plugin: python
    python-version: python2
    source: /usr/local/lib/python2.7/dist-packages/x
    stage-packages:
      - python-dev
      - python-pip
  xplugins:
    plugin: python
    python-version: python2
    source: /usr/local/lib/python2.7/dist-packages/x_plugins
    stage-packages:
        - libmysqlclient-dev
    filesets:
      appw: [/home/myname/Desktop/app-code/*]

apps:
  xyz:
     command: usr/bin/python -m x.y --configfile=./appw/custom.ini
     daemon: simple
     restart-condition: always
     plugs:
      - network
      - network-control
      - bluetooth-control

It’s not working in the current state, what is the best design for this case?
Thanks.

Where does your ini file point to? paths in there should be absolute and containing the $SNAP dir (if python respects the environment in such cases)

do you have any journal or syslog excerpts from when the daemon tries to start ?

It points to the same directory, all source files for my custom app are in the same directory with the ini file.

I am getting this when I run the app
/snap/x/x1/usr/bin/python: No module named x

No, I replaced this line command: usr/bin/python -m x.y --configfile=./appw/custom.ini with this:

command: usr/bin/python -m bin/x.y --configfile=./appw/custom.ini

and getting this error: /snap/x/x4/usr/bin/python: Import by filename is not supported.

First, have you tried running your app in a virtualenv?