Skip to content
Mathieu Rampant edited this page Apr 3, 2024 · 18 revisions

For Windows Users, it is recommended to install all the programs as Administrator

Download and Install Python

  1. Check if you have Python (3.6+) installed by running python --version
  2. If you don't have python on your system, download the latest version on Python's Website
  3. Install it. Make sure to check "Add Python to PATH" on Windows

Download and Install Git

  1. Check if you have git installed by running git --version
  2. If you don't have it already, install Git using apt-get install git, dnf install git or yum install git. If you are running MacOS, simply run git --version and it should prompt you to install it If you are running Windows, I recommend installing git bash

Download and Install Pycharm

  1. Go to Pycharm Download Page
  2. Download the right version of Pycharm for your system
  3. Install it

Checkout NEMO github

  1. Start Pycharm and select "Checkout from Version Control", then select "Git"
  2. Use the following parameters:
  • URL: https://github.com/usnistgov/NEMO.git
  • Directory: <the directory where you want NEMO's code to be>
  1. The code should now be downloaded and the project should be available in Pycharm

Add Python Interpreter for NEMO

  1. Go to "File -> Settings" (windows) or "Pycharm -> Preferences" on MacOS
  2. Go to "Project: NEMO -> Project Interpreter"
  3. Click on "No Interpreter" then "Show All..."
  4. Click on "+" to create a new interpreter.
  5. Select "Virtualenv Environment". Base Interpreter should be already selected as the version you installed in step 1
  6. Click "Ok"

Enable Python Formatting with black

Starting in version 5.0.0, NEMO uses Black for python formatting. In order to have your code style checked automatically:

  1. In the bottom of the Pycharm IDE, click "Terminal"
  2. Execute pip install black to install Black on NEMO VirtualEnv
  3. Then either set it up in Pycharm or use pre-commit hooks
  4. To set it up directly in Pycharm:
    1. Go to "File -> Settings" (windows) or "Pycharm -> Preferences" on MacOS.
    2. Go to "Editor -> Code Style -> Python" and uncheck "use tab character"
    3. Go to "Tools -> Black" or "Tools -> Actions on Save -> Black -> Configure" and
    • Enable the two check-boxes under "Use Black formatter:"
    • Add --line-length=120 in the "Settings" field
    1. Click "OK"

Enable HTML Formatting with djlint

Starting in version 5.4.0, NEMO uses djLint for html formatting. In order to have your code style checked automatically:

  1. In the bottom of the Pycharm IDE, click "Terminal"
  2. Execute pip install djlint to install djLint on NEMO VirtualEnv
  3. Run djlint . --reformat --max-attribute-length=100 --max-line-length=120 after making changes to html files or use pre-commit hooks (see below)

Set up pre-commit hooks

To make code formatting easier, it is recommended to set up pre-commit hooks to have both python and html files automatically formatted.

  1. In the bottom of the Pycharm IDE, click "Terminal"
  2. Execute pip install pre-commit black djlint or pip install ./["dev-tools"] to install pre-commit and the other tools on NEMO VirtualEnv
  3. Enable hooks by running pre-commit install
  4. To run pre-commit hooks on all files, run pre-commit run --all-files

Create Settings for NEMO

  1. In the left side panel, right click on the main NEMO folder (not NEMO -> NEMO subfolder) and select "New -> Python File"
  2. Enter the name settings and confirm.
  3. In the settings.py file, if you see a notification to install package requirements, do it.
  4. In settings.py, paste the settings from Settings
  5. Make sure you have in settings.py:
    • import os
    • BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    • DEBUG = True
    • 'NEMO.middleware.RemoteUserAuthenticationMiddleware' is in middleware
    • Uncomment AUTHENTICATION_BACKENDS = ['NEMO.views.authentication.RemoteUserAuthenticationBackend']
    • ALLOWED_HOSTS = ['localhost']
    • use file email backend with EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'email_sink/')
    • database with name 'NAME': os.path.join(BASE_DIR, 'nemo.db'),
    • STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    • MEDIA_ROOT = os.path.join(BASE_DIR, 'resources/icons')
    • for file logging, use "filename": os.path.join(BASE_DIR, "nemo.log"),
    • for error_file logging, use "filename": os.path.join(BASE_DIR, "nemo_error.log"),

Initialize NEMO and populate database

  1. in the bottom of the Pycharm IDE, click "Terminal"
  2. execute pip install . (this step can take several minutes)
  3. execute python manage.py migrate
  4. execute python manage.py loaddata ./resources/fixtures/splash_pad.json

Start NEMO

  1. In the top right corner of Pycharm, click "Add Configuration..."
  2. Click "+" and select "Python", then enter the following:
  • "Name": start nemo
  • "Script Path": manage.py
  • "Parameters": runserver localhost:8000
  1. In "Environment Variables", add REMOTE_USER key and value captain
  2. In "working directory", select the NEMO folder
  3. Click "Apply"

You can now run your saved configuration and access NEMO at http://localhost:8000

If you want to login as someone else, simply change the REMOTE_USER environment variable to another username (like "ned" or "professor")