mirror of
https://github.com/actions/python-versions.git
synced 2025-12-12 21:48:15 +00:00
Update macos-pkg-setup-template.sh
This commit is contained in:
@@ -23,25 +23,46 @@ PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/$ARCH
|
||||
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
|
||||
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
|
||||
|
||||
echo "Check if Python hostedtoolcache folder exist..."
|
||||
# Check if Python dependencies are installed (e.g., zlib)
|
||||
echo "Checking if zlib is installed..."
|
||||
if ! brew list zlib &>/dev/null; then
|
||||
echo "Installing zlib via brew..."
|
||||
brew install zlib
|
||||
else
|
||||
echo "zlib already installed."
|
||||
fi
|
||||
|
||||
# Only for Python 3.7.17, install additional dependencies like zlib and others
|
||||
if [ "$MAJOR_VERSION" -eq 3 ] && [ "$MINOR_VERSION" -eq 7 ] && [ "$PYTHON_FULL_VERSION" == "3.7.17" ]; then
|
||||
echo "Installing additional dependencies for Python 3.7.17..."
|
||||
brew install bzip2 readline ncurses sqlite3 openssl@3
|
||||
# Ensure the environment variables for zlib are set correctly
|
||||
ZLIB_PREFIX=$(brew --prefix zlib)
|
||||
export LDFLAGS="-L${ZLIB_PREFIX}/lib"
|
||||
export CFLAGS="-I${ZLIB_PREFIX}/include"
|
||||
export CPPFLAGS="-I${ZLIB_PREFIX}/include"
|
||||
echo "zlib linked at ${ZLIB_PREFIX}/lib"
|
||||
fi
|
||||
|
||||
echo "Check if Python hostedtoolcache folder exists..."
|
||||
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
|
||||
echo "Creating Python hostedtoolcache folder..."
|
||||
mkdir -p $PYTHON_TOOLCACHE_PATH
|
||||
else
|
||||
# remove ALL other directories for same major.minor python versions
|
||||
find $PYTHON_TOOLCACHE_PATH -name "${MAJOR_VERSION}.${MINOR_VERSION}.*"|while read python_version;do
|
||||
# Remove ALL other directories for same major.minor python versions
|
||||
find $PYTHON_TOOLCACHE_PATH -name "${MAJOR_VERSION}.${MINOR_VERSION}.*" | while read python_version; do
|
||||
python_version_arch="$python_version/$ARCH"
|
||||
if [ -e "$python_version_arch" ];then
|
||||
if [ -e "$python_version_arch" ]; then
|
||||
echo "Deleting Python $python_version_arch"
|
||||
rm -rf "$python_version_arch"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Install Python binaries from prebuilt package"
|
||||
echo "Installing Python binaries from prebuilt package"
|
||||
sudo installer -pkg $PYTHON_PKG_NAME -target /
|
||||
|
||||
echo "Create hostedtoolcach symlinks (Required for the backward compatibility)"
|
||||
echo "Creating hostedtoolcache symlinks (Required for the backward compatibility)"
|
||||
echo "Create Python $PYTHON_FULL_VERSION folder"
|
||||
mkdir -p $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
||||
cd $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
||||
@@ -51,7 +72,7 @@ ln -s "${PYTHON_FRAMEWORK_PATH}/include" include
|
||||
ln -s "${PYTHON_FRAMEWORK_PATH}/share" share
|
||||
ln -s "${PYTHON_FRAMEWORK_PATH}/lib" lib
|
||||
|
||||
echo "Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)"
|
||||
echo "Creating additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)"
|
||||
ln -s ./bin/$PYTHON_MAJOR_DOT_MINOR python
|
||||
|
||||
cd bin/
|
||||
@@ -73,8 +94,8 @@ export PIP_ROOT_USER_ACTION=ignore
|
||||
./python -m ensurepip
|
||||
./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location
|
||||
|
||||
echo "Install OpenSSL certificates"
|
||||
echo "Installing OpenSSL certificates"
|
||||
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
|
||||
|
||||
echo "Create complete file"
|
||||
echo "Creating complete file"
|
||||
touch $PYTHON_TOOLCACHE_VERSION_PATH/${ARCH}.complete
|
||||
|
||||
Reference in New Issue
Block a user