Create symbolic links to help with use
This commit is contained in:
@@ -5,6 +5,32 @@ Please see Apple's documentation on [file system basics](https://developer.apple
|
||||
|
||||
This is an intended replacement for when Apple removes `/usr/bin/python`
|
||||
|
||||
## Using interactively
|
||||
After installing any of the packages, a symbolic link can be used within terminal for interactive python sessions. At the time of this writing `/usr/local/bin/python3.framework` points to `/Library/SystemFrameworks/Python3.framework/Versions/3.8/bin/python3.8`
|
||||
|
||||
## Using with scripts
|
||||
Careful consideration should be used when determining the best course of action for using with scripts. Due to various complexities, a shim file has been provided and is located at `/Library/SystemFrameworks/Python3.framework/python3`
|
||||
|
||||
It is currently recommended to point directly to this shim as future updates to python3 could change this path.
|
||||
|
||||
At the time of this writing `/Library/SystemFrameworks/Python3.framework/python3` points to `/Library/SystemFrameworks/Python3.framework/Versions/3.8/bin/python3.8`
|
||||
|
||||
An example script would look like the following:
|
||||
|
||||
```
|
||||
#!/Library/SystemFrameworks/Python3.framework/python3
|
||||
|
||||
print('This is an example script.')
|
||||
```
|
||||
|
||||
### Other options to consider
|
||||
#### zshenv global alias
|
||||
If you are calling python within zsh scripts, adding a global alias to `/etc/zshenv` may be appropriate.
|
||||
|
||||
`alias -g python3.framework='/Library/SystemFrameworks/Python3.framework/python3'`
|
||||
|
||||
For more information on this method, please see Moving to Zsh Part [II](https://scriptingosx.com/2019/06/moving-to-zsh-part-2-configuration-files/) and [IV](https://scriptingosx.com/2019/07/moving-to-zsh-part-4-aliases-and-functions/)
|
||||
|
||||
## Notes
|
||||
To decrease complexity, only a _single_ package may be installed at any given time on a machine.
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
PYTHON_VERSION=3.8.3
|
||||
RP_SHA="8bce58e91895978da6f238c1d2e1de3559ea4643"
|
||||
MP_SHA="71c57fcfdf43692adcd41fa7305be08f66bae3e5"
|
||||
# Hardcoded paths
|
||||
FRAMEWORKDIR="/Library/SystemFrameworks"
|
||||
PYTHON_BIN="$FRAMEWORKDIR/Python3.framework/Versions/3.8/bin/python3.8"
|
||||
RP_BINDIR="/tmp/relocatable-python"
|
||||
MP_BINDIR="/tmp/munki-pkg"
|
||||
|
||||
# Sanity Checks
|
||||
## Type Check
|
||||
@@ -54,10 +59,7 @@ DATE=$(/bin/date -u "+%m%d%Y%H%M%S")
|
||||
TOOLSDIR=$(dirname $0)
|
||||
OUTPUTSDIR="$TOOLSDIR/outputs"
|
||||
CONSOLEUSER=$(/usr/bin/stat -f "%Su" /dev/console)
|
||||
FRAMEWORKDIR="/Library/SystemFrameworks"
|
||||
RP_BINDIR="/tmp/relocatable-python"
|
||||
RP_ZIP="/tmp/relocatable-python.zip"
|
||||
MP_BINDIR="/tmp/munki-pkg"
|
||||
MP_ZIP="/tmp/munki-pkg.zip"
|
||||
echo "Creating Python Framework - $TYPE"
|
||||
|
||||
@@ -87,13 +89,15 @@ if [ "${DL_RESULT}" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# remove existing Python package folder
|
||||
# remove existing Python package folders and recreate
|
||||
if [ -d "$TOOLSDIR/$TYPE" ]; then
|
||||
/bin/rm -rf "$TOOLSDIR/$TYPE"
|
||||
/bin/mkdir -p "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}"
|
||||
/bin/mkdir -p "$TOOLSDIR/$TYPE/payload/usr/local/bin"
|
||||
/usr/bin/sudo /usr/sbin/chown -R ${CONSOLEUSER}:wheel "$TOOLSDIR/$TYPE"
|
||||
else
|
||||
/bin/mkdir -p "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}"
|
||||
/bin/mkdir -p "$TOOLSDIR/$TYPE/payload/usr/local/bin"
|
||||
/usr/bin/sudo /usr/sbin/chown -R ${CONSOLEUSER}:wheel "$TOOLSDIR/$TYPE"
|
||||
fi
|
||||
|
||||
@@ -114,6 +118,10 @@ fi
|
||||
echo "Moving Python.framework to payload folder"
|
||||
/usr/bin/sudo /bin/mv "${FRAMEWORKDIR}/Python.framework" "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework"
|
||||
|
||||
# make a symbolic link to help with interactive use and stable path
|
||||
/bin/ln -s "$PYTHON_BIN" "$TOOLSDIR/$TYPE/payload/usr/local/bin/python3.framework"
|
||||
/bin/ln -s "$PYTHON_BIN" "$TOOLSDIR/$TYPE/payload/$FRAMEWORKDIR/Python3.framework/python3"
|
||||
|
||||
# take ownership of the payload folder
|
||||
echo "Taking ownership of the Payload directory"
|
||||
/usr/bin/sudo /usr/sbin/chown -R ${CONSOLEUSER}:wheel "$TOOLSDIR/$TYPE"
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/Library/SystemFrameworks/Python3.framework/python3
|
||||
|
||||
print('This is an example script.')
|
||||
Reference in New Issue
Block a user