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

Don't double install mac deps, cleanups #2513

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 @@ -27,8 +27,3 @@ cmake .. $PG_BASE_CMAKE_FLAGS -Denable-readline=OFF $FLUIDSYNTH_EXTRA_PLAT_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,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 @@ -36,27 +36,22 @@ cd ${HARFBUZZ_NAME}
# Cairo and chafa are only needed for harfbuzz commandline utilities so we
# don't use it. glib available is a bit old so we don't prefer it as of now.
# 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 +65,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
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
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
Loading