The backend for the CnCNet map browser.
UI is here https://github.com/CnCNet/cncnet-map-ui
The mascot for the backend API is Kirovy, by Direct & Dominate
Just set up your environment file and run the full docker compose.
You can use the docker files if you'd like, but Django + docker is known to have issue attaching to debuggers and hitting breakpoints, so here are the native OS instructions.
- Download and install pyenv
- Install PostgreSQL for your system. This is required for Django
- On Mac you can do
brew install postgresql
if you have brew installed.
- On Mac you can do
- Install LibMagic for Python Magic
- On Mac you can do
brew install libmagic
if you have breq installed.
- On Mac you can do
- Checkout the repository
- Switch to the repository directory
- Setup Python
- Install Python 3.12
pyenv install 3.12
or whatever the latest python is. - Setup the virtual environments
pyenv virtualenv 3.12 cncnet-map-api
- Set the virtual enviornment for the directory
pyenv local cncnet-map-api
- Install Python 3.12
- Setup requirements
pip install -r requirements-dev.txt
- On Apple Silicon you'll need to install lzo with
brew install lzo
then runCFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install -r requirements-dev.txt
to getpython-lzo
to install. You shouldn't need to include those flags again unlesspython-lzo
updates.
- On Apple Silicon you'll need to install lzo with
- Install the pre-commit hooks
pre-commit install
- Setup the environment variables
- Create a
.env
file at the root of the repo - Copy the contents of
example.env
to your.env
file. - Fill out the required values in
.env
- If the app doesn't run due to a missing required variable, add said variable to
example.env
because the person who made the variable forgot to do so.
- Create a
- Run the
db
service indocker-compose
- Load your
.env
file into your shell, (you can usesource load_env.sh && read_env
) then migrate the database./manage.py migrate
./manage.py runserver
You can technically use PyCharm to launch everything via docker-compose
, but there is some
weird issue with breakpoints not triggering.
I strongly recommend using PyCharm and the .env
plugin for running the PyTests.
All you need to do is run the database from docker-compose
, then launch the tests via PyCharm.
If you want to run the tests via CLI:
- Make sure your database is running from the docker compose file.
docker-compose start db
- Make sure your environment variables are setup and loaded to your shell. See backend dev setup
- Run
DJANGO_SETTINGS_MODULE="kirovy.settings.testing" pytest tests
Django should automatically run migrations as part of the test startup.
Run tests with docker compose:
docker-compose up --build test