[4.0.4][strict] usage of the python plugin forces the python3 interpreter to be shipped in the snap

Bug #1882994 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Expired
Undecided
Unassigned

Bug Description

The python plugin uses the following command to set up a venv in the installation directory:

https://github.com/snapcore/snapcraft/blob/4.0.4/snapcraft/plugins/v2/python.py#L117-L120
${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} "${SNAPCRAFT_PART_INSTALL}

This forces python3 to be copied into the snap without any explicit configuration:

snapcraft-microstack # stat parts/openstack-projects/install/bin/python3
  File: parts/openstack-projects/install/bin/python3 -> /root/stage/bin/python3
  Size: 23 Blocks: 0 IO Block: 4096 symbolic link
Device: 10fc80h/1113216d Inode: 7210747 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-06-10 17:27:10.515782934 +0000
Modify: 2020-06-10 17:27:10.511782914 +0000
Change: 2020-06-10 17:27:10.511782914 +0000
 Birth: -

snapcraft-microstack # rm parts/openstack-projects/install/bin/python3

snapcraft-microstack # "${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} "${SNAPCRAFT_PART_INSTALL}"
snapcraft-microstack # stat parts/openstack-projects/install/bin/python3
  File: parts/openstack-projects/install/bin/python3 -> /root/stage/bin/python3
  Size: 23 Blocks: 0 IO Block: 4096 symbolic link
Device: 10fc80h/1113216d Inode: 7210747 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-06-10 17:27:28.487873571 +0000
Modify: 2020-06-10 17:27:28.483873551 +0000
Change: 2020-06-10 17:27:28.483873551 +0000
 Birth: -

Meanwhile, I would like to avoid this and the one shipped with core20.

And at runtime the lack of that leads to subtle failures like this:

# a shell in the snap environment:
# sha256sum /usr/bin/python3.8
3fe2b9781ccb82b2a143cdcac2630ff25a74e049d5f34d6c10edd0598ccb705f /usr/bin/python3.8

# sha256sum /snap/microstack/x11/bin/python3
3fe2b9781ccb82b2a143cdcac2630ff25a74e049d5f34d6c10edd0598ccb705f /snap/microstack/x11/bin/python3

# python3.8
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keystone
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'keystone'

>>> import sys
>>> sys.path
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/lib/python3/dist-packages']

# python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keystone
>>> import sys
>>> sys.path
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/snap/microstack/x11/lib/python3.8/site-packages']

# outside the confined environment:

$ sha256sum /snap/core20/current/usr/bin/python3
3fe2b9781ccb82b2a143cdcac2630ff25a74e049d5f34d6c10edd0598ccb705f /snap/core20/current/usr/bin/python3

$ sha256sum /snap/core20/current/bin/python3
3fe2b9781ccb82b2a143cdcac2630ff25a74e049d5f34d6c10edd0598ccb705f /snap/core20/current/bin/python3

$ sha256sum /snap/microstack/current/bin/python3
05d75e4d16006f760b67b0901587f0f94dace6b7231e1351c1349ecbb0ebaf4c /snap/microstack/current/bin/python3

description: updated
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

We had a symlink issue in the past which caused *cyclic symlinking farm* that has since been solved, is this still an issue today?

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Snapcraft because there has been no activity for 60 days.]

Changed in snapcraft:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.