Error: invalid command 'bdist_wheel'

Hi,
I need yacron in my application. Here is simple yaml:

name: yacron
version: 1.0.0
summary: yacron
description: A modern Cron replacement that is Docker-friendly

base: core20
confinement: devmode


parts:
  yacron:
    plugin: python
    python-packages:
      - wheel
      - yacron

While building snap package, it gives error:

Building wheels for collected packages: strictyaml, crontab
  Building wheel for strictyaml (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /root/parts/yacron/install/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lnqmppfw/strictyaml/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lnqmppfw/strictyaml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-u1b28js2
       cwd: /tmp/pip-install-lnqmppfw/strictyaml/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help
  
  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for strictyaml
  Running setup.py clean for strictyaml

This is because the addition of wheel is done at the same time as yacron. You will either need 2 parts or, considering that yacron is your main deliverable, add it through use of source.

@sergiusens
Thanks for reply. I noticied that usr/lib/python3/dist-packages is not in sys.path, $SNAP/usr/lib/python3/dist-packages is neither in sys.path so within snap sandbox, python modules in $SNAP/usr/lib/python3/dist-packages can’t be imported. I think this is a bug. So the following worked for me:

name: yacron
version: 1.0.0
summary: yacron
description: A modern Cron replacement that is Docker-friendly

base: core20
confinement: devmode

parts:
  yacron:
    plugin: python
    build-environment:
      - PYTHONPATH: "$SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages"
    stage-packages:
      - python3-wheel
    python-packages:
      - yacron
3 Likes

I really like your solution, I’ll have to test it out. One thing that I found worked as well was a build override, this is a snippet from my own snap which had this issue which also fixes this problem, albeit not as nicely as your solution:

 parts:
   dependencies:
     plugin: python
     override-build: |
       snapcraftctl build
       pip3 install wheel
       pip3 install urllib3 pydbus
       pip3 install pycairo
       pip3 install PyGObject
     build-packages:
       - libgirepository1.0-dev
       - gcc
       - pkg-config
       - libcairo2-dev
       - gir1.2-glib-2.0
       - gir1.2-freedesktop
     stage-packages:
       - libgirepository1.0-dev
       - gir1.2-glib-2.0
       - gir1.2-freedesktop

Yes, the following also worked for me:

parts:
  yacron:
    plugin: python
    override-build: |
       snapcraftctl build
       pip3 install wheel

    python-packages:
      - yacron

It is also nice solution, but the thing is usr/lib/python3/dist-packages is not in sys.path, thus any prebuild python packages installed under stage-packages that goes to usr/lib/python3/dist-packages is not recognized neither by snapcraaft nor snap. For example I have to write this

   environment:
      PYTHONPATH: "$SNAP/usr/lib/python3/dist-packages"

for python apps

1 Like