From 70c8481fd893fe2e9fa16f7167073b0c6f417e55 Mon Sep 17 00:00:00 2001 From: ohemorange Date: Thu, 18 Jun 2020 15:24:10 -0700 Subject: [PATCH] Don't include certbot deps when EXCLUDE_CERTBOT_DEPS is set in plugins (#8091) This will allow DNS plugin snaps to build if they rely on unreleased acme/certbot, and remove other copy of Certbot from externally snapped plugins. Fixes #8064 and fixes #7946. Implementation is based on the design [here](https://github.com/certbot/certbot/issues/8064#issuecomment-645513120). To test, see reverted commit 8632064. Steps taken: - added changes to setup.py and snapcraft.yaml - successfully snapped, connected, ran `sudo certbot plugins --prepare` - added temporary changes to have both certbot and certbot-dns-dnsimple use DNSAuthenticator2 - snapped and installed certbot, `certbot plugins` failed as expected. - snapped and installed certbot-dns-dnsimple, `sudo certbot plugins --prepare` succeeded - Inspected dns plugin's `bin` and `lib`; no `certbot` or `acme`, as expected. ``` $ ls /snap/certbot-dns-dnsimple/current/lib/python3.6/site-packages/ OpenSSL future-0.18.2.dist-info requests_file.py PyYAML-5.3.1.dist-info idna setuptools _cffi_backend.cpython-36m-x86_64-linux-gnu.so idna-2.9.dist-info setuptools-47.3.1.dist-info certbot_dns_dnsimple lexicon six-1.15.0.dist-info certbot_dns_dnsimple-1.6.0.dev0-py3.6.egg-info libfuturize six.py certifi libpasteurize tldextract certifi-2020.4.5.1.dist-info past tldextract-2.2.2.dist-info cffi pip urllib3 cffi-1.14.0.dist-info pip-20.1.1.dist-info urllib3-1.25.9.dist-info chardet pkg_resources wheel chardet-3.0.4.dist-info pyOpenSSL-19.1.0.dist-info wheel-0.34.2.dist-info cryptography pycparser yaml cryptography-2.8.dist-info pycparser-2.20.dist-info zope dns_lexicon-3.3.26.dist-info requests zope.interface-5.1.0-py3.6-nspkg.pth easy_install.py requests-2.23.0.dist-info zope.interface-5.1.0.dist-info future requests_file-1.5.1.dist-info $ ls /snap/certbot-dns-dnsimple/current/bin/ chardetect futurize lexicon pasteurize tldextract ``` - reset to HEAD^ - snapped and installed certbot to not have the DNSAuthenticator2 changes, `certbot plugins` failed as expected. * Don't include certbot deps when EXCLUDE_CERTBOT_DEPS is set * Set EXCLUDE_CERTBOT_DEPS in certbot-dns-dnsimple/snap/snapcraft.yaml --- certbot-dns-dnsimple/setup.py | 11 +++++++++-- certbot-dns-dnsimple/snap/snapcraft.yaml | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/certbot-dns-dnsimple/setup.py b/certbot-dns-dnsimple/setup.py index 9ba71a7ea..6efebcd41 100644 --- a/certbot-dns-dnsimple/setup.py +++ b/certbot-dns-dnsimple/setup.py @@ -12,12 +12,19 @@ version = '1.6.0.dev0' # Remember to update local-oldest-requirements.txt when changing the minimum # acme/certbot version. install_requires = [ - 'acme>=0.31.0', - 'certbot>=1.1.0', 'setuptools', 'zope.interface', ] +if not os.environ.get('EXCLUDE_CERTBOT_DEPS'): + install_requires.extend([ + 'acme>=0.31.0', + 'certbot>=1.1.0', + ]) +elif 'bdist_wheel' in sys.argv[1:]: + raise RuntimeError('Unset EXCLUDE_CERTBOT_DEPS when building wheels ' + 'to include certbot dependencies.') + setuptools_known_environment_markers = (StrictVersion(setuptools_version) >= StrictVersion('36.2')) if setuptools_known_environment_markers: install_requires.append('mock ; python_version < "3.3"') diff --git a/certbot-dns-dnsimple/snap/snapcraft.yaml b/certbot-dns-dnsimple/snap/snapcraft.yaml index 273fc3f56..64be45436 100644 --- a/certbot-dns-dnsimple/snap/snapcraft.yaml +++ b/certbot-dns-dnsimple/snap/snapcraft.yaml @@ -15,6 +15,8 @@ parts: override-pull: | snapcraftctl pull snapcraftctl set-version `grep ^version $SNAPCRAFT_PART_SRC/setup.py | cut -f2 -d= | tr -d "'[:space:]"` + build-environment: + - EXCLUDE_CERTBOT_DEPS: "True" slots: certbot: