Failed to generate snap metadata errors

Hi,

I’m trying to snap a very simple script and I can’t seem to figure out what I’m doing wrong.

This is my directory tree:

numpy-dice-hy
├── numpy_dice_hy.py
├── README.md
└── snap
    └── snapcraft.yaml

This is my snapcraft.yaml file:

name: numpy-dice-hy
base: core18
version: git
summary: Dice roller using numpy.
description: Dice roller using numpy.

grade: devel
confinement: devmode

parts:
  numpy-dice-hy:
    source: https://github.com/nom666nom/numpy-dice-hy.git
    plugin: python
    python-version: python3
    source-type: git
    python-packages: [numpy]

apps:
  numpy-dice-hy:
    command: numpy_dice_hy.py

When I run the snapcraft command I get the following error:
Failed to generate snap metadata: The specified command 'numpy_dice_hy.py' defined in the app 'numpy-dice-hy' does not exist or is not executable. Ensure that 'numpy_dice_hy.py' is relative to the prime directory.

When I run snapcraft --debug my script is located in ./project/numpy_dice_hy.py which is ../project/numpy_dice_hy.py relative to the prime directory. If I change the command path in the yaml file to that I then get a new error: Failed to run '/bin/sh /tmp/tmpktn8oklg': Exited with code 1. . Obviously that’s not the answer to the problem. How do I comply with making my script relative to the prime directory?

Any help would be appreciated.

I’ve resolved my issue after walking away from it for the evening. Part of the issue was the setup.py and part of it was my misunderstanding of certain values.

My directory structure now looks like this:

├── bin
│   └── numpy_dice_hy.py
├── numpy-dice-hy
│   ├── __init__.py
│   └── numpy_dice_hy.py
├── README.md
├── setup.py
└── snap
    └── snapcraft.yaml```
The key it seems is that the setup.py needs to install the script where the snap expects it.

setup.py: ```scripts=['bin/numpy_dice_hy.py'],```
snapcraft.yaml: ```command: bin/numpy_dice_hy.py```

Once I made these adjustments the snapcraft process works.  Hopefully this helps others in the future.