windows_installer.ps1 - Windows PowerShell Installation Script¶
Pre-Script Definitions¶
Automatically moves PowerShell to the user directory; when using Powershell as an admin as the default admin location is in Windows/System32.
Version of python required, put into both string and array form to be easier to parse and output
Checking if Python is Installed¶
In the command below:
2>&1Sends errors (2) and success output (1) to the success output stream. For more information, run the following in PowerShell:PS> man about_Redirection.%{ "$_" }converts objects on the error stream to strings (see SO).
Case 1: No Python¶
sometimes the pythonVersion variable is empty other times it contains “Python was not found…”
clear screen to hide confusing or conflicting powershell error message(s)
blank line
abort script
Split the pythonVersion variable into an array.
Case 1: Old Python 2¶
Case 2: Old Python 3¶
Creating codechat venv¶
We do this so that our installation does not mess with any Python libraries.
Create a virtual enviroment named codechat
find CodeChat_Server.exe and tell user if just updating or installing
Install the CodeChat Server
Update the CodeChat Server
Copies path of CodeChat_Server to the clipboard for easy pasting and displays path in terminal
$pathToCodeChat = Get-Command $env:USERPROFILE\codechat\Scripts\CodeChat_Server | Select-Object -ExpandProperty Definition
Set-Clipboard $pathToCodeChat
echo "Here is your path to CodeChat (Also copied to your clipboard): $pathToCodeChat"
echo "Now add this path to your plugin's setup - see"
echo "https://codechat-system.readthedocs.io/en/latest/extensions/contents.html"