A set of PowerShell scripts to automate deployment of python applications. The automation includes cloning of application repos, installation of Miniforge, and setting up conda environments for each application.
- non-coders
- many devices
- users need to update often
- Download 3 files, *.bat, *.yml, *.ps1 All files must be in the same folder and not in a zip.
- Right click run-elevated-firse.bat and click 'Run with Elevated Privileges' or 'Run as Administrator', allow elevation when prompted
- Right click *.ps1 and click 'Run with PowerShell', allow elevation when prompted and follow the prompts
- Operating system: Windows 10 or 11
- Internet connection during installation/update
- Disk used: varies by application but minimum ~2GB
- Installs python optimized for enterprise environments (miniforge-cost,versatility,reproduceability)
- Attempts to fix “SSL certificate verify failed” for conda and pip
- Update via start menu shortcut
- Simple: download 3 files, run 1 with admin privileges
- Start menu shortcuts
- Multi-user installation option
- Don’t need github access
- Use for multiple apps (each gets own conda environment)
- No GUI, headless/remote installs possible
- Updates distributed via git (uses git cli, so not tied to github.com)
- Use SSH (deploy) keys to access private repos
- No compiling or bundling
- Optionally install National Instruments drivers
- Environment file autodetect: priority highest to lowest - environment.yml > setup.py/pyproject.toml > requirements.txt
- Detects developer install: uses existing git repos
- if application repos is private, generate read-only deploy key for your application repo
- (optional) add gitpyup.yml to your application repo(s) to generate shortcuts and or set the environment file
# example contents of optional gitpyup.yml in root of application repo
environment_file: setup.py # specify to override autodetect
shortcuts: # generate shortcuts
- name: myconsolescript
command: conda run -n <app name> <console script> # e.g. conda run -n plotme plotme
target: powershell.exe # (optional) default is powershell.exe
- name: myscript
target: powershell.exe
script: myscript.ps1
- create config file: yourAppName.yml
- In this example plotme is the only application. Application order doesn't matter.
# <your app name>.yml - name is up to you
applications:
# optional, gitpyup can be placed here to override the default that is in Deploy-gitpyup.ps1
- name: gitpyup
clone_uri: [email protected]:3Mcloud/gitpyup.git
deploy_key: "replace with deploy key if needed"
- name: plotme
clone_uri: [email protected]:3mcloud/plotme.git
# example key format
deploy_key: |-
-----BEGIN OPENSSH PRIVATE KEY-----
**********************************************
**********************************************
-----END OPENSSH PRIVATE KEY-----
# optional, needed for HTTPS inspection compatability (usually corporate environments)
tls_bundle: "https://raw.githubusercontent.com/<org/user>/<repo>/main/tls-ca-bundle.txt"
- upload 3 files somewhere your users can access
- Deploy-gitpyup.ps1
- yourAppName.yml
- run-elevated-first.bat
- gitpyup/Deploy-gitpyup.ps1 - Initial setup and updates, clones repos, creates shortcuts
- gitpyup/Setup-Python.ps1 - Installs/updates Miniforge
- gitpyup/Setup-Application.ps1 - Creates/updates application environments
- gitpyup/Uninstall-gitpyup.ps1 - Removes start menu shortcuts, cloned repos
- gitpyup/run-elevated-first.bat - Sets PowerShell policy and unblocks Deploy-gitpyup.ps1
- gitpyup/Setup-NationalInstruments.ps1 - modify $packages array to add or remove packages, run with elevated priveleges
- Tests
- NoPrompt flag for non-interactive install so it can be used in CI/CD pipelines, add currently interactive configuration options to yourappname.yml
- Convert to powershell module and publish to PowerShell Gallery
- Modify Setup-Python.ps1 so it can be used standalone
- share conda environment between multiple applications via application.yml or gitpyup.yml
- allow customization of National Instruments packages via gitpyup.yml
- support additional WinGet packages via gitpyup.yml