- Clone repository
- Include submodules by either passing
--recursiveflag togit cloneor - Run
git submodule update --init --recursiveafter the fact
- Include submodules by either passing
- Install Python 3.11
- [Optional] Create a virtual environment
python3 -m venv venvand activate it- Windows:
venv\Scripts\activate.ps1 - *nix:
source venv/bin/activate
- Windows:
- Install dependencies
python3 -m pip install -r requirements.txt - Run a redis server and specify host + port in
.env - Acquire osu! and discord developer credentials (client ID and client secret)
- Discord developer portal -> Create new application -> OAuth2 -> Client ID & Client Secret
- For development, add
http://127.0.0.1:8000/auth/discord/discord_codeto the list of allowed redirect URLs
- For development, add
- osu! account settings page -> Scroll down to OAuth -> New OAuth application
- For development, add
http://127.0.0.1:8000/auth/osu/codeto list of allowed redirect URLs
- For development, add
- Discord developer portal -> Create new application -> OAuth2 -> Client ID & Client Secret
- Database setup
- For development purposes, a SQLite database should suffice. In
fivedigitworldcup/settings.pyin DATABASES dictionary:'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } - Alternatively, create a database at PlanetScale
- Once the databse is created, create a password. Select "Connect with: Django" and follow the instructions.
- Replace the database's
ENGINEwith'ENGINE': 'django_psdb_engine'for proper foreign key support.
- For development purposes, a SQLite database should suffice. In
- Run database migrations if not already done:
python3 manage.py migrate - Run a development server using
python3 manage.py runserver 127.0.0.1:8000- Discord and osu OAuth credentials are provided using environment variables:
- DISCORD_CLIENT_ID
- DISCORD_CLIENT_SECRET
- OSU_CLIENT_ID
- OSU_CLIENT_SECRET
- Discord and osu OAuth require a redirect URL to be specified. This defaults to http://localhost:8000 which is fine for local development. This redirect URL can be given using an environment variable
- OAUTH_REDIRECT_PREFIX
- Either export them to your shell or provide them when running
runserver:
- Discord and osu OAuth credentials are provided using environment variables:
OAUTH_REDIRECT_PREFIX="https://xxxxx.example.com:8000" \
DISCORD_CLIENT_ID="xxxxxxxxxx" \
DISCORD_CLIENT_SECRET="xxxxxxxxxx" \
OSU_CLIENT_ID="xxxxxxxxxx" \
OSU_CLIENT_SECRET="xxxxxxxxxxx" \
python3 manage.py runserver 127.0.0.1:8000
- Installing mysqlclient:
- First install
mysql-clientandpkg-configusing brew:brew install mysql-client pkg-config
- Export PKG_CONFIG_PATH and install
mysqlclientby itselfPKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig" python3 -m pip install mysqlclient~=2.2.0
- Install rest of dependencies:
python3 -m pip install -r requirements.txt
- First install