Skip to content

Commit

Permalink
Don't double install mac deps, cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Oct 9, 2023
1 parent 19b2207 commit 596354b
Show file tree
Hide file tree
Showing 30 changed files with 71 additions and 199 deletions.
30 changes: 15 additions & 15 deletions buildconfig/macdependencies/build_mac_deps.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This uses manylinux build scripts to build dependencies
# on mac.
#
# Warning: this should probably not be run on your own mac.
# Since it will install all these deps all over the place,
# and they may conflict with existing installs you have.
# Warning: this should not be run on your own mac as it cleans dependencies on the system

set -e -x

export MACDEP_CACHE_PREFIX_PATH=${GITHUB_WORKSPACE}/pygame_mac_deps_${MAC_ARCH}
export PG_DEP_PREFIX=${GITHUB_WORKSPACE}/pygame_mac_deps_${MAC_ARCH}

bash ./clean_usr_local.sh
mkdir $MACDEP_CACHE_PREFIX_PATH
mkdir $PG_DEP_PREFIX

export PKG_CONFIG_PATH="$PG_DEP_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"

# to use the gnu readlink, needs `brew install coreutils`
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
Expand All @@ -19,25 +19,29 @@ export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export MAKEFLAGS="-j 4"

# With this we
# 1) Force install prefix to /usr/local
# 2) use lib directory within /usr/local (and not lib64)
# 1) Force install prefix to $PG_DEP_PREFIX
# 2) use lib directory within $PG_DEP_PREFIX (and not lib64)
# 3) make release binaries
# 4) build shared libraries
# 5) not have @rpath in the linked dylibs (needed on macs only)
export PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr/local/ \
# 6) tell cmake to search in $PG_DEP_PREFIX for sub dependencies
export PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$PG_DEP_PREFIX \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=true \
-DCMAKE_INSTALL_NAME_DIR=/usr/local/lib"
-DCMAKE_INSTALL_NAME_DIR=$PG_DEP_PREFIX/lib \
-DCMAKE_PREFIX_PATH=$PG_DEP_PREFIX"

export PG_BASE_CONFIGURE_FLAGS="--prefix=$PG_DEP_PREFIX"

if [[ "$MAC_ARCH" == "arm64" ]]; then
# for scripts using ./configure to make arm64 binaries
export CC="clang -target arm64-apple-macos11.0"
export CXX="clang++ -target arm64-apple-macos11.0"

# This does not do anything actually, but without this ./configure errors
export ARCHS_CONFIG_FLAG="--host=aarch64-apple-darwin20.0.0"
export PG_BASE_CONFIGURE_FLAGS="$PG_BASE_CONFIGURE_FLAGS --host=aarch64-apple-darwin20.0.0"

# configure cmake to cross-compile
export PG_BASE_CMAKE_FLAGS="$PG_BASE_CMAKE_FLAGS -DCMAKE_OSX_ARCHITECTURES=arm64"

Expand All @@ -57,10 +61,6 @@ cd ../manylinux-build/docker_base
# Now start installing dependencies
# ---------------------------------

sudo mkdir -p /usr/local/man/man1 # the install tries to put something in here
sudo chmod 0777 /usr/local/man/man1 # so that install can put files here
mkdir -p ${MACDEP_CACHE_PREFIX_PATH}/usr/local/man/man1

# sdl_image deps
bash zlib-ng/build-zlib-ng.sh
bash libpng/build-png.sh # depends on zlib
Expand Down
2 changes: 1 addition & 1 deletion buildconfig/macdependencies/install_mac_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ def symtree(srcdir: Path, destdir: Path, verbose: bool = False):
destpath.symlink_to(path)


symtree(Path(sys.argv[1]), Path("/"), verbose=True)
symtree(Path(sys.argv[1]), Path("/usr/local"), verbose=True)
9 changes: 6 additions & 3 deletions buildconfig/manylinux-build/docker_base/Dockerfile-aarch64
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM quay.io/pypa/manylinux2014_aarch64
ENV MAKEFLAGS="-j 2"
ENV PG_DEP_PREFIX="/usr/local"

# Set up repoforge
COPY RPM-GPG-KEY.dag.txt /tmp/
Expand All @@ -18,15 +19,17 @@ RUN yum install -y zlib-devel dbus-devel fontconfig xz systemd-devel \
libXi-devel libXScrnSaver-devel

# With this we
# 1) Force install prefix to /usr/local
# 2) use lib directory within /usr/local (and not lib64)
# 1) Force install prefix to $PG_DEP_PREFIX
# 2) use lib directory within $PG_DEP_PREFIX (and not lib64)
# 3) make release binaries
# 4) build shared libraries
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr/local/ \
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$PG_DEP_PREFIX \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=true"

ENV PG_BASE_CONFIGURE_FLAGS="--prefix=$PG_DEP_PREFIX"

ADD pkg-config /pkg-config_build/
RUN ["bash", "/pkg-config_build/build-pkg-config.sh"]

