3
0
mirror of https://github.com/actions/python-versions.git synced 2025-04-07 15:59:40 +00:00

fix: setup OpenSSL certificates in macos-pkg-setup-template.sh ()

The macOS pkg installer does not setup default certificates for OpenSSL.
A script is provided by the macOS pkg installer to setup those using the certifi PyPI package.
Let's run this script as part of the setup template in order to be able to do HTTPS downloads out of the box.
This commit is contained in:
Matthieu Darbois
2022-10-03 10:13:05 +02:00
committed by GitHub
parent a1a012d197
commit 1e1d9f9032
3 changed files with 18 additions and 0 deletions

@ -20,6 +20,7 @@ PYTHON_TOOLCACHE_PATH=$TOOLCACHE_ROOT/Python
PYTHON_TOOLCACHE_VERSION_PATH=$PYTHON_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/x64
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..."
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
@ -64,5 +65,8 @@ echo "Upgrading pip..."
./python -m ensurepip
./python -m pip install --ignore-installed pip --disable-pip-version-check --no-warn-script-location
echo "Install OpenSSL certificates"
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete

@ -96,4 +96,8 @@ Describe "Tests" {
"./dist/simple-test" | Should -ReturnZeroExitCode
}
}
It "Check urlopen with HTTPS works" {
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
}
}

@ -0,0 +1,10 @@
import sys
if sys.version_info[0] == 2:
from urllib2 import urlopen
else:
from urllib.request import urlopen
response = urlopen("https://raw.githubusercontent.com/actions/python-versions/c641695f6a07526c18f10e374e503e649fef9427/.gitignore")
data = response.read()
assert len(data) == 140, len(data)