mirror of
https://github.com/actions/python-versions.git
synced 2025-12-15 15:32:11 +00:00
Compare commits
8 Commits
3.14.0-bet
...
test-3.7.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbc60cfaec | ||
|
|
c84ab0e4bd | ||
|
|
4117c4fe82 | ||
|
|
3d18e531c2 | ||
|
|
c47a267fd1 | ||
|
|
d43da0ca8a | ||
|
|
c0cdd7380e | ||
|
|
dbeaa2df93 |
@@ -6,18 +6,17 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
MacOS Python builder class.
|
MacOS Python builder class.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Contains methods that required to build macOS Python artifact from sources. Inherited from base NixPythonBuilder.
|
Contains methods required to build macOS Python artifacts from sources. Inherited from base NixPythonBuilder.
|
||||||
|
|
||||||
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
|
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
|
||||||
If we wanted to start using the official binaries instead of building from source, we should avoid changing previous versions
|
If we wanted to start using the official binaries instead of building from source, we should avoid changing previous versions
|
||||||
so we remain backwards compatible.
|
so we remain backwards compatible.
|
||||||
|
|
||||||
.PARAMETER platform
|
.PARAMETER platform
|
||||||
The full name of platform for which Python should be built.
|
The full name of the platform for which Python should be built.
|
||||||
|
|
||||||
.PARAMETER version
|
.PARAMETER version
|
||||||
The version of Python that should be built.
|
The version of Python that should be built.
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
macOSPythonBuilder(
|
macOSPythonBuilder(
|
||||||
@@ -31,14 +30,18 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Prepare system environment by installing dependencies and required packages.
|
Prepare system environment by installing dependencies and required packages.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
if ($this.Version -eq "3.7.17") {
|
# Only for Python 3.7.17, install additional dependencies
|
||||||
# We have preinstalled ncurses and readLine on the hoster runners. But we need to install bzip2 for
|
if ($this.Version -eq "3.7.17") {
|
||||||
# setting up an environemnt
|
Write-Host "Installing additional dependencies for Python 3.7.17..."
|
||||||
# If we get any issues realted to ncurses or readline we can try to run this command
|
# Install necessary dependencies for Python 3.7.17
|
||||||
# brew install ncurses readline
|
Execute-Command -Command "brew install bzip2 zlib readline ncurses sqlite3 openssl@3"
|
||||||
Execute-Command -Command "brew install bzip2"
|
|
||||||
}
|
# Ensure the environment variables for zlib are set correctly
|
||||||
|
$zlibPrefix = (brew --prefix zlib)
|
||||||
|
$env:LDFLAGS += " -L$($zlibPrefix)/lib"
|
||||||
|
$env:CFLAGS += " -I$($zlibPrefix)/include"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Configure() {
|
[void] Configure() {
|
||||||
@@ -71,10 +74,10 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
|
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
|
||||||
$env:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
|
$env:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
|
||||||
} else {
|
} else {
|
||||||
$configureString += " --with-openssl=/usr/local/opt/openssl@3"
|
$configureString += " --with-openssl=/usr/local/opt/openssl@1.1" # For Python 3.7.x, use OpenSSL 1.1
|
||||||
|
|
||||||
# For Python 3.7.2 and 3.7.3 we need to provide PATH for zlib to pack it properly. Otherwise the build will fail
|
# For Python 3.7.2, 3.7.3, and 3.7.17 we need to provide PATH for zlib to pack it properly.
|
||||||
# with the error: zipimport.ZipImportError: can't decompress data; zlib not available
|
# Otherwise, the build will fail with the error: zipimport.ZipImportError: can't decompress data; zlib not available
|
||||||
if ($this.Version -eq "3.7.2" -or $this.Version -eq "3.7.3" -or $this.Version -eq "3.7.17") {
|
if ($this.Version -eq "3.7.2" -or $this.Version -eq "3.7.3" -or $this.Version -eq "3.7.17") {
|
||||||
$env:LDFLAGS = "-L/usr/local/opt/zlib/lib"
|
$env:LDFLAGS = "-L/usr/local/opt/zlib/lib"
|
||||||
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
|
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
|
||||||
@@ -82,9 +85,11 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
|
|
||||||
if ($this.Version -gt "3.7.12") {
|
if ($this.Version -gt "3.7.12") {
|
||||||
$configureString += " --with-tcltk-includes='-I /usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
|
$configureString += " --with-tcltk-includes='-I /usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Specific for Python 3.7.17
|
||||||
if ($this.Version -eq "3.7.17") {
|
if ($this.Version -eq "3.7.17") {
|
||||||
|
Write-Host "Setting environment for Python 3.7.17..."
|
||||||
$env:LDFLAGS += " -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib"
|
$env:LDFLAGS += " -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib"
|
||||||
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
|
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,25 +23,47 @@ PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/$ARCH
|
|||||||
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
|
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
|
||||||
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
|
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
|
||||||
|
|
||||||
echo "Check if Python hostedtoolcache folder exist..."
|
# Check if zlib is installed
|
||||||
|
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
|
||||||
|
|
||||||
|
# Check if Python hostedtoolcache folder exists...
|
||||||
|
echo "Check if Python hostedtoolcache folder exists..."
|
||||||
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
|
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
|
||||||
echo "Creating Python hostedtoolcache folder..."
|
echo "Creating Python hostedtoolcache folder..."
|
||||||
mkdir -p $PYTHON_TOOLCACHE_PATH
|
mkdir -p $PYTHON_TOOLCACHE_PATH
|
||||||
else
|
else
|
||||||
# remove ALL other directories for same major.minor python versions
|
# Remove ALL other directories for same major.minor python versions
|
||||||
find $PYTHON_TOOLCACHE_PATH -name "${MAJOR_VERSION}.${MINOR_VERSION}.*"|while read python_version;do
|
find $PYTHON_TOOLCACHE_PATH -name "${MAJOR_VERSION}.${MINOR_VERSION}.*" | while read python_version; do
|
||||||
python_version_arch="$python_version/$ARCH"
|
python_version_arch="$python_version/$ARCH"
|
||||||
if [ -e "$python_version_arch" ];then
|
if [ -e "$python_version_arch" ]; then
|
||||||
echo "Deleting Python $python_version_arch"
|
echo "Deleting Python $python_version_arch"
|
||||||
rm -rf "$python_version_arch"
|
rm -rf "$python_version_arch"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Install Python binaries from prebuilt package"
|
echo "Installing Python binaries from prebuilt package"
|
||||||
sudo installer -pkg $PYTHON_PKG_NAME -target /
|
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"
|
echo "Create Python $PYTHON_FULL_VERSION folder"
|
||||||
mkdir -p $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
mkdir -p $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
||||||
cd $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
cd $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
|
||||||
@@ -51,7 +73,7 @@ ln -s "${PYTHON_FRAMEWORK_PATH}/include" include
|
|||||||
ln -s "${PYTHON_FRAMEWORK_PATH}/share" share
|
ln -s "${PYTHON_FRAMEWORK_PATH}/share" share
|
||||||
ln -s "${PYTHON_FRAMEWORK_PATH}/lib" lib
|
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
|
ln -s ./bin/$PYTHON_MAJOR_DOT_MINOR python
|
||||||
|
|
||||||
cd bin/
|
cd bin/
|
||||||
@@ -73,8 +95,8 @@ export PIP_ROOT_USER_ACTION=ignore
|
|||||||
./python -m ensurepip
|
./python -m ensurepip
|
||||||
./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location
|
./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"
|
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
|
||||||
|
|
||||||
echo "Create complete file"
|
echo "Creating complete file"
|
||||||
touch $PYTHON_TOOLCACHE_VERSION_PATH/${ARCH}.complete
|
touch $PYTHON_TOOLCACHE_VERSION_PATH/${ARCH}.complete
|
||||||
|
|||||||
Reference in New Issue
Block a user