Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Make Python bridge the default #19246

Merged
merged 4 commits into from
Sep 8, 2023

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Aug 26, 2023

Replace --enable-pybridge with --enable-old-bridge, and flip the logic. That way, it will slowly disappear as old distro releases become unsupported. This also means that builders from upstream now get the Python bridge by default.

Keep the unit tests running with the C bridge for the time being, to exercise it with multiple architectures/compilers/valgrind.

https://issues.redhat.com/browse/COCKPIT-1037

@martinpitt martinpitt force-pushed the pybridge-default branch 2 times, most recently from 0006cee to a7c9885 Compare August 26, 2023 08:22
@martinpitt martinpitt added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Aug 26, 2023
@martinpitt martinpitt removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Aug 26, 2023
@martinpitt martinpitt marked this pull request as ready for review August 26, 2023 09:31
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, and agreed in principle. Please see comments.

Makefile.am Show resolved Hide resolved
tools/cockpit.spec Outdated Show resolved Hide resolved
pkg/Makefile.am Show resolved Hide resolved
jelly

This comment was marked as resolved.

@martinpitt martinpitt added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Aug 28, 2023
@martinpitt

This comment was marked as resolved.

@jelly

This comment was marked as resolved.

@martinpitt
Copy link
Member Author

@allisonkarlitskaya Still no-test, but the unit tests work. Would you mind doing another round of review before I re-enable the full impact of integration tests? Danke!

@martinpitt martinpitt marked this pull request as ready for review September 4, 2023 07:08
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and the XXX commit, obviously ;)

src/Makefile.am Outdated Show resolved Hide resolved
@martinpitt martinpitt removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Sep 4, 2023
@martinpitt martinpitt added the .github-changes Set by a reviewer just before landing to acknowledge that a PR changes github workflows label Sep 4, 2023
@@ -13,6 +13,9 @@ WORKDIR /home/builder

ENV LANG=C.UTF-8

# HACK: unbreak distcheck on Debian: https://bugs.debian.org/1035546
ENV DEB_PYTHON_INSTALL_LAYOUT=deb
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@allisonkarlitskaya allisonkarlitskaya Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I've wrapped my head around this situation properly then it also means that something like this, for example:

./configure
make
sudo make install

would result in Cockpit getting installed into /usr/local/local/ on Debian ...

Copy link
Member

@allisonkarlitskaya allisonkarlitskaya Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crux of the issue is that although sysconfig has a check for situations where the prefix is not the same as the base prefix (ie: venvs) it doesn't consider pip's --prefix flag when applying this logic...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notes for myself:

  • check the sudo make install behaviour from above
  • possibly: toss away pip install and install the wheel ourselves; create single-line wrappers for cockpit-{bridge,askpass,beiboot} in our tree and install via scripts directory; use #!/usr/bin/env python3 hashbangs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed a make install DESTDIR=/tmp/i in Debian creates /tmp/i/usr/local/local/lib/python3.11, and /tmp/i/usr/local/local/bin/cockpit-{bridge,askpass,beiboot} as we suspected.

I tried to convert to python3-installer:

--- src/Makefile.am
+++ src/Makefile.am
@@ -26,7 +26,7 @@ install-python:
        @# wheel-based installation with .dist-info.
        @# This needs to work on RHEL8 up through modern Fedora, offline, with
        @# system packages available to the build.
-       python3 -m pip install --no-index --force-reinstall --root='$(DESTDIR)/' --prefix='$(prefix)' \
+       python3 -m installer --destdir='$(DESTDIR)/' --prefix='$(prefix)' \
                "$$(python3 '$(srcdir)'/src/build_backend.py --wheel '$(srcdir)' tmp/wheel)"
        mkdir -p $(DESTDIR)$(libexecdir)
        mv -t $(DESTDIR)$(libexecdir) $(DESTDIR)$(bindir)/cockpit-askpass $(DESTDIR)$(bindir)/cockpit-beiboot

and it has the same problem. That's unsurprising, as the offending patch is in Debian's cpython, not in pip.

@martinpitt
Copy link
Member Author

@allisonkarlitskaya AFAICS we need to pick one of these:

  1. re-drop the distcheck with the python bridge, and only test with C bridge (not a way forward into the future)
  2. go with the DEB_PYTHON_INSTALL_LAYOUT hack; possibly refine it a bit (not sure how, though)
  3. write our own wheel installer and hack around Debian's cpython install patch (I don't want to do this -- this is awful and wrong)
  4. Drop testing on i386 and move unit tests to Fedora

My proposal would be 2. (i.e. this PR as-is) and I'll do a follow-up for 4. (which will drop the hack). Or if you prefer, 4. first and then this PR without the _LAYOUT hack. WDYT?

@allisonkarlitskaya
Copy link
Member

allisonkarlitskaya commented Sep 5, 2023

I'm fine with 2 as well, but what about the broken make install on Debian? Or do we care? It's their bug, after all...

@martinpitt
Copy link
Member Author

Yeah, it'll fail on "cockpit-askpass not found", but what can you do.. We ship stable and backported cockpit packages in the distro, and even provide a mechanism to build debs from upstream. So far nobody has complained, and I'd only like to go that far in trying to work around this.

This has to go through SSH authentication and remote page loading, which
occasionally takes more than 15s on loaded CI infrastructure.
This simplifies the hack: We no longer need the temporary symlink dance,
but let the upstream build system put the Python module directly into
the distro target path that `dh_python` will use anyway.
Fixes distcheck when configuring for with the Python bridge.

This also needs to remove tmp/wheel/, as otherwise it counts as a
leftover file in the source tree with `make distcheck`.
Replace --enable-pybridge with --enable-old-bridge, and flip the logic.
That way, it will slowly disappear as old distro releases become
unsupported. This also means that builders from upstream now get the
Python bridge by default.

The distcheck scenarios now apply to the Python bridge. Add a
`$DEB_PYTHON_INSTALL_LAYOUT` hack to work around
https://bugs.debian.org/1035546 to unbreak the installation of the
generated wrapper binaries, as by default they'd go into
prefix/usr/local/bin on Debian.

Add a new distcheck scenario for the C bridge, to ensure that we don't
break that.

https://issues.redhat.com/browse/COCKPIT-1037
@github-actions github-actions bot removed the .github-changes Set by a reviewer just before landing to acknowledge that a PR changes github workflows label Sep 8, 2023
@martinpitt martinpitt added the .github-changes Set by a reviewer just before landing to acknowledge that a PR changes github workflows label Sep 8, 2023
# HACK: Debian's pip breaks --prefix: https://bugs.debian.org/1035546 with
# default install layout
override_dh_auto_install:
DEB_PYTHON_INSTALL_LAYOUT=deb dh_auto_install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks.

@martinpitt martinpitt merged commit 14c07d7 into cockpit-project:main Sep 8, 2023
34 of 35 checks passed
@martinpitt martinpitt deleted the pybridge-default branch September 8, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.github-changes Set by a reviewer just before landing to acknowledge that a PR changes github workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants