Change in rainfall 2001-2016, global tropics

Map: Change in rainfall 2001-2016, global tropics

Clone PyDev project from GitHub

Introduction

This post explains how to clone a PyDev project from GitHub.com directly into Eclipse. The example used is Karttur’s GeoImagine Framework. But to get the complete Framework operational, you have to do additional installations as described in my blog on Karttur’s GeoImagine Framework.

The advantages with cloning a project include that the project is directly linked (imported) to Eclipse and that you can easily accessupgrades from within Eclipse. But you can not push any changes back, unless you have the rights to the online GitHub repo. Alternatively you can also clone or download the GeoImagine Python project using GitHub Desktop or the Git command-line tool git. The advantage with the latter solutions is that you then separate the cloning and working with the code. These alternatives are detailed in the blog on Karttur’s GeoImagine Framework.

Prerequisites

You can clone Karttur´s GeoImagine Python project as described in here as long as you have Eclipse installed. To create a fully functional GeoImagine Framework you must also have installed the Spatial Data Integrated Development Environment (SPIDE) as described in the earlier posts in this blog and do some further manoeuvring as described in the blog on Karttur’s GeoImagine Framework.

Add GitHub repo to Eclipse

There are many online tutorials for cloning GitHub projects into Eclipse, but I have not found any that deals with cloning a PyDev project. And that is what is outlined in the rest of this post.

Clone GitHub repository with Eclipse

Start Eclipse. Once in, click the Open Perspective icon and select Git, or start writing “Git” in Quick access textbox.

Open Perspective in Eclipse

If you get different options for which perspective to select, click the alternative for Git and then Open it.

Select Git view in Eclipse

The view Git repositories should open (if not use the Quick access textbox and type Git, then select View –> Git repositories). In the Git repositories view you should click the alternative Clone a Git repository (if no text appears slide the cursor over the icons to get the alternative Clone a Git repository and add the clone to this view).

Git repositories alternatives in Eclipse.
Git repositories view in Eclipe.

In the dialogue window for Source Git Repository, fill in the url to the repository (you can copy the path from your GitHub.com account). Leave all other options with their defaults values (including empty).

Select/define Source Git Repository in Eclipse.

Click the Next > button. This will take you to the Branch Selection view. Make sure master is selected and again click Next >.

Select repository branch in Eclipse.

The next view is for Local Destination. Either accept the default or navigate and select your preferred destination path. The destination folder does not necessaily need to have the same name as the online repository (kt-gi-test01 in the example), but it is recommended. Click Next > to continue.

Select Local Destination for GutHub repository clone in Eclipse.

When ready, click Finish and the GitHub remote repository should be cloned to your local machine. If it worked properly you should see the cloned repository in the Git Repositories view.

Added Git Respositories in Eclipse.

Import GitHub project to Eclipse

My Map

Once imported, switch to the PyDev perspective. The perspectives available are in the upper right corner of the Eclipse window.

If the Python icon is not included among the predefined perspective icons, go via the menu system:

Window –> Perspective –> Open Perspective –> Other

Open Other perspictive via the Eclipse main menu.

In the options window that opens, select PyDev and then clock Open

Select PyDev perspective in Eclipse.

Managing GitHub submodules

You should now have Karttur´s GeoImagine Framework installed on your local machine, added with a cloned copy from Karttur’s GitHub repository. If your project sub-packages are missing or have no content, you have to run an update on the submodules.

Update submodules

The GitHub repo that holds the complete GeoImagine Framework is just an empty container with links to other repos that hold the actual codes (one repo per submodule or PyDev package). This is a special case, and requires that you update the submodules from inside Eclipse to clone the actual content of each submodule (and fill the packages with the actual code).

My Map

Switch perspective in Eclipse main window by clicking the Git icon in the upper right corner. If the icon for Git perspective is missing follow the same menu path as outlined above for switching to the PyDev perspective.

In the Git Repositories view, expand the project (i.e. click the filled arrow to the left of the project) to see the content (see figure below). You should then see the folder for Submodules. If you look inside a submodule, it is most probably empty. That is, as mentioned above, because the Framework repo is just an empty container that links to the repos with the actual code. To clone the complete content of the submodlues (i.e. the Python packages that build up the complete Framework), right click the Submodules and select Update Submodule from the pop-out menu.

Update Submodule in Eclipse.

It will take a while for the data to download, but then should have a complete copy, or clone, of the PyDev project repo from GitHub.com.

Karttur´s GeoImagine Framework

If you want to continue with Karttur’s GeoImagine Framework there are some additional steps required. As these steps are very specific they are covered in a separate blog on Karttur’s GeoImagine Framework. To continue directly from here in that blog, go to the post on prepare the database connection.

A note on editing the code

You can work with the cloned code and develop/improve it. But you can not push the changes back to the GitHub online repository (unless you have the login and password for Karttur´s GitHub pages). If you could, it would mean that the code of the master branches of the individual packages would change. All changes (updates) on the GeoImagine Framework is done using branches in each package repository, for which I have yet to write the instructions.