structure:
- src: contains all program files
- src.api: contains the api
- src.app: contains the database logic
- src.core: contains the core componetns
- src.core.database: contains all the database functionality
- Create fork of primary repo
- Download a clone of the forked repo
git clone <your github repo path url>
- Open a terminal to your cloned repo
- follow linux or windows sections for further setup
creating a python venv to work in and install the project requirements
python -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pre-commit install
Setup overview:
- install requirements: python, pip, make, docker
- create venv
python3 -m venv .venv
- activate venv
source .venv/bin/activate
- run setup
make setup
detailed guide in sections below
distros such as ubuntu, mint, pop, kali
sudo apt install make
sudo apt install python3-pip
distros such as fedora, centos, rocky
sudo yum install make
sudo yum install python3-pip
sudo pacman -Syu make
sudo pacman -Syu python3-pip
typically requires xcode command line tools from http://developer.apple.com/
or using homebrew from https://brew.sh/ (example below). note the command it installs is gmake
, ideally just make an alias make
by adding it to your bash profile
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew --version
Homebrew 4.1.17
brew install make
brew install python3-pip
add your alias to your bash profile (loaded on terminal start)
nano ~/.bash_profile
ctrl+x and enter to save once you have added the alias line (example below line to add)
alias make="gmake"
run the following command to create your venv
python3 -m venv .venv
next command is to activate your virtiual envionrment, you should see to the far left of your prompt showing you what env you are in
source .venv/bin/activate
if you ever need to get out of the virtual enviornment run the deactivate
command
deactivate
use the make
command with an action
when developing on linux. think of actions
as a list of predefined commands to help simplify common development routines.
make help
to see all avaiable actions
clean-pyc clean python cache files
clean-test cleanup pytests leftovers
docker-restart restart containers
docker-test restart containers & test
pre-commit-setup Install pre-commit
test-setup installs pytest singular package for local testing
requirements installs all requirements
create-env create .env file
setup setup requirements
docs opens your browser to the webapps testing docs
- docker
- python3
- local clone of repo
- terminal opened to cloned repos root path
With the Makefile we setup our development environment. it is important that you are in your python virtual environment (.venv) when you run this command.
the make setup
command will
- create a .env file,
- install precommit
- install requirements for testing
- install requirements for the project
make setup
You are now ready to develop code but you may want to read further, to know how to run & debug te code
with the Makefile we can easily start & shutdown the containers to a fresh state, under the hood we leverage docker compose
commands.
make docker-restart
run test
make docker-test
when you added some dependancies update the requirements
.venv\Scripts\activate
call pip freeze > requirements.txt
when you want to upgrade the dependancies
.venv\Scripts\activate
powershell "(Get-Content requirements.txt) | ForEach-Object { $_ -replace '==', '>=' } | Set-Content requirements.txt"
call pip install -r requirements.txt --upgrade
call pip freeze > requirements.txt
powershell "(Get-Content requirements.txt) | ForEach-Object { $_ -replace '>=', '==' } | Set-Content requirements.txt"
upgrading with linux
sed -i 's/==/>=/g' requirements.txt
pip install -r requirements.txt --upgrade
pip freeze > requirements.txt
if you are running the cluster
kubectl port-forward -n kafka svc/bd-prd-kafka-service 9094:9094
kubectl port-forward -n database svc/mysql 3306:3306