From 3c313d364989db73f6f8d585a9a9c0efda09ffd0 Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Fri, 13 Oct 2023 17:23:01 +1000 Subject: [PATCH 1/4] Add bootstrap specific to pyenv-win. Fix typos --- README.md | 16 ++++++++-------- bootstrap/bash-pyenv-win-profile.sh | 13 +++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 bootstrap/bash-pyenv-win-profile.sh diff --git a/README.md b/README.md index e2df0e2..d5a6690 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Hello, World! -If you're reading this, wecome! I assume you're from the audience of the "Beginner's Python" workshop, and it's good to have you here. You're probably used to the Google Collab/Jupyter environment, but this is a step forwards in both complexity, and eventual comfort. Consider this your first steps towards writing some serious Python code. +If you're reading this, welcome! I assume you're from the audience of the "Beginner's Python" workshop, and it's good to have you here. You're probably used to the Google Colab/Jupyter environment, but this is a step forwards in both complexity, and eventual comfort. Consider this your first steps towards writing some serious Python code. This repo is here to help you set up the software and tools you'll need to write anything from simple scripts to full-blown applications. By the end of this session you'll be able to run the included machine learning webapp, and hopefully feel comfortable making modifications to it yourselves. @@ -53,7 +53,7 @@ https://code.visualstudio.com/download ```bash sudo apt-get update && sudo apt-get install snapd -sudo snap install code +sudo snap install code --classic ``` @@ -71,7 +71,7 @@ Follow the instructions below depending on your operating system.
-1. Jump over here and downloadload the installer https://git-scm.com/download/win (64-bit Standalone) +1. Jump over here and download the installer https://git-scm.com/download/win (64-bit Standalone) 1. Select `Use Visual Studio Code as Git's default editor` at the default editor screen 1. Select `Git from the command line and also from 3rd-party software` at the adjusting path environment screen @@ -152,7 +152,7 @@ Moving around, doing folder stuff: Git commands: -- `git clone {url}` : pull down a new rsepo +- `git clone {url}` : pull down a new repo - `git pull` : checks the remote server for newer versions of a git repo VSCode commands: @@ -190,7 +190,7 @@ You should see either `bash` (a lot of Linux distros) or `zsh` (MacOS). If you s From time to time, programming languages get an update. This makes a lot of people very angry and is been widely regarded as a bad move. (With apologies to Douglas Adams.) -Pyenv allows us to spend less time handling Python versions. A tool called Anaconda can also do this (as well as other things), but Anaconda comes with licencing conditions that make it unattractive for commercial work. It helps us recover if we accidentally break a Python install, it helps us upgrade, and it helps downstream tooling (such as VSCode or PDM) to switch Python versions based on availability. +Pyenv allows us to spend less time handling Python versions. A tool called Anaconda can also do this (as well as other things), but Anaconda comes with licencing conditions that make it unattractive for commercial work. Pyenv helps us recover if we accidentally break a Python install, it helps us upgrade, and it helps downstream tooling (such as VSCode or PDM) to switch Python versions based on availability. Follow the instructions below based on your OS: @@ -210,7 +210,7 @@ Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv Next, in Git Bash, run the following command: ```bash -. ~/projects/python-intro/bootstrap/bash-pyenv-profile.sh +. ~/projects/python-intro/bootstrap/bash-pyenv-win-profile.sh ``` (Don't forget the full-stop at the beginning!) @@ -277,8 +277,8 @@ If you're using `zsh`, run the following: Now that Pyenv is installed, we can install Python easily: ```bash -pyenv install 3.10.12 -pyenv global 3.10.12 +pyenv install 3.10.11 +pyenv global 3.10.11 ``` Double check Python has been installed properly using `python --version` diff --git a/bootstrap/bash-pyenv-win-profile.sh b/bootstrap/bash-pyenv-win-profile.sh new file mode 100644 index 0000000..33c96c9 --- /dev/null +++ b/bootstrap/bash-pyenv-win-profile.sh @@ -0,0 +1,13 @@ +echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc + +echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile + +echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bash_profile +echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc + +echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bash_profile +echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bashrc + +echo "Shell environment set up, exit to force restart" \ No newline at end of file From 4ec244aac260213b08b335461c9d4cbccdafaf31 Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Sun, 15 Oct 2023 17:24:54 +1000 Subject: [PATCH 2/4] .local not required on Windows pyenv-win --- bootstrap/bash-pyenv-win-profile.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bootstrap/bash-pyenv-win-profile.sh b/bootstrap/bash-pyenv-win-profile.sh index 33c96c9..331cc38 100644 --- a/bootstrap/bash-pyenv-win-profile.sh +++ b/bootstrap/bash-pyenv-win-profile.sh @@ -4,9 +4,6 @@ echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/. echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile -echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bash_profile -echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc - echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bash_profile echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bashrc From bae9d0f25dbdb07ebd984245067f486f58177efb Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Wed, 18 Oct 2023 15:14:58 +1000 Subject: [PATCH 3/4] add execute mode to bash script, not that it works on windows --- bootstrap/bash-pyenv-win-profile.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bootstrap/bash-pyenv-win-profile.sh diff --git a/bootstrap/bash-pyenv-win-profile.sh b/bootstrap/bash-pyenv-win-profile.sh old mode 100644 new mode 100755 From 3a179c7ed679955d212cefe598d925c836ceb116 Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Wed, 18 Oct 2023 20:01:34 +1000 Subject: [PATCH 4/4] fix path as pyenv-win is in its own directory Set recommended variables Include shims in path --- bootstrap/bash-pyenv-win-profile.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bootstrap/bash-pyenv-win-profile.sh b/bootstrap/bash-pyenv-win-profile.sh index 331cc38..343ee09 100755 --- a/bootstrap/bash-pyenv-win-profile.sh +++ b/bootstrap/bash-pyenv-win-profile.sh @@ -1,10 +1,14 @@ -echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc -echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc +echo 'export PYENV_ROOT="$HOME/.pyenv/pyenv-win"' >> ~/.bashrc +echo 'export PYENV=$PYENV_ROOT' >> ~/.bashrc +echo 'export PYENV_HOME=$PYENV_ROOT' >> ~/.bashrc +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"' >> ~/.bashrc -echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile -echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile +echo 'export PYENV_ROOT="$HOME/.pyenv/pyenv-win"' >> ~/.bash_profile +echo 'export PYENV=$PYENV_ROOT' >> ~/.bash_profile +echo 'export PYENV_HOME=$PYENV_ROOT' >> ~/.bash_profile +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"' >> ~/.bash_profile echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bash_profile echo 'export PATH=$HOME/AppData/Roaming/Python/Scripts:$PATH' >> ~/.bashrc -echo "Shell environment set up, exit to force restart" \ No newline at end of file +echo "Shell environment set up, exit to force restart"