Problem with python3-setuptools as a stage-package

Hi Folks,

The project I’m trying to snap up required python3-setuptools as a staging package.

Problem is, I run into this error when snapping

  ERROR: Command errored out with exit status 1:
   command: /root/stage/usr/bin/python3 /snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpjvcdn261
   cwd: /tmp/pip-download-vdr4ovym/pygobject
  Complete output (10 lines):
  Traceback (most recent call last):
File "/snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 257, in <module>
  main()
File "/snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 240, in main
  json_out['return_val'] = hook(**hook_input['kwargs'])
File "/snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 85, in get_requires_for_build_wheel
  backend = _build_backend()
File "/snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 76, in _build_backend
  obj = getattr(obj, path_part)
  AttributeError: module 'setuptools.build_meta' has no attribute '__legacy__'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /root/stage/usr/bin/python3 /snap/snapcraft/3943/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpjvcdn261 Check the logs for full command output.
Failed to run '/root/stage/usr/bin/python3 -m pip download --disable-pip-version-check --dest /root/parts/requirements/python-packages --requirement /root/parts/requirements/src/requirements.txt': Exited with code 1.

From my research, it seems this is a known problem when setuptools version is less than v 40.8.

18.04 repositories use 39.0.1-2 unfortunately.

How can I get the latest setuptools version in this snap, or what workaround might there be?

Thanks!

Any idea is a big help!

A bit late to this, but I had the same or similar problem. In my case, the issue wasn’t actually setuptools. It was kind of a misleading error. I had to add python3-setuptools to both my stage packages and my build packages. I saw the same (similar?) issue when I had python3-setuptools in only stage packages. In any case, I saw the same error and found the same research you did. I even tried core20 but that didn’t work because the gnome desktop stuff isn’t ready yet. Anyway, probably just a shot in the dark, but . . .

Try to remove your python3-setuptools and upgrade your setuptools package trhought pip
$ sudo apt remove python3-setuptools
$ pip install -U setuptools
It worked for me