|
| 1 | +ADVANCED INSTALLATION NOTES FOR DEVELOPERS AND ADVANCED USERS |
| 2 | + |
| 3 | +If you are prone to work with more than one version of switch, you will |
| 4 | +greatly benefit from python virtual environments which isolate your project's |
| 5 | +python software from other versions that may be installed on the computer. |
| 6 | +Software requirements and compatibilities change over time, sometimes in |
| 7 | +incompatible ways. Virtual environments also help developers ensure they have |
| 8 | +included all necessary dependencies in setup.py and aren't relying on |
| 9 | +mannually installed system libraries. Using virtual environments to |
| 10 | +encapsulate each project's customized software allows active and archived |
| 11 | +projects to coexist on a single computer. These instructions assume you have |
| 12 | +read INSTALL, have installed Anaconda (or equivalent), pip and solver |
| 13 | +prerequisites. |
| 14 | + |
| 15 | +INSTALLATION WITH PYTHON VIRTUAL ENVIRONMENTS FOR DEVELOPMENT |
| 16 | + |
| 17 | +1. Open either a terminal or Anaconda command prompt (Start -> Anaconda -> |
| 18 | + Anaconda Prompt) |
| 19 | + |
| 20 | +2a. DEVELOPERS |
| 21 | + Developers often work with switch example directories and don't necessarily |
| 22 | + have a separate folder with inputs for analysis. In this case, the source |
| 23 | + directory doubles as your project directory. Execute these commands, but |
| 24 | + set PROJECT_DIR to the actual path you want to use. |
| 25 | + PROJECT_DIR=/path/to/new/switch/checkout |
| 26 | + SRC_DIR="$PROJECT_DIR" |
| 27 | + |
| 28 | +2b. ANALYSTS |
| 29 | + Analysts typically have a directory per project that stores data for their |
| 30 | + input scenarios as well as a copy of the code they are using. Execute these |
| 31 | + commands, but set PROJECT_DIR to the actual path you want to use. |
| 32 | + PROJECT_DIR=/path/to/project/directory |
| 33 | + SRC_DIR="$PROJECT_DIR"/switch_source |
| 34 | + |
| 35 | + Note: If you are using one of Matthias's packaged scenarios with a |
| 36 | + submodule or subtree, set SRC_DIR to that subfolder instead of doing a |
| 37 | + fresh git checkout. In this case, skip step 3. |
| 38 | + |
| 39 | +3. Download a copy of switch |
| 40 | + git clone https://github.com/switch-model/switch.git "$SRC_DIR" |
| 41 | + |
| 42 | +4. Create a virtual environment in your project directory, and install switch |
| 43 | + and its prerequisites. |
| 44 | + cd "$PROJECT_DIR" |
| 45 | + pip install virtualenv |
| 46 | + virtualenv venv |
| 47 | + source venv/bin/activate |
| 48 | + pip install --editable "$SRC_DIR" |
| 49 | + |
| 50 | + Note: The --editable flag ensures that any changes to your downloaded copy |
| 51 | + of switch will be immediately reflected to your installed copy in the |
| 52 | + virtual environment. |
| 53 | + |
| 54 | +5. Record the exact version of every library you are using so you can |
| 55 | + precisely replicate this setup in the future. |
| 56 | + pip freeze > requirements.txt |
| 57 | + Without this step, you are at higher risk of not being able to readily |
| 58 | + repeat or extend this analysis, especially if future releases of libraries |
| 59 | + are not completely backwards compatible (this has happened a few times in |
| 60 | + the past few years). |
| 61 | + |
| 62 | + |
| 63 | +EXECUTION |
| 64 | + |
| 65 | +1. Open either a terminal or Anaconda command prompt (Start -> Anaconda -> |
| 66 | + Anaconda Prompt) and navigate to your project directory. |
| 67 | +2. Activate your virtual environment with the following command: |
| 68 | + source venv/bin/activate |
| 69 | +3. Execute switch like normal |
| 70 | + switch solve ... |
0 commit comments