Skip to content

Github workflow: Fix python link error on macOS #2108

Github workflow: Fix python link error on macOS

Github workflow: Fix python link error on macOS #2108

Workflow file for this run

---
name: master
on: # yamllint disable-line rule:truthy
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
build:
name: build
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04', 'macos-12', 'macos-13', 'macos-14']
arch: ['x86_64', 'arm64']
cc: ['gcc', 'clang']
include:
- cc: 'gcc'
cxx: 'g++'
- cc: 'clang'
cxx: 'clang++'
exclude:
- os: 'ubuntu-20.04'
arch: 'arm64'
- os: 'ubuntu-22.04'
arch: 'arm64'
- os: 'macos-12'
arch: 'arm64'
- os: 'macos-13'
arch: 'arm64'
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout master
uses: actions/checkout@v3
- name: Setup build environment
run: |
echo "MYTHTV_CONFIG=--prefix=${{ github.workspace }}/build/install --cc=${{ matrix.cc }} --cxx=${{ matrix.cxx }}" >> $GITHUB_ENV
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
# As some OSes can cross-compile, establish defaule configrue/make
# commands which can be overided as appropriate
echo "CONFIGURE_CMD=./configure" >> $GITHUB_ENV
echo "MAKE_CMD=make" >> $GITHUB_ENV
# GitHub caches are immutable, so to update a cache, use a unique key with
# a prefixed restore-key. GitHub will rotate the caches within their 10 GB
# storage limit.
# See https://github.com/actions/cache/blob/471fb0c87e5d7210f339d8ea2e01505ddafd793d/workarounds.md#update-a-cache
- name: Check ccache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ${{ matrix.os }}-${{ matrix.cc }}-ccache-${{ github.sha }}
restore-keys: ${{ matrix.os }}-${{ matrix.cc }}-ccache
# macOS runners on github use homebrew which can place executables in
# an assortment of places. Also, the runners can in various unsynced
# states that need update to resolve linking
- name: Update environment (macOS)
env:
ARCH: ${{ matrix.arch }}
PYTHONVERS: 3.12
run: |
SYSARCH=$(/usr/bin/uname -m)
PKGMGR_CMD='brew'
HB_PREFIX=$(${PKGMGR_CMD} --prefix)
echo "HB_PREFIX=$HB_PREFIX" >> $GITHUB_ENV
echo "PYTHONVERS=${PYTHONVERS}" >> $GITHUB_ENV
${PKGMGR_CMD} update
# brute force upgrade and unlink python versions
# we'll re-link the specified version later
INSTALLED_PYTHONS=$($PKGMGR_CMD list|grep 'python@')
for PYTH in $INSTALLED_PYTHONS; do
$PKGMGR_CMD upgrade $PYTH --force
${PKGMGR_CMD} unlink $PYTH
done
${PKGMGR_CMD} cleanup
${PKGMGR_CMD} upgrade --force
## Install specified python version
#${PKGMGR_CMD} install python@${PYTHONVERS} --force --overwrite
# macOS based github runners starting at macos-14 only run on arm64
# architectures. To generate x86_64 based executable, the arch
# -x86_64 command is needed before any brew commands, make, and
# install to run as x86_64 via Rosetta2.
if [ "$SYSARCH" = "$ARCH" ]; then
# this is a cross-compile
PKGMGR_CMD="arch -${ARCH} $PKGMGR_CMD"
echo "CONFIGURE_CMD=arch -${ARCH} $CONFIGURE_CMD" >> $GITHUB_ENV
echo "MAKE_CMD=arch -${ARCH} $MAKE_CMD" >> $GITHUB_ENV
fi
echo "PKGMGR_CMD=$PKGMGR_CMD" >> $GITHUB_ENV
if: runner.os == 'macOS'
# N.B. These dependencies are for the master branch. Unlike the ansible
# playlists they do not include old dependencies that may be required for
# older versions. The list is intended to provide as much code coverage as
# possible (i.e. enable as many options as possible)
- name: Install core dependencies (linux)
run: |
sudo apt update
sudo apt install ccache qt5-qmake qtscript5-dev nasm libsystemd-dev \
libfreetype6-dev libmp3lame-dev libx264-dev libx265-dev \
libxrandr-dev libxml2-dev libavahi-compat-libdnssd-dev \
libasound2-dev liblzo2-dev libhdhomerun-dev libsamplerate0-dev \
libva-dev libdrm-dev libvdpau-dev libass-dev libpulse-dev \
libcec-dev libssl-dev libtag1-dev libbluray-dev libbluray-bdj \
libgnutls28-dev libqt5webkit5-dev libvpx-dev python3-mysqldb \
python3-lxml python3-setuptools libdbi-perl libdbd-mysql-perl \
libnet-upnp-perl libio-socket-inet6-perl libxml-simple-perl \
libqt5sql5-mysql libwayland-dev qtbase5-private-dev libzip-dev \
libsoundtouch-dev
if: runner.os == 'Linux'
- name: Install core dependencies (macOS)
env:
OS_VERS: ${{ matrix.os }}
run: |
${PKGMGR_CMD} install pkg-config ccache qt@5 nasm libsamplerate \
taglib lzo libcec libbluray libass libhdhomerun dav1d x264 x265 \
libvpx openssl sound-touch lame freetype libass libiconv libxml2 \
libzip XviD zlib pyenv-virtualenv python-lxml python-requests \
python-setuptools --force --overwrite
${PKGMGR_CMD} link qt@5 --force
${PKGMGR_CMD} link python@${PYTHONVERS} --force --overwrite
# macos-14 updated the linker and needs to be run in "classic" mode
case $OS_VERS in
macos-14 | macos-13)
LDFLAGS="-Wl,-ld_classic"
;;
esac
# homebrew uses different prefixes on x86_64 and arm64, find the
# correct one and setup the correct build variables
C_INCLUDE_PATH=$HB_PREFIX/include:$C_INCLUDE_PATH
echo "C_INCLUDE_PATH=$C_INCLUDE_PATH" >> $GITHUB_ENV
CPLUS_INCLUDE_PATH=$HB_PREFIX/include:$CPLUS_INCLUDE_PATH
echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
LDFLAGS="-L$HB_PREFIX/lib $LDFLAGS"
echo "LDFLAGS=$LDFLAGS" >> $GITHUB_ENV
LIBRARY_PATH=$HB_PREFIX/lib:$LIBRARY_PATH
echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV
PKG_CONFIG_PATH=$HB_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
if: runner.os == 'macOS'
- name: ccache statistics [pre]
run: |
ccache -sV
- name: Configure core
working-directory: ./mythtv
run: ${CONFIGURE_CMD} $MYTHTV_CONFIG --enable-libmp3lame --enable-libvpx
--enable-libx264 --enable-libx265 --enable-bdjava --enable-vulkan
- name: Make core
working-directory: ./mythtv
run: ${MAKE_CMD} all_no_test -j4
- name: Install core
working-directory: ./mythtv
run: ${MAKE_CMD} install
# QTest requires a QT SQL plugin - but there are currently none available
# via brew on macOS
- name: Unit test core
working-directory: ./mythtv
run: ${MAKE_CMD} test
if: runner.os == 'Linux'
- name: Install plugin dependencies (linux)
run: sudo apt install libvorbis-dev libflac++-dev libminizip-dev
libcdio-dev libcdio-paranoia-dev python3-pycurl libxml-xpath-perl
libdate-manip-perl libdatetime-format-iso8601-perl
libsoap-lite-perl libjson-perl libimage-size-perl
if: runner.os == 'Linux'
- name: Install plugin dependencies (ubuntu-20.04)
run: sudo apt install python3-oauth
if: matrix.os == 'ubuntu-20.04'
- name: Install plugin dependencies (ubuntu-22.04)
run: sudo apt install python3-oauthlib
if: matrix.os == 'ubuntu-22.04'
- name: Install plugin dependencies (macOS)
run: ${PKGMGR_CMD} install minizip flac libvorbis libcdio python-pycurl
python-oauthlib --force --overwrite
if: runner.os == 'macOS'
- name: Configure plugins
working-directory: ./mythplugins
run: ${CONFIGURE_CMD} $MYTHTV_CONFIG
- name: Make plugins
working-directory: ./mythplugins
run: ${MAKE_CMD} -j4
- name: ccache statistics [post]
run: |
ccache -sV