Skip to content

CnCNet/cncnet-map-api

Repository files navigation

CnCNet Map Browser API

The backend for the CnCNet map browser.

UI is here https://github.com/CnCNet/cncnet-map-ui

Kirovy

The mascot for the backend API is Kirovy, by Direct & Dominate

Kirovy enjoying his job

Development

Frontend devs

Just set up your environment file and run the full docker compose.

Example env file

Backend devs

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.

  1. Download and install pyenv
  2. Install PostgreSQL for your system. This is required for Django
    • On Mac you can do brew install postgresql if you have brew installed.
  3. Install LibMagic for Python Magic
    • On Mac you can do brew install libmagic if you have breq installed.
  4. Checkout the repository
  5. Switch to the repository directory
  6. 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
  7. Setup requirements pip install -r requirements-dev.txt
    • On Apple Silicon you'll need to install lzo with brew install lzo then run CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install -r requirements-dev.txt to get python-lzo to install. You shouldn't need to include those flags again unless python-lzo updates.
  8. Install the pre-commit hooks pre-commit install
  9. 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.
  10. Run the db service in docker-compose
  11. Load your .env file into your shell, (you can use source load_env.sh && read_env) then migrate the database ./manage.py migrate
  12. ./manage.py runserver

You can technically use PyCharm to launch everything via docker-compose, but there is some weird issue with breakpoints not triggering.

Running tests

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

About

The CnCNet map server rewritten in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages