Commit graph

87 commits

Author SHA1 Message Date
Will Greenberg
ebcdf54025 test w/ fewer env vars 2024-07-18 14:18:42 -07:00
Erica Portnoy
efb0379264 unstage pyvenv.cfg 2024-07-18 13:43:45 -07:00
Erica Portnoy
48af4e83e3 we're missing some import so let's just throw pip and wheel back in 2024-07-18 13:22:18 -07:00
Erica Portnoy
566aae8645 clean snapcraft even more 2024-07-18 11:52:36 -07:00
Erica Portnoy
25eef6c739 clean up snapcraft.yaml 2024-07-18 11:46:39 -07:00
Erica Portnoy
6056dd716c update PYTHONPATH with lib-dynload to resolve 'circular import error' 2024-07-18 11:18:05 -07:00
Erica Portnoy
15e880ac14 unset pythonhome 2024-07-17 15:18:04 -07:00
Erica Portnoy
4706f0e033 ok stage venv 2024-07-17 15:08:29 -07:00
Erica Portnoy
b31b9466f1 venv to build packages 2024-07-17 15:03:48 -07:00
Erica Portnoy
def2257b56 remove some staged packages 2024-07-17 14:54:28 -07:00
Erica Portnoy
bcafe32383 double specify path 2024-07-17 10:53:56 -07:00
Erica Portnoy
a8e6753a00 add pythonpath like ubuntu does 2024-07-16 18:03:32 -07:00
Erica Portnoy
bdd392d5b1 why are we manually creating the venv anyway? 2024-07-16 17:37:29 -07:00
Erica Portnoy
5c2a1dc804 trying more things 2024-07-16 17:25:41 -07:00
Erica Portnoy
2003619adc bin python3 2024-07-16 14:53:51 -07:00
Erica Portnoy
d2811f7723 even more path 2024-07-16 14:50:37 -07:00
Erica Portnoy
e640437ac1 what do we do when things don't work? that's right, we expand the path 2024-07-16 14:49:49 -07:00
Erica Portnoy
ba78020291 can we use print statements lol 2024-07-16 14:47:14 -07:00
Erica Portnoy
ad28b3c32b try adding the top level paths why not 2024-07-16 13:58:46 -07:00
Erica Portnoy
5572989047 different pythonpath 2024-07-16 12:50:41 -07:00
Erica Portnoy
12f2fb8155 remove incorrect workarounds 2024-07-16 12:47:30 -07:00
Erica Portnoy
275ed31c4b add libs as well 2024-07-16 12:07:41 -07:00
Erica Portnoy
d9c77d8c5d more workarounds! 2024-07-16 12:06:30 -07:00
Erica Portnoy
56ed69dc07 comment out python home and path 2024-07-16 11:53:21 -07:00
Erica Portnoy
3ef0ed6fd7 back to 3.12 2024-07-16 11:38:10 -07:00
Erica Portnoy
2e7049a8c3 3.10 for core22 2024-07-16 11:28:11 -07:00
Erica Portnoy
d8754a167e does it break on core22? 2024-07-16 11:16:05 -07:00
Erica Portnoy
5f406e4560 put back usr/lib/python3.12 2024-07-15 16:18:14 -07:00
Erica Portnoy
9fb63e4f82 venv build dep? 2024-07-15 16:14:22 -07:00
Erica Portnoy
51e67bcdaf put PYTHONHOME back 2024-07-15 16:09:03 -07:00
Erica Portnoy
fe1c9858f5 update PYTHONPATH as in e98ae54389/snap/snapcraft.yaml (L13C15-L13C103) 2024-07-15 16:05:33 -07:00
Erica Portnoy
3393423f98 add pythonhome and pythonpath 2024-07-15 15:53:44 -07:00
Erica Portnoy
37aac767f6 stage python3.12-venv 2024-07-15 15:31:55 -07:00
Erica Portnoy
233e5ac36d migrate variable names 2024-07-12 15:40:54 -07:00
Erica Portnoy
b8a120df45 Migrate primary certbot snap to core24 and python 3.12 2024-06-21 10:31:06 -07:00
Brad Warren
5149dfd96e
Add some missing type libraries for mypy (#9657)
* add some missing types

* install pkg-config

* install pkg-config for docker too

* add pkg-config to plugins

* pkg-config when cryptography may need to be built

* deps cleanup

* more comments

* more tweaks
2023-04-09 11:49:08 +10:00
Brad Warren
b95deaa7e4
Use the git CLI with cargo (#9223)
Hopefully this makes things more stable. This is based on Alex's suggestion [here](https://opensource.eff.org/eff-open-source/pl/ouf996zuxjnkdxwq81bihxak7e). 

* git cli in docker

* git cli in snap

* git cli in dns snaps

* use true strings
2022-03-02 12:10:01 -08:00
alexzorin
8ff7153019
snap: revert to checking snapctl file existence (#9018)
While the previous approach of testing the functionality of snapctl
worked, the snapd developers told us they could not guarantee its
reliability.

---

As with #8955, I tested this on Debian 9, 10 and CentOS 7, 8, Stream.
2021-09-03 07:47:12 -07:00
alexzorin
bdc48e6a32
snap: workaround for snapctl crash in plugin hook (#8955)
* snap: workaround for snapctl crash in plugin hook

* test functionality, not existence
2021-08-02 16:15:46 -07:00
Brad Warren
f4fc3e636d
Redo the majority of Certbot's pinning system (#8741)
* add initial pyproject.toml

* add extra dependencies

* add simple bash script

* polish

* reuse pipstrap

* add requirements.txt

* temporarily remove hashin dep

* Switch to requirements.txt

* remove hashin check

* update requirements.txt again

* remove unnecessary merge

* pin back augeas

* unpin cryptography

* simplify pywin32 pinning

* update comment

* pin back pytest and pylint

* pin back pytest-forked

* pin back coverage

* update script comments

* fix pyopenssl case

* add minimum poetry version

* run pin.sh
2021-03-26 07:51:59 +01:00
ohemorange
f90e93134c
Upgrade cryptography to 3.4.6 (#8730)
* Upgrade cryptography to 3.4.6

* Fix comment with instructions for how to use hashin

* run tools/rebuild_certbot_constraints.py

* add deps for building cryptography in snaps

* Update cryptography build dependencies for docker

* Update sources for test farm tests

* Remove rust if it's installed for test farm tests

* source bootstrap script and call sudo as needed
2021-03-24 10:29:12 -07:00
Adrien Ferrand
c3d6fca3eb
Make certbot constraint file independent from certbot-auto + update cryptography (#8649)
* Refactor to not depend on certbot-auto dependencies pinning anymore

* Update constraints

* Replaces references

* Upgrade AWS dependencies pinning

* Fix script

* Fix Windows installer builds

* Fixing sdists letstest script

* Pin cryptography on 3.1.1 specifically for RHEL/CentOS 7 to avoid build failures during test_sdists test.

* Finish fix

* Fix VERSION_ID in RHEL 7
2021-02-23 15:29:52 -08:00
Adrien Ferrand
d38766e05c
Enable again build isolation with proper pinning of build dependencies (#8443)
Fixes #8256

First let's sum up the problem to solve. We disabled the build isolation available in pip>=19 because it could potential break certbot build without a control on our side. Basically builds are not reproductible. Indeed the build isolation triggers build of PEP-517 enabled transitive dependencies (like `cryptography`) with the build dependencies defined in their `pyproject.toml`. For `cryptography` in particular these requirements include `setuptools>=40.6.0`, and quite logically pip will install the latest version of `setuptools` for the build. And when `setuptools` broke with the version 50, our build did the same.

But disabling the build isolation is not a long term solution, as more and more project will migrate on this approach and it basically provides a lot of benefit in how dependencies are built.

The ideal solution would be to be able to apply version constraints on our side on the build dependencies, in order to pin `setuptools` for instance, and decide precisely when we upgrade to a newer version. However for now pip does not provide a mechanism for that (like a `--build-constraint` flag or propagation of existing `--constraint` flag).

Until I saw https://github.com/pypa/pip/issues/9081 and https://github.com/pypa/pip/issues/8439.

Apart the fact that https://github.com/pypa/pip/issues/9081 shows that pip maintainers are working on this issue, it explains how pip works regarding PEP-517 and infers which workaround can be used to still pin the build dependencies. It turns out that pip invokes itself in each build isolation to install the build dependencies. It means that even if some flags (like `--constraint`) are not explicitly passed to the pip sub call, the global environment remains, in particular the environment variables.

Thus it is known that every pip flag can alternatively be set by environment variable using the following pattern for the variable name: `PIP_[FLAG_NAME_UPPERCASE]`. So for `--constraint`, it is `PIP_CONSTRAINT`. And so you can pass a constraint file to the pip sub call through that mechanism.

I made some tests with a constraint file containing pinning for `setuptools`: indeed under isolation zone, the constraint file has been honored and the provided pinned version has been used to build the dependencies (I tested it with `cryptography`).

Finally this PR takes advantage of this mechanism, by setting `PIP_CONSTRAINT` to `pip_install`, the snap building process, the Dockerfiles and the windows installer building process.

I also extracted out the requirements of the new `pipstrap.py` to be reusable in these various build processes.

* Use workaround to fix build requirements in build isolation, and renable build isolation

* Clean imports in pipstrap

* Externalize pipstrap reqs to be reusable

* Inject pipstrap constraints during pip_install

* Update docker build

* Update snapcraft build

* Prepare installer build

* Fix pipstrap constraints in snap build

* Add back --no-build-cache option in Docker images build

* Update snap/snapcraft.yaml

* Use proper flags with pip

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2020-12-16 10:49:31 -08:00
Adrien Ferrand
878c3e396f
Avoid --system-site-packages during the snap build by preparing a venv with pipstrap that already includes wheel (#8445)
This PR proposes an alternative configuration for the snap build that avoid the need to use `--system-site-package` when constructing the virtual environment in the snap.

The rationale of `--system-site-package` was that by default, snapcraft creates a virtual environment without `wheel` installed in it. However we need it to build the wheels like `cryptography` on ARM architectures. Sadly there is not way to instruct snapcraft to install some build dependencies in the virtual environment before it kicks in the build phase itself, without overriding that entire phase (which is possible with `parts.override-build`).

The alternative proposed here is to not override the entire build part, but just add some preparatory steps that will be done before the main actions handled by the `python` snap plugin. To do so, I take advantage of the `--upgrade` flag available for the `venv` module in Python 3. This allows to reuse a preexisting virtual environment, and upgrade its component. Adding a flag to the `venv` call is possible in snapcraft, thanks to the `SNAPCRAFT_PYTHON_VENV_ARGS` environment variable (and it is already used to set the `--system-site-package`).

Given `SNAPCRAFT_PYTHON_VENV_ARGS` set to `--upgrade` , we configure the build phase as follows:
* create the virtual environment ourselves in the expected place (`SNAPCRAFT_PART_INSTALL`)
* leverage `tools/pipstrap.py` to install `setuptools`, `pip`, and of course, `wheel`
* let the standard build operations kick in with a call to `snapcraftctl build`: at that point the `--upgrade` flag will be appended to the standard virtual environment creation, reusing our crafted venv instead of creating a new one.

This approach has also the advantage to invoke `pipstrap.py` as it is done for the other deployable artifacts, and for the PR validations, reducing risks of shifts between the various deployment methods.
2020-12-10 12:05:32 -08:00
alexzorin
dc3ac13750
snap: disable the "user site-packages directory" (#8509)
Although Certbot is a classic snap, it shouldn't load Python code from
the host system. This change prevents packages being loaded from the
"user site-packages directory" (PEP-370). i.e. Certbot will no longer
load DNS plugins installed via `pip install --user certbot-dns-*`.
2020-12-06 09:10:03 +01:00
Brad Warren
cc76906712
Set Certbot snap version from __init__.py (#8344)
Fixes https://github.com/certbot/certbot/issues/8166 following the feedback in https://github.com/certbot/certbot/pull/8337.

I took the command to get Certbot's version from: ef8c481634/snap/snapcraft.yaml (L90)

You can see the snap tests passing with this change at https://dev.azure.com/certbot/certbot/_build/results?buildId=2785&view=results.
2020-10-05 08:37:01 -07:00
Adrien Ferrand
7f0fa18c57
Refactor certbot snap wrapper (#8313)
Partial fix for #8280

This PR refactors the bash script wrapper for snap (`/certbot.wrapper`) into certbot python codebase. Here are the keypoints of this refactoring:
* the wrapping is applied when `main` function from `certbot._internal.main` is called if environment variable `CERTBOT_SNAPPED` is `True`, which is set during the snap build
* the initial bash script wrapper  is removed, simplifying `snap/snapcraft.yaml` by removing the `certbot.wrapper` part
* the dependency to `curl` and `jq` binaries are removed
* the failure during requesting the snapd socket is correctly handled, and displays an informative message in order to correct the situation, as required by #8280

One side note about the modifications done to `app.certbot.command` in `snapcraft.yaml`. Normally calling `bin/certbot` should be sufficient and it is effectively under a normal situation (`core` snap up-to-date). However in the same situation than when the problem occurs in #8280, using `bin/certbot` makes the snap raise an exception about `certbot.main` module that cannot be found.

It seems that when `core` snap is not up-to-date (in Debian for instance with default `snapd` installation), the shebang `/usr/bin/env python3` in the `bin/certbot` wrapper is wrongly resolved to the host Python, instead of the snap Python. It is working as expected if `core` snap is up-to-date. One way to fix that is to keep a bash script wrapper, because in this case, it is the `PATH` value that matters to resolve the Python interpreter, and `PATH` is correctly set up to resolve it from the snap first.

However to keep the simplification provided by the wrapper removal, I prefered to use `bin/python3 $SNAP/bin/certbot` as `command` to explicitly target the correct Python interpreter. Again normally it is not needed because everything is working correctly with a `core` snap up-to-date, but since the root purpose of all of this is to target bad situations, well, it is better to have a snap that is effectively able to start to display the informative message...

* Refactor the bash wrapper for snap execution as Python code into certbot

* Remove wrapper, finalize the python logic

* Organize code

* Improve error handling

* Update command

* Setup basic certbot logging before running the snap prepare logic

* Improve instructions

* Use logging facility

* Handle properly an exception in snap_config

* Use the python script call approach

* Update instructions to keep sync with https://github.com/certbot/website/pull/650
2020-09-30 13:24:56 -07:00
ohemorange
fca7ec896a
Improve error message for prepare-plug-plugin hook when certbot isn't installed (#8338)
Provides a partial fix for #8182 by improving the error message.
2020-09-30 12:43:24 -07:00
alexzorin
2ceabadb81
snap: use snap REST API in certbot.wrapper (#8260)
In order to avoid potentially breaking changes in the snap CLI on the
host, this commit changes certbot.wrapper to use the snap REST API (via
curl and jq) to list connected Certbot plugins.
2020-09-04 23:55:21 +02:00
alexzorin
a2951b4db1
snap: Fix "stack smashing" error in wrapper (#8249)
* snap: Fix "stack smashing" error in wrapper

certbot.wrapper had implicit dependencies on sed, awk and coreutils,
which were being accidentally provided through the host system. Because
certbot.wrapper modifies LD_LIBRARY_PATH, this was causing some systems
to load an incompatible combination of shared libraries, resulting sed
crashing.

This commit reduces the dependencies of this script to just gawk, and
explicitly stages it as part of the Certbot snap.

It additionally moves invocations of all host system programs to a
moment prior to the modification of LD_LIBRARY_PATH, and the invocation
of snapped programs to after the modification.

Fixes #8245

* snap: Don't modify LD_LIBRARY_PATH

* leftover tracing

* snap: revert curl/jq in wrapper, use gawk for now
2020-09-04 20:51:01 +02:00