hub/MACOS_INSTALL.md

174 lines
8.1 KiB
Markdown
Raw Normal View History

2022-05-02 17:56:30 -04:00
# MACOS_INSTALL
2022-05-09 15:55:46 -04:00
This is an installation guide for macOS, covering all the steps needed to begin developing code for the Urban Simulation
Platform 'Hub'. At the end of this process you will have installed and configured all the necessary applications,
set up your own project on CERC's Gitlab and created your first python file.
2022-05-02 17:56:30 -04:00
## Prepare your environment
2022-05-02 17:56:30 -04:00
To develop any new code for the Urban Simulation Platform you must have the right software applications installed and configured.
The Platform is written in python and so the applications you need are:
* Python Interpreter
* Python Editor
2022-05-09 15:55:46 -04:00
* @Chris: Miniconda??
2022-05-09 15:55:46 -04:00
You also need to register a user account with the CERC's code repository on Gitlab and have the necessary permissions for
creating new code. For that purpose, please, contact Guillermo (guillermo.gutierrezmorote@concordia.ca) or
Koa (kekoa.wells@concordia.ca) as soon as possible.
2022-05-02 17:56:30 -04:00
### Get a Python interpreter
2022-05-09 15:55:46 -04:00
2022-05-02 17:56:30 -04:00
1. Download the latest version of python for macOS: [Python environment](https://www.python.org/downloads/)
2. Open the downloaded .pkg file and follow the instructions to install.
2022-05-02 17:56:30 -04:00
### Get a Python editor
2022-05-09 15:55:46 -04:00
1. You will need a python editor in order to import the existing Hub source code and to write your own python code.
Whilst this is a personal choice we would like to recommend [PyCharm Community Edition](https://www.jetbrains.com/pycharm/download/#section=mac),
an excellent open-source python editor.
2022-05-02 17:56:30 -04:00
2. Open the downloaded .dmg file and then drag the PyCharm CE app into your Applications folder.
2022-05-02 17:56:30 -04:00
![pycharm ce](docs/img_macos_install/img_0.png)
2022-05-02 17:56:30 -04:00
## Get the CERC Hub source code
2022-05-02 17:56:30 -04:00
1. Run PyCharmCE
2. Click on the **Get from VCS** button in the top right of the window.
2022-05-02 17:56:30 -04:00
![get_vc_1](docs/img_macos_install/img_1.png)
2022-05-02 17:56:30 -04:00
3. Select **Git** as the **Version control**. For the URL use the link to the Hub repository, as seen below.
2022-05-02 17:56:30 -04:00
![get_vc_2](docs/img_macos_install/img_2.png)
2022-05-09 15:55:46 -04:00
(You can also copy this URL by going to the Hub repository in [Gitlab](https://rs-loy-gitlab.concordia.ca/Guille/hub.git)
2022-05-02 17:56:30 -04:00
and clicking on the Copy URL button next to **Clone with HTTPS**)
![git_lab](docs/img_macos_install/img_3.png)
2022-05-02 17:56:30 -04:00
The Directory to store the Hub source code locally is automatically created for you. Edit this if you prefer it to be stored somewhere else.
2022-05-02 17:56:30 -04:00
Note: If you see a message saying Git is not installed, click on the **Download and install** and follow instructions.
2022-05-09 15:55:46 -04:00
4. Click the **Clone** button to download CERC Hub source code.
2022-05-02 17:56:30 -04:00
(If the macOS security asks if you trust executing this source code, you can click **Trust Project**.)
2022-05-02 17:56:30 -04:00
![trust_project](docs/img_macos_install/img_4.png)
You will then see the project directories and files below, with the hub readme document displayed.
You have successfully cloned a copy of the CERC hub onto your computer.
2022-05-02 17:56:30 -04:00
![hub_readme](docs/img_macos_install/img_5.png)
2022-05-02 17:56:30 -04:00
## Create Your Own Branch of the Hub
2022-05-09 15:55:46 -04:00
You now need to create a new **Branch** of the Hub source code. This is like your own special version of the Hub,
where you can safely integrate your model, without affecting the smooth running of the Main Branch Hub and the Platform.
To create your working branch you need rights to edit the project. Please, contact Guillermo (guillermo.gutierrezmorote@concordia.ca)
or Koa (kekoa.wells@concordia.ca) to get those rights and then follow the instructions.
2022-05-02 17:56:30 -04:00
1. Create your working branch by right-clicking on the project folder (hub) and then selecting **Git->New Branch...**
2022-05-02 17:56:30 -04:00
![new_branch](docs/img_macos_install/img_6.png)
2022-05-02 17:56:30 -04:00
2. Give a name to your branch that has some sense of what will be done with it, _updating_documentation_,
_lca_classes_,... And, click on the **Create** button.
2022-05-02 17:56:30 -04:00
![name_branch](docs/img_macos_install/img_7.png)
2022-05-02 17:56:30 -04:00
3. Click on the **Git** button in the bottom-left corner to pop-up the window showing the Git information.
See your new branch has been created under _Local_.
2022-05-02 17:56:30 -04:00
![branch_in_local](docs/img_macos_install/img_8.png)
2022-05-02 17:56:30 -04:00
4. Now we need to let the CERC Gitlab repository know about this new branch. You do this by right-clicking on
your branch and selecting **Push...** from the drop-down menu.
2022-05-02 17:56:30 -04:00
![push_branch_1](docs/img_macos_install/img_9.png)
2022-05-02 17:56:30 -04:00
5. Then click on the **Push** button at the bottom-right of the **Push Commits** window.
2022-05-02 17:56:30 -04:00
![push_branch_2](docs/img_macos_install/img_10.png)
2022-05-02 17:56:30 -04:00
Note - at this point you may need to login to Gitlab using you Concordia credentials.
2022-05-02 17:56:30 -04:00
![gitlab_credentials](docs/img_macos_install/img_11.png)
2022-05-02 17:56:30 -04:00
Check that your branch now appears in the _Remote_ branch hierarchy, in the bottom-left corner. If it does not appear,
2022-05-09 15:55:46 -04:00
contact Guille (guillermo.gutierrezmorote@concordia.ca) or Koa (kekoa.wells@concordia.ca), to find the reason of the error.
2022-05-02 17:56:30 -04:00
![branch_pushed](docs/img_macos_install/img_12.png)
2022-05-02 17:56:30 -04:00
## Configure Pycharm
2022-05-02 17:56:30 -04:00
When integrating your model with the Platform, it is important that you follow [CERCs coding style guidelines](PYGUIDE.md).
2022-05-09 15:55:46 -04:00
One of the rules is that we use two spaces as a tab instead of the standard [pep8](https://www.python.org/dev/peps/pep-0008/)
four spaces indentation. This option can be configured in PyCharm at the settings screen.
2022-05-02 17:56:30 -04:00
To access the settings screen, click on the gear icon in the top right corner, and select **Preferences** from
the drop-down menu. The Preferences window will appear. From the panel on the left, select
**Editor->Code Style->Python** and you will see where tab size can be changed. Change it to 2.
See the picture below.
![configure_pycharm](docs/img_macos_install/img_13.png)
2022-05-02 17:56:30 -04:00
## Set up a new project on Gitlab
2022-05-02 17:56:30 -04:00
1. Open a browser and to the [CERC Git](https://rs-loy-gitlab.concordia.ca/). Click on the blue **New project** button.
2022-05-02 17:56:30 -04:00
![git_new_project](docs/img_macos_install/img_14.png)
2022-05-02 17:56:30 -04:00
2. Choose the **Create blank project** option from the three options seen below.
2022-05-02 17:56:30 -04:00
![blank_project](docs/img_macos_install/img_15.png)
2022-05-09 15:55:46 -04:00
3. Type in a name (remember to follow the CERC naming conventions described in the ![Coding Style](PYGUIDE.md)).
Check the option **Initialize repository with a README**, and ideally, check the **Visibility Level** to be **Public**.
Then click on the **Create project** button.
2022-05-02 17:56:30 -04:00
![project_created](docs/img_macos_install/img_16.png)
You should then see a confirmation screen with all the information about your new project.
![confirmation_project](docs/img_macos_install/img_17.png)
## Get your project into Pycharm
1. Now you can make a clone of this project, within PyCharm. First, copy the URL by clicking on the blue **Clone** button
and then click on the **Copy URL** button next to the **Clone with HTTPS** link.
![copy_https](docs/img_macos_install/img_18.png)
2022-05-02 17:56:30 -04:00
2. Switch back to PyCharm and close the Hub project by choosing **File->Close Project**. You will then see the
**Welcome To PyCharm** window again.
2022-05-02 17:56:30 -04:00
3. Clone a copy of your Project into PyCharm, following the steps 2-6 of the _GET THE CERC HUB SOURCE CODE_
section above, but using the URL link that you just copied for your gitlab project.
4. Select **Pycharm->Preferences** to open the **Preferences** window. From the panel on the left click on
**Project:<project name> -> Project Structure**.
![new_project_in_pychaem](docs/img_macos_install/img_19.png)
5. Add the Hub project to your own, by clicking on Add Content Root: (Pilar, this is where it all went wrong for me :-) )
## Create your first Python file
Add your first file to your project and click on install requirements to automatically download all the dependencies
(in blue at top-right corner).
When all the dependencies are satisfied, you are all set to start importing your first city model.
Add the following code to your main.py
from imports.geometry_factory import GeometryFactory
city = GeometryFactory('citygml', 'myfile.gml').city
2022-05-02 17:56:30 -04:00
Always remember to push your own project changes as the last thing you do before ending your working day!
First, commit your changes by clicking on the green check in the top-right corner of Pycharm. Add a comment
that explains briefly your changes. Then, pull by clicking on the blue arrow to be sure that there are no
conflicts between your version (local) and the remote one (gitlab). Once the conflicts are solved and the merge in
local is done, push the changes by clicking on the green arrow.