- 1. Summary of Development Setup
- 2. Setting up your system for the first time(The tedious way)
- 2.1 MacOS
- 2.2 Windows
- 2.3 Linux
- 3. Setting up your system for the first time (The Docker Way)
- 3.1 MacOS
- 3.2 Windows
- 3.3 Linux
- Working on new features
The Development Environment setup requires the use of the following tools/software:
- Package Management System
- Mac : Homebrew
- Windows : WSL(Although this is not a PMS, but we will use to install the tools/software on Windows)
- Linux : Yum(Red Hat), Pacman(Arch), Aptitude(Debian)
- Python - High-level programming language
- Git - Version control system
- SQLITE3 - Database Engine
- PostgreSQL - Relational DBMS
- Docker - Software platform that simplifies the process of building, running, managing and distributing applications(Environment Standardization Software)
- VS Code, Pycharm, Spyder - Integrated Development Environment - IDE
Before you go ahead and start setting up the development environment, we wanted to let you know that there are two ways you can do the development environment setup.
- The docker way (recommended - This is the easiest way to set up the development environment as it automatically sets up the entire environment for you and takes care of all the installation, also you are less likely to encounter errors)
- The tedious way (this can sometimes take long time and be a frustrating experience as you might encounter OS specific challenges during installation of various tools/software)
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, MacOS, as well as Linux source.
We will use Homebrew to install Python on our Mac. To use Homebrew for Python installation, we need to first install a compiler which we can get by installing Xcode's command-line tools.
To install the xcode, open a terminal on your system, and enter the following command.
xcode-select --install
Now that you have the Xcode's command-line tools installed, let's go ahead and install Homebrew.
To install Homebrew, paste the following command on your terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/homebrew/install/HEAD/install.sh)"
Note: Homebrew might need you to use one more command to add Homebrew to your PATH
, please carefully check if the Homebrew has NEXT STEPS for you on the terminal after the installation.
Now that we have Homebrew installed, let's go ahead and install Python3.
brew update
brew install python
To confirm that you have Python3 installed and can be accessed, please check this guide from official python installation for Mac.
In summary, you should be able to access Python3 with the command python3
. TIP : you can quickly check the Python version by entering the command below on the terminal
python3 --version
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git: Git official website, w3schools.
brew install git
To verify Git is installed correctly, you can run the following on the terminal.
git --version
The physionet-build uses sqlite3 as a quick database for local setup. Let's install that.
brew install sqlite3
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download it from official website and install it directly on your Mac.
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have the setup, let's go ahead and clone the project to your system. Open a terminal and enter the following command.
git clone https://github.com/MIT-LCP/physionet-build
Now that we have cloned the project to your system, let's go ahead and create a virtual environment, you can learn more about virtual environments in Python here.
In Summary, a virtual environment will let us install and keep different versions of the python library specific to individual projects.
Let's create a virtual environment for our project.
Open a terminal and enter the following command to navigate inside the project directory.
cd physionet-build
Now create the virtual environment with the following command on the same terminal.
python3 -m venv env
On the same terminal from step 2.1.7.1, enter the following command to activate the virtual environment.
source env/bin/activate
Now that we have the virtual environment set up, let's install the python libraries needed for the project.
On the same terminal from step 2.1.7.2, enter the following command to install the requirements.
pip install -r requirements.txt
TIP : If you see an error message about psycopg2-binary, you can open the requirements.txt inside the project directory and remove psycopg2-binary temporarily (and run the pip install -r requirements.txt
command again). Since we are using sqlite3, psycopg2-binary which is a PostgreSQL database adapter for the Python, is not needed for local development. After you have installed all the requirements, you can add it back to the requirements.txt file.
We now have everything set up to run the project locally, let's go ahead and set up the project
cd physionet-build
source env/bin/activate
cp .env.example .env
2.1.9.4 Run the following commands(on the same terminal from 2.1.9.3 ) to set up the database and compile the static files.
-
Run :
cd physionet-django
to navigate inside the django project -
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
Enter the following command to start the server.
python3 manage.py runserver
The local development server will be available at http://localhost:8000.
On Windows, we will use WSL (Windows Subsystem for Linux) to install Python and other dependencies. You can learn more about WSL on the official website.
WSL will install Ubuntu on your system by default, and you can use the Ubuntu terminal to install and run the project.
To install WSL, you can follow the official instructions.
Please make sure you update the WSL to WSL2, here is the official guide on how to upgrade to WSL2.
TIP : If you are not sure what is a CMD, here is a read about CMD and how to open it.
TIP: If you get error 0xc03a001a
when updating to WSL2 , please check this github issue on how to fix it.
Now that WSL is installed, let's go ahead and install Python3 on WSL.
Note: Check if you already have a Python3 installed on your system(if you already have the latest version of Python3, you won't have to do the step 2.2.2), to check enter the following on Ubuntu Terminal.
Please open the Ubuntu terminal and enter the following command to check if you have Python3 installed on your system.
python3 --version
On the Ubuntu terminal, enter the following commands to install Python3.
sudo apt update
sudo apt install software-properties-common gcc build-essential python3-dev python3-venv
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3
To confirm that you have Python3 installed and can be accessed, please check this guide for Python installation for Linux.
In summary, you should be able to access Python3 with the command python3
, you can quickly check the Python version by entering the command below on the terminal.
python3 --version
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git: Git official website, w3schools.
To install Git on Ubuntu, enter the following command on the Ubuntu terminal.
sudo apt install git
To verify Git is installed correctly, you can run the following in the terminal.
git --version
The physionet-build uses sqlite3 as a quick database for local set up. Let's install that.
To install sqlite3 on Ubuntu, enter the following command on the Ubuntu terminal.
sudo apt install sqlite3
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download the .exe package from official website and install it directly on your Windows by following the official instructions.
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have all the setup, let's go ahead and clone the project to your system. Enter the following command on the Ubuntu terminal to clone the project.
git clone https://github.com/MIT-LCP/physionet-build
Now that we have cloned the project to your system, let's go ahead and create a virtual environment, you can learn more about virtual environments in Python here.
In Summary, a virtual environment will let us install and keep different versions of the python library specific to individual projects.
Let's create a virtual environment for our project.
Open a Ubuntu terminal and enter the following command to navigate inside the project directory.
cd physionet-build
Now create the virtual environment with the following command on the same terminal.
python3 -m venv env
TIP : If you get a message like python3-venv is not installed
, please run the following command on the terminal and try again.
sudo apt install python3-venv
On the same terminal from step 2.2.8.1, enter the following command to activate the virtual environment.
source env/bin/activate
Now that we have the virtual environment set up, let's install the python libraries needed for the project.
On the same terminal from step 2.2.8.2, enter the following command to install the requirements.
pip install -r requirements.txt
TIP : If you see an error message about psycopg2-binary, you can open the requirements.txt inside the project directory and remove psycopg2-binary temporarily (and run the pip install -r requirements.txt
command again). Since we are using sqlite3, psycopg2-binary which is a PostgreSQL database adapter for the Python, is not needed for local development. After you have installed all the requirements, you can add it back to the requirements.txt file.
TIP : If you are having difficulty in opening the project in VS Code, you could open a Ubuntu terminal and enter the following command to open the project in VS Code.
cd physionet-build
code .
We now have everything set up to run the project locally, let's go ahead and set up the project.
cd physionet-build
source env/bin/activate
cp .env.example .env
2.2.10.4 Run the following commands(on the same terminal from 2.2.10.3) to set up the database and compile the static files.
-
Run :
cd physionet-django
to navigate inside the django project -
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
Enter the following command to start the server.
python3 manage.py runserver
The local development server will be available at http://localhost:8000.
Because Linux has many distros, please follow the guide from Real Python to set up Python3 based on your Linux system.
Here we have added instructions on installing Python3 on Ubuntu(Debian-based Linux Distro).
Open a terminal and enter the following commands.
sudo apt update
sudo apt install software-properties-common gcc build-essential python3-dev python3-venv
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3
To confirm that you have Python3 installed and can be accessed, please check this guide for Python installation for Linux.
In summary, you should be able to access Python3 with the command python3
, you can quickly check the Python version by entering the command below on the terminal.
python3 --version
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git Git official website, w3schools.
sudo apt install git
To verify Git is installed correctly, you can run the following in the terminal.
git --version
The physionet-build uses sqlite3 as a quick database for local set up. Let's install that.
sudo apt install sqlite3
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download the .deb package from official website and install it directly on your Linux by the following the official instruction.
sudo apt install ./<path to your downloaded vscode file>.deb
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have the setup, let's go ahead and clone the project to your system. Open a terminal and enter the following command.
git clone https://github.com/MIT-LCP/physionet-build
Now that we have cloned the project to your system, let's go ahead and create a virtual environment, you can learn more about virtual environments in Python here.
In Summary, a virtual environment will let us install and keep different versions of the python library specific to individual projects.
Let's create a virtual environment for our project.
Open a terminal and enter the following command to navigate inside the project directory.
cd physionet-build
Now create the virtual environment with the following command on the same terminal.
python3 -m venv env
TIP : If you get a message like python3-venv is not installed
, please run the following command on the terminal and try again.
sudo apt install python3-venv
On the same terminal from step 2.3.6.1, enter the following command to activate the virtual environment.
source env/bin/activate
Now that we have the virtual environment set up, let's install the python libraries needed for the project.
On the same terminal from step 2.3.6.2, enter the following command to install the requirements.
pip install -r requirements.txt
TIP : If you see an error message about psycopg2-binary, you can open the requirements.txt inside the project directory and remove psycopg2-binary temporarily (and run the pip install -r requirements.txt
command again). Since we are using sqlite3, psycopg2-binary which is a PostgreSQL database adapter for the Python, is not needed for local development. After you have installed all the requirements, you can add it back to the requirements.txt file.
We now have everything set up to run the project locally, let's go ahead and set up the project.
cd physionet-build
source env/bin/activate
cp .env.example .env
2.3.8.4 Run the following commands(on the same terminal from 2.3.8.3 ) to set up the database and compile the static files.
-
Run :
cd physionet-django
to navigate inside the django project -
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
Enter the following command to start the server.
python3 manage.py runserver
The local development server will be available at http://localhost:8000.
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, MacOS, as well as Linux source.
We will use Homebrew to install Git on our Mac. To use Homebrew for Git installation, we need to first install a compiler which we can get by installing Xcode's command-line tools.
To install the xcode, open a terminal on your system, and enter the following command.
xcode-select --install
Now that you have the Xcode's command-line tools installed, let's go ahead and install Homebrew.
To install Homebrew, paste the following command on your terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/homebrew/install/HEAD/install.sh)"
Note: Homebrew might need you to use one more command to add Homebrew to your PATH
, please carefully check if the Homebrew has NEXT STEPS for you on the terminal after the installation.
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git Git official website, w3schools.
brew install git
To verify Git is installed correctly, you can run the following in the terminal.
git --version
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download it from official website and install it directly on your Mac.
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have Git and VS Code set up, let's go ahead and clone the project to your system. Open a terminal and enter the following command.
git clone https://github.com/MIT-LCP/physionet-build
Let's go ahead and install Docker on our system, as promised this will take care of all the setup for us. We are nearly there.
Please follow the official installation guide to install Docker on your Mac.
Here is a recommended read on Docker.
Now that we have Docker installed, let's go ahead and build the project. It's as simple as running the following commands in the terminal.
cd physionet-build
cp .env.example .env
docker compose build
That should take care of all the setup for you, now let's go ahead start our server and load the demo data on our database.
To start our server, we can do it with a single command.
docker compose up
This will start our development server on http://localhost:8000, run the postgres database, development and test containers. Before you go ahead and play around with the project, we need to load the demo data on our test and development database (Note: we only need to load the demo data when doing the setup for the first time).
Note: We are using two databases, one for development and the other for testing. The reason for this is to make sure that the test database is always clean and we can run the tests without worrying about the data changes on the development database. To do that, we need to open a new terminal and run the following commands.
Navigate inside the project directory.
cd physionet-build
Enter the development container shell and navigate inside physionet-django
directory.
docker compose exec dev /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
In a new Terminal, enter the test container shell and navigate inside physionet-django
directory.
docker compose exec test /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files.
That's it, you are all setup and ready to go. You can now start playing around with the project on http://localhost:8000.
TIP: If you are trying to login as admin, you can use the forgot password option to reset your password. The email will be printed on the terminal where you started the server. Simply copy the link from the terminal and paste it in your browser to reset your password and login as admin.
Download Git bash from the official website and install it with the default settings.
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git: Git official website, w3schools.
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download the .exe package from official website and install it directly on your Windows by following the official instructions.
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have Git Bash and VS Code set up, let's go ahead and clone the project to your system. Open Git bash and enter the following command.
git clone https://github.com/MIT-LCP/physionet-build
Let's go ahead and install Docker on our system, as promised this will take care of all the setup for us. We are nearly there.
Please follow the official installation guide to install Docker on your Windows.
Here is a recommended read on Docker.
Now that we have Docker installed, let's go ahead and build the project. It's as simple as running the following commands in the terminal.
TIP : If you are not sure what is a CMD, here is a read about CMD and how to open it.
cd physionet-build
copy .env.example .env
docker compose build
That should take care of all the setup for you, now let's go ahead start our server and load the demo data on our database.
To start our server, we can do it with a single command.
docker compose up
This will start our development server on http://localhost:8000, run the postgres database, development and test containers. Before you go ahead and play around with the project, we need to load the demo data on our test and development database (Note: we only need to load the demo data when doing the setup for the first time).
Note: We are using two databases, one for development and the other for testing. The reason for this is to make sure that the test database is always clean and we can run the tests without worrying about the data changes on the development database. To do that, we need to open a new CMD and run the following commands.
Navigate inside the project directory.
cd physionet-build
Enter the development container shell and navigate inside physionet-django
directory.
docker compose exec dev /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
In a new CMD, enter the test container shell and navigate inside physionet-django
directory.
docker compose exec test /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files.
That's it, you are all setup and ready to go. You can now start playing around with the project on http://localhost:8000.
TIP: If you are trying to login as admin, you can use the forgot password option to reset your password. The email will be printed on the terminal where you started the server. Simply copy the link from the terminal and paste it in your browser to reset your password and login as admin.
Git is free and open-source software for distributed version control. We will use it later to clone the PhysioNet project to our system, and you can also use it to submit your contribution to the project. Here are a few resources to learn about Git Git official website, w3schools.
sudo apt install git
To verify Git is installed correctly, you can run the following in the terminal.
git --version
Visual Studio Code is a source-code editor that can be used with a variety of programming languages.
To set VS Code up, you can download the .deb package from official website and install it directly on your Linux by the following the official instruction.
After installing VS Code, you can install this Python extension on VS Code to get the support for IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. Simply visit the link above and click on the install button on the website, it should redirect and open the installation option on VS Code.
Now that we have Git and VS Code set up, let's go ahead and clone the project to your system. Open a terminal and enter the following command.
git clone https://github.com/MIT-LCP/physionet-build
Let's go ahead and install Docker on our system, as promised this will take care of all the setup for us. We are nearly there.
Please follow the official installation guide to install Docker on your Linux.
Here is a recommended read on Docker.
Now that we have Docker installed, let's go ahead and build the project. It's as simple as running the following commands in the terminal.
cd physionet-build
cp .env.example .env
docker compose build
That should take care of all the setup for you, now let's go ahead start our server and load the demo data on our database.
To start our server, we can do it with a single command.
docker compose up
This will start our development server on http://localhost:8000, run the postgres database, development and test containers. Before you go ahead and play around with the project, we need to load the demo data on our test and development database (Note: we only need to load the demo data when doing the setup for the first time).
Note: We are using two databases, one for development and the other for testing. The reason for this is to make sure that the test database is always clean and we can run the tests without worrying about the data changes on the development database. To do that, we need to open a new terminal and run the following commands.
Navigate inside the project directory.
cd physionet-build
Enter the development container shell and navigate inside physionet-django
directory.
docker compose exec dev /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files. -
Run :
python3 manage.py compilestatic
to compile the css files.
In a new terminal, enter the test container shell and navigate inside physionet-django
directory.
docker compose exec test /bin/bash
cd physionet-django
Run the following commands to set up the database
-
Run :
python3 manage.py resetdb
to reset the database with the latest applied migrations. -
Run :
python3 manage.py loaddemo
to load the demo fixtures set up example files.
That's it, you are all setup and ready to go. You can now start playing around with the project on http://localhost:8000.
TIP: If you are trying to login as admin, you can use the forgot password option to reset your password. The email will be printed on the terminal where you started the server. Simply copy the link from the terminal and paste it in your browser to reset your password and login as admin.
Now that you have completed your setup and have familiarized yourself with the codebase, here is how you can contribute and submit your changes for review.
- Create a new branch for each feature you work on.
- Work on your changes, add files and commit your changes.
- On commits, add a clear explanation of the changes. Here is an interesting read from freeCodeCamp about how to write a good commit message.
- Once your changes are final and ready to be submitted, push the changes and open a Merge Request. Someone will review your changes ASAP.
Here are some good resources to read about contributing to OpenSource projects, Python and Django.