snapcraft icon indicating copy to clipboard operation
snapcraft copied to clipboard

Charmcraft no longer builds from scratch using edge release of snapcraft

Open lengau opened this issue 1 year ago • 1 comments

Bug Description

Doing a clean build of charmcraft breaks on the latest (core22-based) snapcraft available from edge. It works fine on stable, and it works fine if you upgrade from stable but don't run snapcraft clean.

Removing python3-pip from stage-packages appears to be sufficient to resolve the issue, but the config hook is then unable to find charmcraft. (See: https://github.com/canonical/charmcraft/pull/1146)

To Reproduce

In a new VM (tested in multipass with both focal and jammy):

  1. git clone https://github.com/canonical/charmcraft.git
  2. sudo snap install --edge snapcraft
  3. snapcraft --use-lxd

Environment

ubuntu@jammy:~/charmcraft$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
ubuntu@jammy:~/charmcraft$ snapcraft --version
snapcraft 7.4.3.post44+git4d0d7511 

snapcraft.yaml

https://github.com/canonical/charmcraft/blob/main/snap/snapcraft.yaml

Relevant log output

Pulling charmcraft 
+ snapcraftctl pull
+ git config --global --add safe.directory /root/parts/charmcraft/src
++ python3 setup.py --version
+ version=2.3.0.post15+git2c06b8c
+ snapcraftctl set-version 2.3.0.post15+git2c06b8c
Pulling craftctl 
+ snapcraftctl pull
Skipping build cryptography-deps (already ran)
Skipping build python3 (already ran)
Building charmcraft 
+ snapcraftctl build
+ python3 -m venv /root/parts/charmcraft/install
+ SNAPCRAFT_PYTHON_VENV_INTERP_PATH=/root/parts/charmcraft/install/bin/python3
+ pip install -U wheel
Traceback (most recent call last):
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 22.0.2 (/snap/snapcraft/9453/usr/lib/python3/dist-packages), Requirement.parse('pip==20.0.2'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/stage/usr/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3252, in <module>
    def _initialize_master_working_set():
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/root/parts/charmcraft/install/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==20.0.2' distribution was not found and is required by the application
Failed to build 'charmcraft'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.

Additional context

No response

lengau avatar Jul 10 '23 23:07 lengau