- Summary
- Install pyenv
- Install rust (prerequisite for poetry)
- Install poetry
- Install git
- Install gh
- Next Steps
We will now install some packages that we will need to manage our python project.
-
We will install
pyenv
to manage our python environments and versions. -
pyenv
is used to isolate a python installation and version, and tie it to a specific project, so that the project will work regardless of what version of python you use in general in your system, or in your other projects (that might have other environments).
-
We will also install
poetry
. -
poetry
is a package manager, that specifies your project dependencies so that other users can install the exact same packages and versions of which you used in your project. -
For instance, if your project needs a certain version of
numpy
, and is only compatible with that version,poetry
will allow users to automatically installnumpy
with the specific version, to guarantee your project will run correctly in their system.
-
We will also install
git
, andgh
. -
git
is a file manager that focuses on the handling and versioning of code repositories. A code repository is a virtual directory where your code can be stored and shared. -
We will use GitHub as the server that will house our code repository for this project. We will use
git
to sync our local files with the GitHub repository. -
gh
is a package that focuses on handling GitHub features through the terminal. We can use it in case we want to remotely access GitHub features (like pull requests, complex merges, being social, etc.) without the need for a browser, straight from our Pi's UNIX-based terminal.
-
Run:
curl https://pyenv.run | bash
. -
We need to add
pyenv
to ourbashrc
file, to let the package be called anywhere in the system (without needing to be in the program's folder). This is called and environment variable. To do so:-
Run:
nano ~/.bashrc
.[!NOTE] This opens your
bashrc
file in a text editor. -
Anywhere in the file, add the following lines:
export PATH="~/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"
-
Ctrl + O
andEnter
to save, andCtrl + X
to exit. -
Run:
source ~/.bashrc
.[!NOTE] This reloads the
bashrc
file in the system.
-
-
Run:
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
. -
Follow the instructions on the prompt.
-
Add
rust
as an environment variable, to do so:-
Run:
source $HOME/.cargo/env
. -
Run:
source ~/.bashrc
.[!NOTE] This reloads the
bashrc
file in the system.
-
-
Before installing poetry, you will need a version of Python. Any version will do. We will use pyenv to download one and set is as the global system version.
- Run:
pyenv install -l
. This will display a list of all available versions of Python to install. - Run:
pyenv install 3.11.4
.
[!NOTE] At the time of writing, the latest stable build is
3.11.4
, so we will install this one. You can install any version, however.- Now set is as the global default, for this, run:
pyenv global 3.11.4
. - Verify this is set correctly, run:
pyenv versions
, make sure3.11.4
is there and is highlighted with an asterisk*
, denoting it as the global Python installation.
- Run:
-
Now, we are ready to install Poetry. Run:
curl -sSL https://install.python-poetry.org | python3 -
.[!WARNING] If this does not work:
-
Option 2:
- Run:
apt-get install pipx
. - Run:
pipx install poetry
.
- Run:
-
Option 3:
- Run:
pip install poetry
. - Follow the instructions here.
- Run:
-
-
We need to add
poetry
to ourbashrc
file, to let the package be called anywhere in the system (without needing to be in the program's folder). This is called adding to your PATH. To do so:-
Run:
nano ~/.bashrc
.[!NOTE] This opens your
bashrc
file in a text editor. -
Anywhere in the file, add the following line (replace
YOUR_USER_NAME
for your username without crochets):export PATH="/home/[YOUR_USER_NAME]/.local/bin:$PATH"
. -
Ctrl + O
andEnter
to save, andCtrl + X
to exit. -
Run:
source ~/.bashrc
.[!NOTE] This reloads the bash file in the system.
-
Run
poetry --version
to check that the installation was successful and that you have a version of Poetry in your machine.
-
Important
It is highly recommended you run this option change now: poetry config virtualenvs.in-project true
. This will prompt Poetry to install your virtual environment in the project directory itself, rather than on your machine. This virtual environment is still specific to your machine and will be ignored by git. There are advantages and drawbacks to enabling this option. One of the advantages is that, when deleting the project directory, you will delete all the dependencies with it, thus not cluttering your machine with virtual environments.
- Run:
sudo apt-get install git-all
.
- Run:
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y`.
-
Create a git repository.
- Go to 5 - Create a git repository.