Skip to content

Installation

RachelMurray-Watson edited this page Jul 2, 2024 · 26 revisions

Installation

This guide is for a completely fresh set up of everything required to start working with the TLO project. Whilst we currently only have Windows & Mac setup, Linux steps will be similar.

NB. Windows users -- this is the (outdated but still useful - need to install Git-LFS) video showing the complete setup: https://www.dropbox.com/s/3ml5kmvh5nghj06/WindowsSetup.mp4?dl=0

Shared steps

Sign up for a free license for PyCharm (and other IntelliJ products)

  • Navigate to https://account.jetbrains.com/login and sign in or create an account, making sure to click the verify email link
  • Once logged in, navigate to https://www.jetbrains.com/student/ to get a staff/student license, scrolling down the page to the Apply Now button. Most likely using your university email and a picture of your university ID card. The process should take a couple of days. In the meantime you can use the professional version of pycharm as a trial evaluation.
  • For those without access to a school account, the PyCharm Community Edition can be used. It can be downloaded from this link (https://www.jetbrains.com/pycharm/download/other.html). Although the community edition has a few limitations, it should suffice for most of the TLOModel requirements. So far, all tests and processes using the community edition have been successful.

Git & Git-LFS

MacOS users already have git installed. Windows users should install Git for Windows.

Both MacOS and Linux users need to install Git LFS to handle large files in the repository.

Windows installation

Video walkthrough

Mac installation

1. Install Anaconda

  • Navigate to https://www.anaconda.com/download and provide your email to activate the download page below. While the model should be able to run on Python 3.6 or higher, the recommended version for Python is 3.11; this will ensure consistency with the entire development team. Based on the operating system you are running, click the download link under the OS of your choice, in this case, Mac OS.

Download-Now-Anaconda

  • Run the installer, clicking continue and accepting as required, using the default settings

2. Install and set up PyCharm

  • Navigate to (https://www.jetbrains.com/pycharm/download/other.html)
  • Click the Download button underneath the Professional version Other-Versions-PyCharm
  • Open the image and drag PyCharm into your Applications Folder Pycharm install
  • Open PyCharm.app from your Applications folder, accepting the user agreement and clicking Skip Remaining and Set Defaults Pycharm defaults
  • A License Activation window will open, if you already have a license then enter in your login details that you created your IntelliJ/PyCharm account with, otherwise click evaluate for free (You can activate PyCharm later by going to the Menu bar Help > Register) PyCharm activate

3. Set up the TLOmodel in PyCharm

  • From the PyCharm welcome page, click Check out from Version control and select git pycharm vc

  • Select Log in to Github... and enter in your GitHub login information github

  • The TLOmodel repository should now be available from the dropdown URL input, select it and then click on the clone button TLO repo

  • Click Yes on the dialogue box asking if you want to open the TLOmodel directory

  • Click the Menu bar PyCharm > Preferences...

  • In the dialogue box navigate to Project: TLOmodel > Project Interpreter interpreter

  • Click on the settings cog on the right and select Add...

  • Select Conda environment from the left hand panel, and set the Python Version to 3.6 (outdated: Version 3.8 should be used, also the print screens are outdated a bit) (now 3.11 should be used), then click OK. Add conda env

  • In the Preferences window there will be a green circle button that is highlighted, click it to remove the highlighting and then click Apply (this will now install packages using pip, not conda). remove conda package manager

  • Still in the Preferences window, navigate to Tools > Python Integrated Tools

    • Set the Package requirements file to be TLOmodel/requirements.dev.txt by clicking on the folder icon and browsing for the file.
    • Change the Default test runner to pytest and click OK to close the Preferences window Integrated tool setup
  • Click on the Terminal button at the bottom of the pycharm window and enter in the following text, hitting the enter key after each line.

    pip install -r requirements/dev.txt
    pip install -e .
  • To build the documentation, run:

    tox -e docs

4. Set up default working directory

  • At the top of your PyCharm window, click on Add Configuration... Add configuration
  • Click on the Spanner Icon (Edit Defaults or Edit Templates)
  • Select the Python Template from the side menu
  • In the Working directory option, click on the folder icon and use this to set it to be the base of the TLOmodel directory and click Apply

5. Confirm that the setup is correct using the tests

  • Still in the Configuration Window from the last step
  • Click the plus icon to the top left of the Configuration window and select Python tests > pytest New pytest configuration
  • A new configuration will appear Empty Pytest config
  • Set the Target input by clicking on the folder icon, and select TLOmodel > tests, click the Open button Test Directory
  • Set up default working directory by clicking on the folder icon in the Working directory option, and use this to set it to be the base of the TLOmodel directory and click Apply
  • The configuration window should now look something like this, click OK Configured pytest
  • At the top of the screen, there will now be a configuration, you can click on the green arrow to run the tests Run pytest
  • A new run panel will open up and pytest will run for a fair while, after it completes it will say that all of the tests have passed pytest running
  • You can scroll down the window and the final lines should look something like this pytest complete

6. If you have not set up git before

  • You can skip this section if you've set up your details in git

  • Click on the Terminal button as before and enter in the following commands, replacing your Name and Email but keeping the quotes. Hit enter after each line

    git config --global user.name "Stefan Piatek"
    git config --global user.email "[email protected]"
Clone this wiki locally