Setting up a development environment on Fedora

This document describes the steps to set up a development environment by creating and initializing a Python virtual environment. As an example, Fedora 33 is used as the platform to develop Nitrate.

Get source code

Fork https://github.com/Nitrate/Nitrate to your own repository, then clone it to your local system.

git clone https://github.com/[your_github_name]/Nitrate.git

Create a virtual environment

Install database and devel packages. For development, SQLite is good enough as a database backend, however this guide uses PostgreSQL to serve the database to show more what Nitrate provides to help developers.

sudo dnf install -y \
    python3 python3-devel python3-pip gcc postgresql-server \
    graphviz-devel krb5-devel postgresql-devel

Initialize the PostgreSQL database and start the server:

sudo postgresql-setup --initdb
sudo systemctl start postgresql

Create a virtual environment and install dependencies:

cd path/to/code
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install .[pgsql,krbauth,docs,tests,devtools,async,bugzilla,socialauth]

Initialize database

Add this line to /var/lib/pgsql/data/pg_hba.conf:

local    all     all     trust

Note

How the local PostgreSQL server instance is configured depends on how you want the Nitrate to connect to the server. Above line is just an example FYI. In practice, you are free to change it any value to fulfill your requirement.

Note that, once you change it, please remember to also change the default values to NITRATE_DB_* environment variables accordingly. Refer to the Makefile target db_envs or the output from DB=pgsql make db_envs.

Create database:

psql -U postgres -c "create database nitrate"

Migrate database:

. .venv/bin/activate
eval "$(DB=pgsql make db_envs)"
make migrate

Final Step

. .venv/bin/activate
eval "$(DB=pgsql make db_envs)"

Before running the server, you may need to create a superuser in order to manage the site during development:

make createsuperuser

As of now, it is ready to run Nitrate:

make runserver

Open http://127.0.0.1:8000/ and there should be brand new Nitrate homepage!