Setup for development - cma-open/cmatools GitHub Wiki

In order to install the repo and system ready for development

  • Note the system prerequisites
  • Download the code
  • Create the development environment
  • Install the system
  • Run system tests

Prerequisites

  • The system is being developed on Linux with Python >=3.9
  • Ensure git has been set up and configured on the development machine (use git config to check)

Code install (linux terminal)

  • Change directory to where your project repo will be located locally, e.g.
 mkdir github-repos
 cd github-repos
  • Create and move into a new project directory, e.g.
 mkdir cmatools-repo
 cd cmatools-repo
  • Clone the repo content from remote GitHub repo
  git clone https://github.com/cma-open/cmatools.git
  • Enter username and password at prompts (not required for public repos)

  • Move into the directory

 cd cmatools

The repo is now available for use and development

Download and install conda

  • Conda is used to manage the python environment and dependencies in which the package is developed and run
  • This step only needs to be done once per system / machine
  • Change directory into the project scripts directory

  cd scripts
  chmod +x install-miniconda.sh
  ./install-miniconda.sh
  • This will carry out a silent install of miniconda
  • If conda has already been installed you will see notices, if so move on to the next step

To test your conda installation:

  • In your terminal window, run the command:
  conda list
  • Update conda to latest version
  conda update -n base -c defaults conda

Setup the development environment

  • The name and content (packages to be installed) of the conda environment is set in the environment.yml file

  • This is ready for use, but can be edited and commited to change the packages used

  • https://github.com/cma-open/cmatools/blob/master/bin/environment.yml

  • Run this script to create a local isolated conda environment

  • From within the scripts directory

  chmod +x create-cmatools-conda-environment.sh
 ./create-cmatools-conda-environment.sh
  • Agree to the prompts in the terminal where required
  • Confirm the conda environments that are currently available
 conda info --envs
  • Confirm the installed packages within the active environment
  conda list

Activate the conda environment

Check the currently available environments, then activate the desired environment

 conda info --envs
 conda activate cmatools-env

Install the package - with develop option

When the conda environment is activated then any installation will occur into this environment and be isolated

  • Change directory into the main project directory, then run setup
  cd ..
  pip install -e .

Run all tests

After installing the code, and at regular points during development, a tests can be run with the following script

 cd bin
 chmod +x runtests.sh
 ./runtests.sh