Skip to content

Instantly share code, notes, and snippets.

@oleksis
Last active September 12, 2023 18:18
Show Gist options
  • Save oleksis/ae145fade455aae58c47e0295d2cf38d to your computer and use it in GitHub Desktop.
Save oleksis/ae145fade455aae58c47e0295d2cf38d to your computer and use it in GitHub Desktop.
Setup Python Coding Environment on Windows
# Oh My Posh
eval "$(oh-my-posh init bash --config ~/.poshthemes/microverse-power.omp.json)"
# Pyenv
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
PATH="/home/oleksis:$PATH"
VSCODE="/mnt/c/Program Files/Microsoft VS Code/bin"
VSCODE_SERVER="/mnt/c/Users/user.HP450-2/.vscode-server-launcher/bin"
PATH="$PATH:$VSCODE:$VSCODE_SERVER"
POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0"
PATH="$PATH:$POWERSHELL"
export GEM_HOME=$HOME/gems
export PATH="$PATH:$HOME/gems/bin"
[user]
name = Oleksis Fraga Menéndez
email = oleksis.fraga@gmail.com
[core]
autocrlf = input
symlinks = true
[wsl2]
# Versión de WSL: 1.3.17.0
kernel=C:\\Users\\oleksis\\bzImage-v6.3.0
# https://github.com/luxzg/WSL2-fixes/blob/master/networkingMode%3Dbridged.md
networkingMode=bridged
# https://i.stack.imgur.com/l3CUD.png
# https://stackoverflow.com/a/65960434
# Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled
# ip addr show dev eth0
# sudo ip addr add 172.19.16.100/28 dev eth0
# sudo ip link set eth0 up
vmSwitch=WSL_external
ipv6=true
localhostForwarding = true
dhcp = true
# setup-python-windows.ps1
# https://realpython.com/python-coding-setup-windows/#running-a-setup-script
Write-Output "Installing Winget Packages"
winget install -e --silent --id Microsoft.PowerShell
winget install -e --silent --id Microsoft.VisualStudioCode
# winget install -e --id Notepad++.Notepad++
# winget install -e --id Docker.DockerDesktop
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
Write-Output "Install and configure Git..."
winget install -e --override "/SILENT /NORESTART" --id Git.Git
# Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Write-Output "Installing pyenv for Windows"
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
# This is a way to make sure that the Path gets updated for the following
# operations that require Path to be refreshed.
# Source: https://stackoverflow.com/a/22670892/10445017
foreach ($level in "Machine", "User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() |
ForEach-Object {
if ($_.Name -match 'Path$') {
$combined_path = (Get-Content "Env:$($_.Name)") + ";$($_.Value)"
$_.Value = (
($combined_path -split ';' | Select-Object -unique) -join ';'
)
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
Write-Output "Setting up pyenv and installing Python"
pyenv update
pyenv install --quiet 3.10.6
pyenv global 3.10.6
Write-Output "Generating SSH key"
ssh-keygen -C john.doe@domain.com -P '""' -f "$HOME/.ssh/id_rsa"
Get-Content $HOME/.ssh/id_rsa.pub | clip
Write-Output "Your SSH key has been copied to the clipboard"
[boot]
systemd=true
[interop]
appendWindowsPath=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment