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

libglib: split libraries from glib #103366

Closed
wants to merge 3 commits into from

Conversation

XuehaiPan
Copy link
Contributor

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Include glib and libglib formulae only in

The remaining formulae that depend on glib will be migrated in separate PRs.

@BrewTestBot BrewTestBot added the automerge-skip `brew pr-automerge` will skip this pull request label Jun 10, 2022
Formula/glib.rb Outdated
Comment on lines 69 to 81
def post_install
(HOMEBREW_PREFIX/"lib/gio/modules").mkpath
libglib = Formula["libglib"]
include.make_relative_symlink(libglib.opt_include)
lib.make_relative_symlink(libglib.opt_lib)
end
Copy link
Contributor Author

@XuehaiPan XuehaiPan Jun 10, 2022

Choose a reason for hiding this comment

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

Make symlinks to let the downstream formula access Formula["glib"].opt_include and Formula["glib"].opt_lib. These symlinks will be removed when the migration is done.

@carlocab
Copy link
Member

This approach doesn't work, because it requires writing to paths outside glib's keg, which is disallowed by the sandbox. That's why the build fails on macOS.

@XuehaiPan XuehaiPan force-pushed the split-glib branch 3 times, most recently from 6a01942 to 8f92ad3 Compare June 12, 2022 17:26
Formula/glib.rb Outdated
Comment on lines 33 to 48
def script
<<~EOS
import pickle as pkl
from mesonbuild.minstall import load_install_data
installdata = load_install_data('meson-private/install.dat')
for attrname in ('data', 'emptydir', 'headers', 'install_scripts', 'install_subdirs', 'man', 'symlinks', 'targets'):
attr = getattr(installdata, attrname)
attr = list(filter(lambda data: all('opt/libglib' not in dataattr
for _, dataattr in vars(data)
if isinstance(dataattr, str)),
attr))
setattr(installdata, attrname, attr)
with open('meson-private/install.dat', mode='wb') as file:
pkl.dump(file, installdata)
EOS
end
Copy link
Contributor Author

@XuehaiPan XuehaiPan Jun 12, 2022

Choose a reason for hiding this comment

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

This approach would be really hacky that modifies a binary file created by meson (created by pickle.dump from Python). I have read the source code of meson, I don't find any other way to do this.

The file targets can be ignored by changing the mtime of files (make them older than those files in libglib). But there are also some symlinks in which we cannot do the same things. Then it will raise PermissionError due to sandboxing.

The only way to not write things to libglib is overwriting the install data of meson.

@XuehaiPan XuehaiPan force-pushed the split-glib branch 4 times, most recently from 6eae317 to 0b4384f Compare June 13, 2022 12:25
@XuehaiPan
Copy link
Contributor Author

Require CI-long-timeout.

Formula/libglib.rb Outdated Show resolved Hide resolved
Formula/libglib.rb Outdated Show resolved Hide resolved
Comment on lines +26 to +28
# TODO: This is a workaround for `brew audit --new-formula`.
# Use `patch` rather than `inreplace` (see also `glib`).
# replace several hardcoded paths with homebrew counterparts
Copy link
Member

Choose a reason for hiding this comment

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

Please don't work around the audits. They are there for a reason.

Formula/libglib.rb Show resolved Hide resolved
Formula/libglib.rb Outdated Show resolved Hide resolved
@XuehaiPan XuehaiPan force-pushed the split-glib branch 2 times, most recently from 66b346a to 899d783 Compare June 14, 2022 09:52
@alebcay alebcay added long build Set a long timeout for formula testing CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. labels Jun 14, 2022
@chenrui333
Copy link
Member

some test failures

brew test --retry --verbose glib-networking
brew test --retry --verbose glib-openssl
brew test --retry --verbose libsoup
brew test --retry --verbose libsoup@2

@chenrui333 chenrui333 added CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. and removed CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. labels Jun 15, 2022
@iMichka
Copy link
Member

iMichka commented Jun 15, 2022

I'm in favour of the split. I wanted to work on something similar, inspired by https://uwekorn.com/2020/10/19/r-without-python.html.

I am wondering if we could reduce the scope of the split. What is our goal here? Reduce the complexity of the Python dependency tree? In this case, I think there are only 2-3 python scripts in bin that need to be extracted to a separate formula (glib and glib-utils like gentoo does, for example).

@danielnachun danielnachun mentioned this pull request Jun 15, 2022
6 tasks
@XuehaiPan
Copy link
Contributor Author

I am wondering if we could reduce the scope of the split. What is our goal here? Reduce the complexity of the Python dependency tree? In this case, I think there are only 2-3 python scripts in bin that need to be extracted to a separate formula (glib and glib-utils like gentoo does, for example).

@iMichka, do you mean ship binary executables in libglib and only keep the Python scripts in glib?

The current implementation of the split in this PR:

  • libglib: only ships headers and shared libraries (include and lib).
  • glib: ships all executables (bin), completions (etc/bash_completion.d), locale settings (share/locale), and Python scripts (share/*).

@iMichka
Copy link
Member

iMichka commented Jun 16, 2022

@iMichka, do you mean ship binary executables in libglib and only keep the Python scripts in glib?

Yes.

Just to avoid any confusion, here is your proposal:
glib -> libglib (headers and libraries)
glib -> glib (all binaries, share, ...)

Here is my proposal:
glib -> glib-utils (Python binaries only)
glib -> glib (everything else)

@SMillerDev
Copy link
Member

I think the libglib/glib split is easier and cleaner to maintain.

It might be better to add a libglib formula first, migrate and after link glib to it though.

@XuehaiPan
Copy link
Contributor Author

XuehaiPan commented Jun 16, 2022

Here is my proposal:
glib -> glib-utils (Python binaries only)
glib -> glib (everything else)

This seems easier to implement and requires less migration effort. There are only three places contain Python scripts (bin / share/glib-2.0/codegen / share/gdb). However, in the future release, the upstream may add more Python code. We should recursively glob the directory to find Python scripts rather than use arbitrary paths.

@danielnachun
Copy link
Member

danielnachun commented Jun 16, 2022

We've also been discussing this on Slack and I think I like what @iMichka proposed for glib/glib-utils. While we will have to pay attention if upstream does add Python code elsewhere, we can just use globbing as @XuehaiPan suggested to find and remove Python scripts in glib, and then make sure we install those in glib-utils.

If you look at the Gentoo ebuild for glib-utils it's very simple to reimplement as a formula in Ruby: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/glib-utils/glib-utils-2.72.2.ebuild. Basically just a few inreplace statements instead of sed and some calls to xsltproc. Given how much of a headache glib is currently causing for Python migrations, I think this would be the simplest route to dealing with this.

@XuehaiPan
Copy link
Contributor Author

Closed in favor of PR #103916.

@XuehaiPan XuehaiPan closed this Jun 17, 2022
@XuehaiPan XuehaiPan deleted the split-glib branch June 23, 2022 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge-skip `brew pr-automerge` will skip this pull request CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. long build Set a long timeout for formula testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants