lxd icon indicating copy to clipboard operation
lxd copied to clipboard

LXD snap contains duplicated copies of some python modules

Open simondeziel opened this issue 1 year ago • 1 comments

The following Python modules are duplicated between LXD's snap and core24:

$ grep -Fxf <(ls -1 /snap/lxd/current/lib/python3/dist-packages/) <(ls -1 /snap/core24/current/usr/lib/python3/dist-packages/) 
certifi
certifi-2023.11.17.egg-info
chardet
chardet-5.2.0.dist-info
idna
idna-3.6.dist-info
PyYAML-6.0.1.dist-info
requests
requests-2.31.0.egg-info
urllib3
urllib3-2.0.7.dist-info
_yaml
yaml

Ideally, those would be removed from LXD's snap and the PYTHONPATH would be augmented to include the /snap/coreXY/current/usr/lib/python3/dist-packages/. Doing that should avoid issues like https://github.com/canonical/lxd/security/code-scanning/693 and https://github.com/canonical/lxd/security/code-scanning/694

simondeziel avatar Oct 17 '24 20:10 simondeziel

Sounds like a plan!

tomponline avatar Oct 18 '24 07:10 tomponline

@simondeziel is this still an issue ?

tomponline avatar Apr 30 '25 08:04 tomponline

@simondeziel is this still an issue ?

Yes it is but I have not had a chance to look into it. When I get there, we should be able to save ~2.4MiB (before xz compression):

$ { cd /snap/lxd/current/lib/python3/dist-packages/; du -shc $(grep -Fxf <(ls -1 /snap/lxd/current/lib/python3/dist-packages/) <(ls -1 /snap/core24/current/usr/lib/python3/dist-packages/)); }
1.5K	certifi
4.0K	certifi-2023.11.17.egg-info
1.1M	chardet
5.5K	chardet-5.2.0.dist-info
299K	idna
11K	idna-3.6.dist-info
4.0K	PyYAML-6.0.1.dist-info
179K	requests
6.5K	requests-2.31.0.egg-info
392K	urllib3
7.5K	urllib3-2.0.7.dist-info
1.5K	_yaml
441K	yaml
2.4M	total

The small size savings are the main reason I didn't prioritized this over other tasks.

simondeziel avatar Apr 30 '25 14:04 simondeziel