Search code examples
pythonsnapcraftkedro

How to snap a python package with plugin packages?


I'd like to bundle the Python package kedro which provides a command line interface (kedro). In addition I'd like to put the Python package kedro-docker into the snap as well. This second package extends the first package's command line interface (kedro docker). But when I create a snap with the snapcraft.yaml below I get only the command line interface of the first package:

name: kedro
base: core18
version: latest
description: |
    Kedro is a development workflow framework that implements software
    engineering best-practice for data pipelines with an eye towards
    productionising machine learning models.

grade: devel
confinement: devmode

architectures:
  - build-on: [amd64]

apps:
  kedro:
    command: kedro
    plugs:
      - home
      - network
      - network-bind
      - docker
    environment: {
      LANG: C.UTF-8,
      LC_ALL: C.UTF-8
    }

parts:
  kedro:
    plugin: python
    python-version: python3
    python-packages:
      - kedro==0.15.9
      - kedro-docker==0.1.1

How can I get the extended command line interface (kedro docker) into the snap?


Solution

  • I'm no expert and never used snapcraft, therefore just a hypothesis here. Kedro-Docker exposes only project-specific commands that won't show up unless you are in the root of the project. So if you run kedro new and then cd <project-dir> && kedro, you should (ideally) see a docker group of commands:

    Global commands from Kedro
    Commands:
      docs  See the kedro API docs and introductory tutorial.
      info  Get more information about kedro.
      new   Create a new kedro project.
    
    Project specific commands from Docker
    Commands:
      docker  Dockerize your Kedro project.
    
    Project specific commands from <project-dir>/kedro_cli.py
    Commands:
      activate-nbstripout  Install the nbstripout git hook to automatically...
      build-docs           Build the project documentation.
      build-reqs           Build the project dependency requirements.
      install              Install project dependencies from both...
      ipython              Open IPython with project specific variables loaded.
      jupyter              Open Jupyter Notebook / Lab with project specific...
      lint                 Run flake8, isort and (on Python >=3.6) black.
      package              Package the project as a Python egg and wheel.
      run                  Run the pipeline.
      test                 Run the test suite.