grimme-lab/homebrew-qc

Build error for mctc-lib

Closed this issue ยท 12 comments

I'm getting a build error related to mctc-lib. Don't have much experience with homebrew troubleshooting, so please let me know if you need more info.

(base) kjelljorner@mba-m1-kjell-jorner xtb-python % brew install mctc-lib
==> Downloading https://github.com/grimme-lab/mctc-lib/archive/v0.3.0.tar.gz
Already downloaded: /Users/kjelljorner/Library/Caches/Homebrew/downloads/91e3a60a0caa095fda13fe68210c78d9a36a070b7bfa7708568d3c4b3f2ca45e--mctc-lib-0.3.0.tar.gz
==> Installing mctc-lib from grimme-lab/qc
==> Using Homebrew-provided Fortran compiler
This may be changed by setting the FC environment variable.
==> meson setup _build --prefix=/opt/homebrew/Cellar/mctc-lib/0.3.0 --libdir=/opt/homebrew/Cellar/mctc-lib/0.3.0/lib --buildtype=release --wrap-mode=nofallback
==> meson compile -C _build
==> meson test -C _build --no-rebuild --num-processes 1
==> meson install -C _build --no-rebuild
Last 15 lines from /Users/kjelljorner/Library/Logs/Homebrew/mctc-lib/04.meson:

Installing libmctc-lib.0.dylib to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib
Installing libmctc-lib.a to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib
Installing app/mctc-convert to /opt/homebrew/Cellar/mctc-lib/0.3.0/bin
Installing /private/tmp/mctc-lib-20220523-95769-e1ftn4/mctc-lib-0.3.0/_build/mctc-convert.1 to /opt/homebrew/Cellar/mctc-lib/0.3.0/share/man/man1
Installing /private/tmp/mctc-lib-20220523-95769-e1ftn4/mctc-lib-0.3.0/LICENSE to /opt/homebrew/Cellar/mctc-lib/0.3.0/share/licenses/mctc-lib
Installing /private/tmp/mctc-lib-20220523-95769-e1ftn4/mctc-lib-0.3.0/_build/meson-private/mctc-lib.pc to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib/pkgconfig
Installing symlink pointing to libmctc-lib.0.dylib to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib/libmctc-lib.dylib
Running custom install script '/private/tmp/mctc-lib-20220523-95769-e1ftn4/mctc-lib-0.3.0/config/install-mod.py include/mctc-lib/gcc-11.3.0'
--- stdout ---

--- stderr ---
env: python: No such file or directory

FAILED: install script '/private/tmp/mctc-lib-20220523-95769-e1ftn4/mctc-lib-0.3.0/config/install-mod.py include/mctc-lib/gcc-11.3.0' exit code 127, stopped

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/grimme-lab/homebrew-qc/issues

I'm having the exact same problem here:

โžœ  ~ brew install mctc-lib
==> Downloading https://github.com/grimme-lab/mctc-lib/archive/v0.3.0.tar.gz
Already downloaded: /Users/passos/Library/Caches/Homebrew/downloads/91e3a60a0caa095fda13fe68210c78d9a36a070b7bfa7708568d3c4b3f2ca45e--mctc-lib-0.3.0.tar.gz
==> Installing mctc-lib from grimme-lab/qc
==> Using Homebrew-provided Fortran compiler
This may be changed by setting the FC environment variable.
==> meson setup _build --prefix=/opt/homebrew/Cellar/mctc-lib/0.3.0 --libdir=/opt/homebrew/Cellar/mctc-lib/0.3.0/lib --buildtype=release
==> meson compile -C _build
==> meson test -C _build --no-rebuild --num-processes 1
==> meson install -C _build --no-rebuild
Last 15 lines from /Users/passos/Library/Logs/Homebrew/mctc-lib/04.meson:

