sapling/ci
Michael Bolin 11f0412245 write "Depends" into .deb and build for Python 3.10 on Ubuntu 22.04
Summary:
Although D39042765 (a04fc2e9b3) appeared to successfully produce `.deb` files, it turns
out that they would only work if you already had the requisite package
dependencies installed. For example, running `hg --version` on a clean
Ubuntu instance would yield:

```
hg: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
```

It turned out that our `DEBIAN/control` file was missing a key `Depends:` line
to tell `dpkg` what dependencies to install. Once again, I decided to look and
see how wezterm deals with this, and the solution appears to be `dpkg-shlibdeps`:

https://github.com/wez/wezterm/blob/97eaa58112a4/ci/deploy.sh#L234,L240

`dpkg-shlibdeps` looks at your executables and, based on the symbols, determines
what the appropriate packages are. For our Ubuntu 22.04 `.deb`, this turns out to be:

```
Depends: libc6 (>= 2.34), libgcc-s1 (>= 4.2), libpython3.10 (>= 3.10.0), libssl3 (>= 3.0.0~~alpha1), zlib1g (>= 1:1.1.4)
```

Apparently you cannot have a package in the `Depends:` line that comes from a PPA,
so if you want to make your `.deb` easy for users to install, that means you should
limit your dependencies to "standard" packages for the distro. In our case, that meant
that our Ubuntu 22.04 `.deb` should use Python 3.10 instead of Python 3.8 (which we
previously fetched from `ppa:deadsnakes/ppa`).

In order to support this, this diff makes a number of changes:

- Adds logic to `setup.py` to check the `PY_VERSION` environment variable to decide
  whether to use Python 3.10 or something else.
- Updates `gen_workflows.py` to define different Python deps based on the Ubuntu version.
- Updates `gen_workflows.py` to remove the logic that uses the `ppa:deadsnakes/ppa`.
- Ran `buck2 run //eden/oss/ci:gen_workflows -- eden/oss/.github/workflows/` to update the GitHub Actions
- Moved the logic for the `deb` target in the `Makefile` into a separate shell script because
  it was getting too complex to express directly in Make.
- Introduced separate `deb-ubuntu-20.04` and `deb-ubuntu-22.04` targets in the `Makefile`.
- Updated `bytearrayobject.rs` to support Python 3.10 in addition to Python 3.9.
- Updated `pick_python.py` to consider `python3.10` if `python3.8` is not found before going
  down the rest of the list.

As you can see in the Test Plan, we are *really close* to things "just working," but we also have
to register `git` as a dependency, which is not discovered by `dpkg-shlibdeps`. This will be
addressed in D39156794.

Reviewed By: DurhamG

Differential Revision: D39156794

fbshipit-source-id: ca1e0a73096e0de97230804a97f316114b8bfc2e
2022-08-31 15:00:05 -07:00
..
create-release.sh create code generator for GitHub actions 2022-08-30 15:37:50 -07:00
gen_workflows.py write "Depends" into .deb and build for Python 3.10 on Ubuntu 22.04 2022-08-31 15:00:05 -07:00
retry.sh create code generator for GitHub actions 2022-08-30 15:37:50 -07:00
tag-name.sh create code generator for GitHub actions 2022-08-30 15:37:50 -07:00