Expand Down
9 changes: 6 additions & 3 deletions buildconfig/manylinux-build/docker_base/Dockerfile-i686
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM quay.io/pypa/manylinux2014_i686
ENV MAKEFLAGS="-j 2"
ENV PG_DEP_PREFIX="/usr/local"

# Set up repoforge
COPY RPM-GPG-KEY.dag.txt /tmp/
Expand All @@ -18,15 +19,17 @@ RUN linux32 yum install -y zlib-devel dbus-devel fontconfig xz systemd-devel \
libXi-devel libXScrnSaver-devel

# With this we
# 1) Force install prefix to /usr/local
# 2) use lib directory within /usr/local (and not lib64)
# 1) Force install prefix to $PG_DEP_PREFIX
# 2) use lib directory within $PG_DEP_PREFIX (and not lib64)
# 3) make release binaries
# 4) build shared libraries
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr/local/ \
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$PG_DEP_PREFIX \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=true"

ENV PG_BASE_CONFIGURE_FLAGS="--prefix=$PG_DEP_PREFIX"

ADD pkg-config /pkg-config_build/
RUN ["linux32", "bash", "/pkg-config_build/build-pkg-config.sh"]

Expand Down
9 changes: 6 additions & 3 deletions buildconfig/manylinux-build/docker_base/Dockerfile-x86_64
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM quay.io/pypa/manylinux2014_x86_64
ENV MAKEFLAGS="-j 2"
ENV PG_DEP_PREFIX="/usr/local"

# Set up repoforge
COPY RPM-GPG-KEY.dag.txt /tmp/
Expand All @@ -18,15 +19,17 @@ RUN yum install -y zlib-devel dbus-devel fontconfig xz systemd-devel \
libXi-devel libXScrnSaver-devel

# With this we
# 1) Force install prefix to /usr/local
# 2) use lib directory within /usr/local (and not lib64)
# 1) Force install prefix to $PG_DEP_PREFIX
# 2) use lib directory within $PG_DEP_PREFIX (and not lib64)
# 3) make release binaries
# 4) build shared libraries
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr/local/ \
ENV PG_BASE_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$PG_DEP_PREFIX \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=true"

ENV PG_BASE_CONFIGURE_FLAGS="--prefix=$PG_DEP_PREFIX"

ADD pkg-config /pkg-config_build/
RUN ["bash", "/pkg-config_build/build-pkg-config.sh"]

Expand Down
2 changes: 1 addition & 1 deletion buildconfig/manylinux-build/docker_base/alsa/build-alsa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ tar xjf ${ALSA}.tar.bz2
cd ${ALSA}

# alsa prefers /usr prefix as a default, so we explicitly override it
./configure --prefix=/usr/local --with-configdir=/usr/local/share/alsa
./configure $PG_BASE_CONFIGURE_FLAGS --with-configdir=$PG_DEP_PREFIX/share/alsa
make
make install
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,3 @@ cd $BROTLI
cmake . $PG_BASE_CMAKE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
16 changes: 2 additions & 14 deletions buildconfig/manylinux-build/docker_base/bzip2/build-bzip2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,8 @@ tar xzf ${BZIP2}.tar.gz
cd $BZIP2

if [[ -z "${CC}" ]]; then
make install
make install PREFIX=$PG_DEP_PREFIX
else
# pass CC explicitly because it's needed here
make install CC="${CC}"
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install PREFIX=${MACDEP_CACHE_PREFIX_PATH}/usr/local
fi

if [[ "$MAC_ARCH" == "arm64" ]]; then
# We don't need bzip2 arm64 binaries, remove them so that intel binaries
# are used correctly
sudo rm /usr/local/bin/bzip2
rm ${MACDEP_CACHE_PREFIX_PATH}/usr/local/bin/bzip2
make install CC="${CC}" PREFIX=$PG_DEP_PREFIX
fi
7 changes: 1 addition & 6 deletions buildconfig/manylinux-build/docker_base/flac/build-flac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ unxz ${FLAC}.tar.xz
tar xf ${FLAC}.tar
cd $FLAC

./configure $ARCHS_CONFIG_FLAG
./configure $PG_BASE_CONFIGURE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,3 @@ fi
cmake .. $PG_BASE_CMAKE_FLAGS -Denable-readline=OFF $FLUIDSYNTH_EXTRA_MAC_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
20 changes: 6 additions & 14 deletions buildconfig/manylinux-build/docker_base/freetype/build-freetype.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tar xf ${HARFBUZZ_NAME}.tar
# 1. First compile freetype without harfbuzz support
cd $FREETYPE

./configure $ARCHS_CONFIG_FLAG --with-harfbuzz=no
./configure $PG_BASE_CONFIGURE_FLAGS --with-harfbuzz=no
make
make install # this freetype is not installed to mac cache dir

