diff --git a/certbot/certbot/_internal/snap_config.py b/certbot/certbot/_internal/snap_config.py index 62f0043fa..e07ee6c08 100644 --- a/certbot/certbot/_internal/snap_config.py +++ b/certbot/certbot/_internal/snap_config.py @@ -71,7 +71,7 @@ def prepare_env(cli_args: List[str]) -> List[str]: raise e data = response.json() - connections = ['/snap/{0}/current/lib/python3.8/site-packages/'.format(item['slot']['snap']) + connections = ['/snap/{0}/current/lib/python3.12/site-packages/'.format(item['slot']['snap']) for item in data.get('result', {}).get('established', []) if item.get('plug', {}).get('plug') == 'plugin' and item.get('plug-attrs', {}).get('content') == 'certbot-1'] diff --git a/certbot/docs/contributing.rst b/certbot/docs/contributing.rst index b1876dca2..0413c5edd 100644 --- a/certbot/docs/contributing.rst +++ b/certbot/docs/contributing.rst @@ -375,8 +375,8 @@ Certbot plugin snaps expose their Python modules to the Certbot snap via a `snap content interface`_ where ``certbot-1`` is the value for the ``content`` attribute. The Certbot snap only uses this to find the names of connected plugin snaps and it expects to find the Python modules to be loaded under -``lib/python3.8/site-packages/`` in the plugin snap. This location is the -default when using the ``core20`` `base snap`_ and the `python snapcraft +``lib/python3.12/site-packages/`` in the plugin snap. This location is the +default when using the ``core24`` `base snap`_ and the `python snapcraft plugin`_. The Certbot snap also provides a separate content interface which diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5fdde3124..2ecab17e3 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -14,7 +14,7 @@ description: | - Keep track of when your certificate is going to expire, and renew it - Help you revoke the certificate if that ever becomes necessary. confinement: classic -base: core20 +base: core24 grade: stable adopt-info: certbot @@ -47,7 +47,7 @@ parts: - ./certbot-apache - ./certbot-nginx stage: - - -usr/lib/python3.8/sitecustomize.py # maybe unnecessary + - -usr/lib/python3.12/sitecustomize.py # maybe unnecessary # Old versions of this file used to unstage # lib/python3.8/site-packages/augeas.py to avoid conflicts between # python-augeas 0.5.0 which was pinned in snap-constraints.txt and @@ -57,18 +57,17 @@ parts: # effect so we now stage the file to keep the auto-generated cffi file. stage-packages: - libaugeas0 - - libpython3.8-dev + - libpython3.12-dev # added to stage python: - libpython3-stdlib - - libpython3.8-stdlib - - libpython3.8-minimal + - libpython3.12-stdlib + - libpython3.12-minimal - python3-pip - python3-wheel - python3-venv - python3-minimal - - python3-distutils - python3-pkg-resources - - python3.8-minimal + - python3.12-minimal # To build cryptography and cffi if needed build-packages: - gcc @@ -85,7 +84,7 @@ parts: # stability of fetching the rust crates needed to build the cryptography # library. - CARGO_NET_GIT_FETCH_WITH_CLI: "true" - - SNAPCRAFT_PYTHON_VENV_ARGS: --upgrade + - PARTS_PYTHON_VENV_ARGS: --upgrade # Constraints are passed through the environment variable PIP_CONSTRAINTS instead of using the # parts.[part_name].constraints option available in snapcraft.yaml when the Python plugin is # used. This is done to let these constraints be applied not only on the certbot package @@ -95,16 +94,18 @@ parts: override-build: | python3 -m venv "${SNAPCRAFT_PART_INSTALL}" "${SNAPCRAFT_PART_INSTALL}/bin/python3" "${SNAPCRAFT_PART_SRC}/tools/pipstrap.py" - snapcraftctl build + craftctl default override-pull: | - snapcraftctl pull + craftctl default grep -v python-augeas "${SNAPCRAFT_PART_SRC}/tools/requirements.txt" >> "${SNAPCRAFT_PART_SRC}/snap-constraints.txt" - snapcraftctl set-version `grep -oP "__version__ = '\K.*(?=')" "${SNAPCRAFT_PART_SRC}/certbot/certbot/__init__.py"` + craftctl set version=$(grep -oP "__version__ = '\K.*(?=')" "${SNAPCRAFT_PART_SRC}/certbot/certbot/__init__.py") + build-attributes: + - enable-patchelf shared-metadata: plugin: dump source: . override-pull: | - snapcraftctl pull + craftctl default mkdir -p certbot-metadata grep -oP "__version__ = '\K.*(?=')" $SNAPCRAFT_PART_SRC/certbot/certbot/__init__.py > certbot-metadata/certbot-version.txt stage: [certbot-metadata/certbot-version.txt] diff --git a/tools/snap/README.md b/tools/snap/README.md index f6354f748..c4ae0558d 100644 --- a/tools/snap/README.md +++ b/tools/snap/README.md @@ -12,7 +12,7 @@ These steps need to be done once to set up your VM and do not need to be run aga 1. Start with a Focal VM. You need a full virtual machine using something like DigitalOcean, EC2, or VirtualBox. Docker won't work. Another version of Ubuntu can probably be used, but Focal was used when writing these instructions. 2. Set up a user other than root with sudo privileges for use with snapcraft and run all of the following commands with it. A command to do this for a user named certbot looks like `adduser certbot && usermod -aG sudo certbot && su - certbot`. 3. Install git and python with `sudo apt update && sudo apt install -y git python`. - 4. Set up lxd for use with snapcraft by running `sudo snap install lxd && sudo /snap/bin/lxd.migrate -yes; sudo /snap/bin/lxd waitready && sudo /snap/bin/lxd init --auto` (errors here are ok; it may already + 4. Set up lxd for use with snapcraft by running `sudo snap install lxd; sudo /snap/bin/lxd waitready && sudo /snap/bin/lxd init --auto` (errors here are ok; it may already have been installed on your system). 5. Add your current user to the lxd group and update your shell to have the new assignment by running `sudo usermod -a -G lxd ${USER} && newgrp lxd`. 6. Install snapcraft with `sudo snap install --classic snapcraft`.