Add local files as snap dependency

i am currently working on my python snap. my project has dependency of ‘geckodriver’.

geckodriver is placed in my project directory as show in tree below.

.
|-- LICENSE
|-- project.py
|-- geckodriver
|-- geckodriver.log
|-- setup.py
`-- snap
    `-- snapcraft.yaml

is there any way to add ‘geckodriver’ dependency in my snap??

and is there a way to access /usr/bin/ ?? first, i used driver path as /usr/bin/geckodriver but my snap can’t access it.

Thanks.

I think you want the dump plugin: https://snapcraft.io/docs/dump-plugin
It can transfer files from your project dir just fine.

Use the organize keyword as outlined in the documentation linked above. Your file will live at $SNAP/usr/bin/geckodriver and be in the path, from the perspective of the snap.

@ppd thanks for reply.
i read about dump-plugin and made some change in my snapcraft.yaml file.

snapcraft.yaml::

parts:
  project:
    plugin: dump
    source: .
    organize:
      'geckodriver' : $SNAP/usr/bin/
    prime:
      - LICENSE

apps:
  project:
    command: bin/project
    plugs:
      - home
      - network
      - network-control

but here i got an error:

Failed to generate snap metadata: Specified command 'bin/project' was not found.
Verify the command is correct and for a more deterministic outcome, specify the relative path to the command from the prime directory.

what did i wrong here?? can you please help me out? and is there any opensource project snapcraft.yaml file available for reference to how can i use dump-plugin properly?

Thanks.

You can find real-world examples for dump plugin usage here: https://github.com/search?q=filename%3Asnapcraft.yaml+"plugin%3Adump"&type=Code

Is there a reason you can’t include geckodriver in the python module itself? Like so: https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
I’m not a python expert though.

For your python project you should use plugin: python. The dump plugin is just for copying stuff 1:1 (mostly).
bin/project must be accessible within the snap, i.e. in $SNAP/bin/project.

what did i wrong here?? can you please help me out? and is there any opensource project snapcraft.yaml file available for reference to how can i use dump-plugin properly?

project is being dumped (as would be the objective of the dump plugin) into the root of the snap as =project.py= (check the prime directory) so bin/project would not exist.

If your intention is to install through python and =setup.py= handles geckodriver, then just use the python plugin for this.
If =setup.py= does not handle the installation of =geckodriver=, then use =override-build= with the python plugin, like:

#+BEGIN_SRC yaml
override-build: |
snapcraftctl override-build
install -D geckodriver $SNAPCRAFT_PART_INSTALL/usr/bin/geckodriver
#+END_SRC

i tried to override build and got error:

Launching a VM.
Skipping pull anonymousmail (already ran)                                       
Building anonymousmail 
/root/parts/anonymousmail/install/usr/bin/python3: No module named pip
Not all dependencies where satisfied with python-packages or requirements. Resorting to fetching from PyPI.
/root/parts/anonymousmail/install/usr/bin/python3: No module named pip
Failed to run '/root/parts/anonymousmail/install/usr/bin/python3 -m pip install --user --no-compile --find-links /root/parts/anonymousmail/python-packages .': Exited with code 1.

i think snap try to fetch geckodriver from pypi.

geckdriver is used to run firefox browser remotely. so geckodriver can’t handle by python and setup script.

is there any way to dump only geckodriver into snap?? i added this lines in parts, and get source error:

geckodriver:
    plugin: dump
    source: ./geckodriver

Thanks.