Expand All @@ -38,25 +38,22 @@ cd ${HARFBUZZ_NAME}
# we also don't compile-in icu so that harfbuzz uses built-in unicode handling
# LDFLAGS are passed explicitly so that harfbuzz picks the freetype we
# installed first
./configure $ARCHS_CONFIG_FLAG --with-freetype=yes \
./configure $PG_BASE_CONFIGURE_FLAGS --with-freetype=yes \
--with-cairo=no --with-chafa=no --with-glib=no --with-icu=no \
--disable-static LDFLAGS="-L/usr/local/lib"
--disable-static
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}

# We do a little hack...
# When freetype finds harfbuzz with pkg-config, we tell freetype a little
# lie that harfbuzz doesn't depend on freetype (even though it does).
# This ensures no direct circular dylib link happen.
# This is a bit of a brittle hack: This command removes the entire line that
# contains "freetype". This is fine for now when the harfbuzz we are
# building has no other dependencies
sed -i '' '/freetype/d' /usr/local/lib/pkgconfig/harfbuzz.pc
sed -i '' 's/ \/usr\/local\/lib\/libfreetype.la//g' /usr/local/lib/libharfbuzz.la
sed -i '' '/freetype/d' $PG_DEP_PREFIX/lib/pkgconfig/harfbuzz.pc
sed -i '' 's/ [^ ]*libfreetype.la//g' $PG_DEP_PREFIX/lib/libharfbuzz.la
fi

cd ..
Expand All @@ -70,11 +67,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
make uninstall
fi

./configure $ARCHS_CONFIG_FLAG --with-harfbuzz=yes
./configure $PG_BASE_CONFIGURE_FLAGS --with-harfbuzz=yes
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
tar xzf ${GETTEXT}.tar.gz
cd $GETTEXT

./configure $ARCHS_CONFIG_FLAG $GETTEXT_CONFIGURE \
./configure $PG_BASE_CONFIGURE_FLAGS $GETTEXT_CONFIGURE \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-debug \
Expand All @@ -38,7 +38,8 @@ cd $GETTEXT
make
make install

# For some reason, this is needed for glib to find gettext
# TODO: remove this, hopefully after glib is updated this won't be needed
if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
make install prefix=/usr/local
fi
7 changes: 1 addition & 6 deletions buildconfig/manylinux-build/docker_base/glib/build-glib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ if [[ "$MAC_ARCH" == "arm64" ]]; then
export GLIB_COMPILE_EXTRA_FLAGS="--cache-file=../macos_arm64.cache"
fi

CFLAGS=-Wno-error ./configure $ARCHS_CONFIG_FLAG --with-pcre=internal $GLIB_COMPILE_EXTRA_FLAGS --disable-libmount --disable-dbus
CFLAGS=-Wno-error ./configure $PG_BASE_CONFIGURE_FLAGS --with-pcre=internal $GLIB_COMPILE_EXTRA_FLAGS --disable-libmount --disable-dbus
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ sha512sum -c libffi.sha512
tar xzf ${LIBFFI}.tar.gz
cd $LIBFFI

./configure $ARCHS_CONFIG_FLAG
./configure $PG_BASE_CONFIGURE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ cmake . $PG_BASE_CMAKE_FLAGS -DWITH_TURBOJPEG=0

make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ sha512sum -c libmodplug.sha512
tar -xf ${MODPLUG_NAME}.tar.gz
cd ${MODPLUG_NAME}

./configure $ARCHS_CONFIG_FLAG
./configure $PG_BASE_CONFIGURE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
6 changes: 1 addition & 5 deletions buildconfig/manylinux-build/docker_base/libpng/build-png.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ sha512sum -c png.sha512
tar xzf ${PNG}.tar.gz
cd $PNG

./configure --with-zlib-prefix=/usr/local/ $ARCHS_CONFIG_FLAG
./configure --with-zlib-prefix=$PG_DEP_PREFIX $PG_BASE_CONFIGURE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ tar xzf ${TIFF}.tar.gz
cd $TIFF

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./configure --disable-lzma --disable-webp --disable-zstd
./configure $PG_BASE_CONFIGURE_FLAGS --disable-lzma --disable-webp --disable-zstd
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Use CMake on MacOS because arm64 builds fail with weird errors in ./configure
cmake . $PG_BASE_CMAKE_FLAGS -Dlzma=OFF -Dwebp=OFF -Dzstd=OFF
fi

make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ sha512sum -c webp.sha512
tar xzf ${WEBP}.tar.gz
cd $WEBP

./configure $ARCHS_CONFIG_FLAG
./configure $PG_BASE_CONFIGURE_FLAGS
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ bzip2 -d ${MPG123}.tar.bz2
tar xf ${MPG123}.tar
cd $MPG123

./configure $ARCHS_CONFIG_FLAG --enable-int-quality --disable-debug
./configure $PG_BASE_CONFIGURE_FLAGS --enable-int-quality --disable-debug
make
make install

if [[ "$OSTYPE" == "darwin"* ]]; then
# Install to mac deps cache dir as well
make install DESTDIR=${MACDEP_CACHE_PREFIX_PATH}
fi

cd ..
Loading

0 comments on commit 596354b

Please sign in to comment.