Skip to content

Commit 1e1d9f9

Browse files
authored
fix: setup OpenSSL certificates in macos-pkg-setup-template.sh (actions#189)
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.
1 parent a1a012d commit 1e1d9f9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

installers/macos-pkg-setup-template.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ PYTHON_TOOLCACHE_PATH=$TOOLCACHE_ROOT/Python
2020
PYTHON_TOOLCACHE_VERSION_PATH=$PYTHON_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
2121
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/x64
2222
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
23+
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
2324

2425
echo "Check if Python hostedtoolcache folder exist..."
2526
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
@@ -64,5 +65,8 @@ echo "Upgrading pip..."
6465
./python -m ensurepip
6566
./python -m pip install --ignore-installed pip --disable-pip-version-check --no-warn-script-location
6667

68+
echo "Install OpenSSL certificates"
69+
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
70+
6771
echo "Create complete file"
6872
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete

tests/python-tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,8 @@ Describe "Tests" {
9696
"./dist/simple-test" | Should -ReturnZeroExitCode
9797
}
9898
}
99+
100+
It "Check urlopen with HTTPS works" {
101+
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
102+
}
99103
}

tests/sources/python-urlopen-https.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
3+
if sys.version_info[0] == 2:
4+
from urllib2 import urlopen
5+
else:
6+
from urllib.request import urlopen
7+
8+
response = urlopen("https://raw.githubusercontent.com/actions/python-versions/c641695f6a07526c18f10e374e503e649fef9427/.gitignore")
9+
data = response.read()
10+
assert len(data) == 140, len(data)

0 commit comments

Comments
 (0)