← Back to issue list

Classic confined Python example fails

View original Github issue

Metadata

Project
snapcraft
Number
#4251
Type
issue
State
closed
Author
dboddie
Labels
Status: Triaged Type: Documentation
Created
Updated
Closed

Current evaluation

Resolved via PR #4269 (commit 833b0f213), which added a passing Spread test for the Python + classic documentation example.

Resolution: closed resolved

Reason: Merged PR canonical/snapcraft#4269 added successful Spread coverage for the Python + classic tutorial in commit 833b0f213, preventing the reported example failure from going unnoticed.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description This example/test used to work (see the successful Actions builds). Now it fails. https://github.com/snapcraft-docs/python-ctypes-example ### To Reproduce * Check out the code from the repository. * Build with `snapcraft --use-lxd` ### Environment Snapcraft running with LXD on Ubuntu 22.10, but also fails on Ubuntu 22.04. ### snapcraft.yaml ```shell name: example-python-ctypes base: core22 version: '0.1' summary: An example snap for a Python project using ctypes description: | Shows how to create a snap for a Python application that uses ctypes to access a system library. grade: devel confinement: classic apps: example-python-ctypes: # This refers to the installed location of the program at build-time. # When the snap is installed, it will be available as example-python-ctypes. command: bin/test-ctypes.py parts: example-part: source: . plugin: python # Override the build to perform a normal build then patch ctypes to fix the # run-time library paths. override-build: | snapcraftctl build $SNAPCRAFT_PROJECT_DIR/snap/local/patch-ctypes.sh # These packages need to be made available so that the build step can patch # ctypes. stage-packages: - libpython3.10-minimal - libpython3.10-stdlib # This resolves warnings reported by the classic linter for Snapcraft 3.7. build-attributes: - enable-patchelf ``` ### Relevant log output ```shell 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:57.764 :: Successfully built test-ctypes 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:57.793 :: Installing collected packages: test-ctypes 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:57.806 :: Successfully installed test-ctypes-0.0.1 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.035 :: + find /root/parts/example-part/install -type f -executable -print0 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.035 :: + xargs -0 sed -i '1 s|^#\!/root/parts/example-part/install/bin/python3.*$|#!/usr/bin/env python3|' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.069 :: ++ set +o 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.069 :: ++ grep errexit 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.071 :: + opts_state='set +o errexit' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.071 :: + set +e 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.071 :: + install_dir=/root/parts/example-part/install/usr/bin 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.071 :: + stage_dir=/root/stage/usr/bin 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.071 :: ++ find /root/parts/example-part/install/usr/bin /root/stage/usr/bin -type f -executable -name 'python3.*' -print -quit 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.073 :: + payload_python=/root/parts/example-part/install/usr/bin/python3.10 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.073 :: + '[' -n /root/parts/example-part/install/usr/bin/python3.10 ']' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + installed_python=/usr/bin/python3.10 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + '[' /usr/bin/python3.10 = /root/parts/example-part/install/usr/bin/python3.10 ']' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + symlink_target=../usr/bin/python3.10 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + '[' -z ../usr/bin/python3.10 ']' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + eval 'set +o errexit' 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: ++ set +o errexit 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.074 :: + ln -sf ../usr/bin/python3.10 /root/parts/example-part/install/bin/python3 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.142 :: 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.142 :: Users are encouraged to replace 'snapcraftctl' with 'craftctl' and use 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.142 :: 'CRAFT_*' environment variables in scriptlets when building snaps based 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.142 :: on core22. Please refer to the core22 migration guide for details. 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.142 :: + /root/project/snap/local/patch-ctypes.sh 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.143 :: + python3 -c import ctypes; print(ctypes.__file__) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.184 :: + CTYPES_INIT=/root/parts/example-part/install/root/parts/example-part/install/usr/lib/python3.10/ctypes/__init__.py 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.184 :: + CTYPES_INIT_ORIG=/root/parts/example-part/install/root/parts/example-part/install/usr/lib/python3.10/ctypes/__init__.py.orig 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.184 :: + python3 -c import site; print(site.__file__) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.194 :: + SITE_PY=/root/parts/example-part/install/root/parts/example-part/install/usr/lib/python3.10/site.py 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.194 :: + [ -f patched/ctypes/__init__.py.orig ] 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.195 :: + echo Patching ctypes... 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.195 :: Patching ctypes... 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.195 :: + patch -s -b /root/parts/example-part/install/root/parts/example-part/install/usr/lib/python3.10/ctypes/__init__.py /root/project/snap/local/patches/ctypes_init.diff 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.196 :: patch: **** Can't reopen file /root/parts/example-part/install/root/parts/example-part/install/usr/lib/python3.10/ctypes/__init__.py : No such file or directory 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.378 'override-build' in part 'example-part' failed with code 2. 2023-06-30 18:35:58.701 :: Review the scriptlet and make sure it's correct. 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 Traceback (most recent call last): 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 177, in run 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 aex.execute(action, stdout=stream, stderr=stream) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 304, in execute 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 self._executor.execute(actions, stdout=stdout, stderr=stderr) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 128, in execute 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 self._run_action(act, stdout=stdout, stderr=stderr) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 193, in _run_action 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 handler.run_action(action, stdout=stdout, stderr=stderr) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 172, in run_action 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 state = handler(step_info, stdout=stdout, stderr=stderr) 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 309, in _run_build 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 self._run_step( 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 485, in _run_step 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 step_handler.run_scriptlet( 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_parts/executor/step_handler.py", line 278, in run_scriptlet 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 raise errors.ScriptletRunError( 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 craft_parts.errors.ScriptletRunError: 'override-build' in part 'example-part' failed with code 2. 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 Review the scriptlet and make sure it's correct. 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.383 The above exception was the direct cause of the following exception: 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 Traceback (most recent call last): 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 File "/snap/snapcraft/9362/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 302, in _run_command 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 _run_lifecycle_and_pack( 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 File "/snap/snapcraft/9362/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 345, in _run_lifecycle_and_pack 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 lifecycle.run( 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 File "/snap/snapcraft/9362/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 192, in run 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 raise errors.PartsLifecycleError(str(err)) from err 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 snapcraft.errors.PartsLifecycleError: 'override-build' in part 'example-part' failed with code 2. 2023-06-30 18:35:58.701 :: 2023-06-30 16:35:58.384 Review the scriptlet and make sure it's correct. 2023-06-30 18:36:00.072 Failed to execute pack in instance. 2023-06-30 18:36:00.072 Detailed information: Run the same command again with --debug to shell into the environment if you wish to introspect this failure. 2023-06-30 18:36:00.073 Traceback (most recent call last): 2023-06-30 18:36:00.073 File "/snap/snapcraft/9362/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 574, in _run_in_provider 2023-06-30 18:36:00.073 instance.execute_run(cmd, check=True, cwd=output_dir) 2023-06-30 18:36:00.073 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_providers/lxd/lxd_instance.py", line 289, in execute_run 2023-06-30 18:36:00.073 return self.lxc.exec( 2023-06-30 18:36:00.073 File "/snap/snapcraft/9362/lib/python3.8/site-packages/craft_providers/lxd/lxc.py", line 371, in exec 2023-06-30 18:36:00.073 return runner(final_cmd, **kwargs) # pylint: disable=subprocess-run-check 2023-06-30 18:36:00.073 File "/snap/snapcraft/9362/usr/lib/python3.8/subprocess.py", line 516, in run 2023-06-30 18:36:00.073 raise CalledProcessError(retcode, process.args, 2023-06-30 18:36:00.073 subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-example-python-ctypes-on-amd64-for-amd64-13899806', '--cwd', '/root/project', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'SNAPCRAFT_MANAGED_MODE=1', 'snapcraft', 'pack', '--verbosity=brief', '--build-for', 'amd64']' returned non-zero exit status 1. ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Resolved via PR #4269 (commit 833b0f213), which added a passing Spread test for the Python + classic documentation example.
stealth/space-bunny-alpha — closed resolved Resolved by adding passing docs-example coverage in merged PR #4269 (commit 833b0f213), which tests the classic-confinement Python ctypes tutorial.
stealth/space-bunny-alpha — closed resolved Closed after merged PR #4269 (commit 833b0f213) added passing Spread coverage for the Python classic-confinement docs example.
stealth/space-bunny-alpha — closed resolved Classic Python docs-example coverage was added: merged PR #4269 (commit 833b0f2) introduced a passing Spread test for the Python + classic tutorial.
qwen/qwen3.6-35b-a3b — — Classic Python snap example fails during build due to a patch script error. Closed and superseded by SNAPCRAFT-49, where resolution is planned as part of a broader effort to test documentation examples.
qwen/qwen3.6-35b-a3b — — The failing Python example was closed and deferred to a larger documentation testing initiative (SNAPCRAFT-49). It will be fixed as part of ongoing efforts to validate example snaps in the official docs.
qwen/qwen3.6-35b-a3b — — Closed and deferred to a larger documentation testing initiative (SNAPCRAFT-49) rather than receiving an immediate fix. Internal tickets CRAFT-1852 and SNAPCRAFT-1083 track the underlying build failure and future docs validation.
qwen3.6-35b-a3b-mtp-q6 — — The classic Python example snap build fails due to a path duplication bug in the build script. The issue was triaged and deferred to be fixed as part of a larger documentation snap testing effort (SNAPCRAFT-49).

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/snapcraft#4269 (confidence 98%)

    PR #4269 added and passed a Spread test for the affected documentation example.

Related issues

Issue Project State Summary Similarity
#4269 spread: add a test for the "python + classic" tutorial snapcraft merged Merged PR #4269 in commit 833b0f213, adding an Ubuntu 20.04 Spread test for the Python classic-confinement tutorial; the new classic-python test passed.
80%