Skip to content

Setup development environment

Prerequisites:

  • This project uses pdm ⧉ as package manager
  • A Postgres DB v14+
  • A Redis server

Note

PDM will create a virtualenv in /.venv, and install dependencies into it. If you wand to change this behaviour please read the PDM Documentation ⧉

Create virtualenvironment

  1. Checkout code

    git clone https://github.com/bitcaster-io/bitcaster
    git config branch.autosetuprebase always
    
  2. In the shell:

    uv ven
    source .venv/bin/activate
    
  3. Install the package

     uv sync
     uv run pre-commit install
    
  4. Add export PYTHONPATH="$PYTHONPATH:./src"

  5. Check your environment:

    ./manage.py env --check and configure the missing variables.

    Hint

    You can generate a list for your development environment with the command

    ./manage.py env --develop --config --pattern='export {key}={value}'
    
  6. Run upgrade command to properly initialize the application:

    ./manage.py upgrade --admin-email ${ADMIN_EMAIL} --admin-password ${ADMIN_PASSWORD}

    Note

    Django migrations and collectstatic commands are automatically included in this step

Configure environment for .direnv

If you want to use direnv ⧉ and automatic loading of environment variables from a .envrc file:

./manage.py env --develop --config --pattern='{key}={value}' > .envrc

echo 'export PYTHONPATH="$PYTHONPATH:./src"' >> .envrc
echo 'eval $(pdm venv activate)' >> .envrc
echo "unset PS1" >> .envrc

Warning

The first time after you have created or modified the .envrc file you will have to authorize it using:

direnv allow