Installing libmctc-lib.0.dylib to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib
Installing libmctc-lib.a to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib
Installing app/mctc-convert to /opt/homebrew/Cellar/mctc-lib/0.3.0/bin
Installing /private/tmp/mctc-lib-20220523-12024-i5ltc4/mctc-lib-0.3.0/_build/mctc-convert.1 to /opt/homebrew/Cellar/mctc-lib/0.3.0/share/man/man1
Installing /private/tmp/mctc-lib-20220523-12024-i5ltc4/mctc-lib-0.3.0/LICENSE to /opt/homebrew/Cellar/mctc-lib/0.3.0/share/licenses/mctc-lib
Installing /private/tmp/mctc-lib-20220523-12024-i5ltc4/mctc-lib-0.3.0/_build/meson-private/mctc-lib.pc to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib/pkgconfig
Installing symlink pointing to libmctc-lib.0.dylib to /opt/homebrew/Cellar/mctc-lib/0.3.0/lib/libmctc-lib.dylib
Running custom install script '/private/tmp/mctc-lib-20220523-12024-i5ltc4/mctc-lib-0.3.0/config/install-mod.py include/mctc-lib/gcc-11.3.0'
--- stdout ---

--- stderr ---
env: python: No such file or directory

FAILED: install script '/private/tmp/mctc-lib-20220523-12024-i5ltc4/mctc-lib-0.3.0/config/install-mod.py include/mctc-lib/gcc-11.3.0' exit code 127, stopped

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/grimme-lab/homebrew-qc/issues

These open issues may also help:
Build error for mctc-lib https://github.com/grimme-lab/homebrew-qc/issues/9

Problem is that meson cannot find a Python interpreter to run the install script for the modules:

https://github.com/grimme-lab/mctc-lib/blob/874680bb150b8e45f7f375db0af1847c77b086ae/config/install-mod.py#L1

However, having meson around kind of guarantees that there is a usable Python installation and we are running those builds on CI with MacOS/x86_64 successfully so far.

It seems to be an issue of python vs python3.

kjelljorner@mba-m1-kjell-jorner xtb-python % ls /opt/homebrew/bin/python*
/opt/homebrew/bin/python3          /opt/homebrew/bin/python3-config   /opt/homebrew/bin/python3.9        /opt/homebrew/bin/python3.9-config

It might be related to the recent removal of python2 from MacOS, which has probably not propagated to the CI runners.

Ah, I forgot there are still platforms where python is not Python 3. Creating a symlink from python to python3 should fix this, or we need to add a patch to all Formulas to adjust the shebang of the install script.

There appears to be some guidance in PEP 394. Maybe the most relevant paragraph is the one below.

When packaging third party Python scripts, distributors are encouraged to change less specific shebangs to more specific ones. This ensures software is used with the latest version of Python available, and it can remove a dependency on Python 2. The details on what specifics to set are left to the distributors; though. Example specifics could include:

  • Changing python shebangs to python3 when Python 3.x is supported.
  • Changing python shebangs to python2 when Python 3.x is not yet supported.
  • Changing python3 shebangs to python3.8 if the software is built with Python 3.8.

Alright then, patches are welcome ;).

Considering that meson requires python 3.7 or newer, would you consider changing the shebangs to
#!/usr/bin/env python3 to be acceptable?

Ok, I'll make some pull requests to the repos later today ๐Ÿ˜‰

Just to be clear - are we on the same page that this should be fixed at the source, i.e., the install-mod.py scripts of the original projects?

At least for some projects those are already fixed (dftd4/dftd4#118), patching those upstream will be useful going forward, but there won't be updated releases for all projects immediately, of course. Means we need patches in the Formulas as well.

I'm currently busy with other urgent projects (including wrapping up my thesis), but I'll be around to merge stuff.

By the way: Meson's find_program will, for non-executable scripts, do some extra magic to make sure it works. Specifically, it will look for shebangs and invoke them for you, this is particularly relevant on Windows where script files are never executable.

If Meson sees "python3" specifically (including via env) then it will replace that with the python3 that it knows about as sys.executable, in order to make sure that there is definitely a python3 to run it with.