First stab at universal 3.9.1 macadmins python (#18)
* First stab at universal 3.9.1 macadmins python * Update workflow files * Removed old build workflows * Add improvements from IAs * Revert to older MP as signing failed, update release notes
This commit is contained in:
@@ -6,13 +6,17 @@
|
||||
# Run this with your current directory being the path where this script is located
|
||||
|
||||
# Harcoded versions
|
||||
RP_SHA="8bce58e91895978da6f238c1d2e1de3559ea4643"
|
||||
RP_SHA="93f3fea5290b761b1c25c15f46f7c76641d94d58"
|
||||
MP_SHA="71c57fcfdf43692adcd41fa7305be08f66bae3e5"
|
||||
MACOS_VERSION=11.0 # use 10.9 for non-universal
|
||||
PYTHON_PRERELEASE_VERSION=
|
||||
PYTHON_BASEURL="https://www.python.org/ftp/python/%s/python-%s${PYTHON_PRERELEASE_VERSION}-macos%s.pkg"
|
||||
# Hardcoded paths
|
||||
FRAMEWORKDIR="/Library/ManagedFrameworks/Python"
|
||||
PYTHON_BIN="$FRAMEWORKDIR/Python3.framework/Versions/Current/bin/python3"
|
||||
RP_BINDIR="/tmp/relocatable-python"
|
||||
MP_BINDIR="/tmp/munki-pkg"
|
||||
PIPCACHEDIR="/Users/${CONSOLEUSER}/Library/Caches/pip"
|
||||
|
||||
# Sanity Checks
|
||||
## Type Check
|
||||
@@ -56,8 +60,10 @@ fi
|
||||
if [ -n "$3" ]; then
|
||||
PYTHON_VERSION=$3
|
||||
else
|
||||
PYTHON_VERSION=3.8.3
|
||||
PYTHON_VERSION=3.9.1
|
||||
fi
|
||||
# Set python bin version based on PYTHON_VERSION
|
||||
PYTHON_BIN_VERSION="${PYTHON_VERSION%.*}"
|
||||
|
||||
if [ -n "$4" ]; then
|
||||
DATE=$4
|
||||
@@ -73,14 +79,20 @@ RP_ZIP="/tmp/relocatable-python.zip"
|
||||
MP_ZIP="/tmp/munki-pkg.zip"
|
||||
echo "Creating Python Framework - $TYPE"
|
||||
|
||||
# Create framework path if not present
|
||||
# Create framework path if not present with 777 so sudo is not needed
|
||||
if [ ! -d "${FRAMEWORKDIR}" ]; then
|
||||
/usr/bin/sudo /bin/mkdir -p "${FRAMEWORKDIR}"
|
||||
/usr/bin/sudo /bin/mkdir -m 777 -p "${FRAMEWORKDIR}"
|
||||
fi
|
||||
|
||||
# remove existing library Python.framework if present
|
||||
if [ -d "${FRAMEWORKDIR}/Python.framework" ]; then
|
||||
/usr/bin/sudo /bin/rm -rf "${FRAMEWORKDIR}/Python.framework"
|
||||
/bin/rm -rf "${FRAMEWORKDIR}/Python.framework"
|
||||
fi
|
||||
|
||||
# remove existing library Python.framework if present
|
||||
if [ -d "${PIPCACHEDIR}" ]; then
|
||||
echo "Removing pip cache to reduce framework build errors"
|
||||
/usr/bin/sudo /bin/rm -rf "${PIPCACHEDIR}"
|
||||
fi
|
||||
|
||||
# Download specific version of relocatable-python
|
||||
@@ -113,8 +125,11 @@ fi
|
||||
|
||||
# build the framework
|
||||
RP_EXTRACT_BINDIR="${RP_BINDIR}/relocatable-python-${RP_SHA}"
|
||||
/usr/bin/sudo "${RP_EXTRACT_BINDIR}/make_relocatable_python_framework.py" \
|
||||
"${RP_EXTRACT_BINDIR}/make_relocatable_python_framework.py" \
|
||||
--baseurl "${PYTHON_BASEURL}" \
|
||||
--python-version "${PYTHON_VERSION}" \
|
||||
--os-version "${MACOS_VERSION}" \
|
||||
--upgrade-pip \
|
||||
--pip-requirements "${TOOLSDIR}/requirements_${TYPE}.txt" \
|
||||
--destination "${FRAMEWORKDIR}"
|
||||
|
||||
@@ -126,7 +141,15 @@ fi
|
||||
|
||||
# move the framework to the Python package folder
|
||||
echo "Moving Python.framework to payload folder"
|
||||
/usr/bin/sudo /bin/mv "${FRAMEWORKDIR}/Python.framework" "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework"
|
||||
/bin/mv "${FRAMEWORKDIR}/Python.framework" "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework"
|
||||
|
||||
# ad-hoc re-sign the framework so it will run on Apple Silicon
|
||||
echo "Adding ad-hoc code signing so the framework will run on Apple Silicon..."
|
||||
/usr/bin/codesign -s - --deep --force --preserve-metadata=identifier,entitlements,flags,runtime "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/${PYTHON_BIN_VERSION}/Resources/Python.app"
|
||||
/usr/bin/codesign -s - --force --preserve-metadata=identifier,entitlements,flags,runtime "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/Python"
|
||||
/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/bin/" -type f -perm -u=x -exec /usr/bin/codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \;
|
||||
/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib/" -type f -perm -u=x -exec /usr/bin/codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \;
|
||||
/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib/" -type f -name "*dylib" -exec /usr/bin/codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \;
|
||||
|
||||
# make a symbolic link to help with interactive use
|
||||
/bin/ln -s "$PYTHON_BIN" "$TOOLSDIR/$TYPE/payload/usr/local/bin/managed_python3"
|
||||
@@ -213,3 +236,4 @@ ZIPFILE="Python3.framework_$TYPE-$PYTHON_VERSION.$DATE.zip"
|
||||
|
||||
# Cleanup the temporary files
|
||||
/usr/bin/sudo /bin/rm -rf "$TOOLSDIR/$TYPE"
|
||||
/usr/bin/sudo /bin/rm -rf "${FRAMEWORKDIR}"
|
||||
|
||||
Reference in New Issue
Block a user