Changes

Jump to: navigation, search

Getting started with Gramps development

1,812 bytes added, 06:18, 26 January 2013
m
Gramps
{{man warn|Warning:|This tutorial is work in progress. Feel free to help and modify it.}}
This tutorial aims to help you in your first [http://en.wikipedia.org/wiki/Hacker_%28programmer_subculture%29 hacking ] of GRAMPSGramps. It will help you setting up a development environment and explain where to find the files you need.
This tutorial assumes that you are using GNU/Linux (but it might help under another OS) and that you know the basics of Python programming language.
== Optional : set up a development environment ==
{{man warn|Warning:|I highly recommend that you do not use your usual environment for developing GRAMPSGramps. Definitely do '''not''' work on your main GRAMPS Gramps family tree. Doing so may result in data loss in your GRAMPS Gramps Family Tree !}}
If you run your development version of GRAMPS Gramps as the usual user, it will show all your usual GRAMPS Gramps family trees, so loading one by mistake is possible and a bug may result in losing productive data. To prevent this, you could use a [[GRAMPSHOME]] environment variable to create a separate folder for productive data, see [[Run GRAMPS Gramps from a portable drive]] for more information.
Here are some options you may choose to prevent this. If you have enough resources, I recommend using VirtualBox.
=== VirtualBox ===
[http://www.virtualbox.org/ VirtualBox] is an open source virtualisation solution. Install it, run it and you have a virtual PC in your PC. Network connection works out of the box without extra configuration needed. Install your favorite Linux distribution and start hacking GRAMPS Gramps in a full fully separated environment.
=== Chroot ===
If you use Ubuntu, you can set up the chroot environment following these instructions:
[https://help.ubuntu.com/community/BasicChroot Creating a basic Ubuntu chroot]
If you use GRAMPS Gramps in a chroot jail with another Linux distribution, please add information here.
You should then have a working chroot environment in /var/chroot (or whichever location you chose).
sudo chroot /var/chroot
This means that within this directory, applications cannot access files without the chroot jail,
i.e. your GRAMPS Gramps install within the directory cannot destroy another install of GRAMPS Gramps in your usual home directory.
From a shell within your chroot directory, just svn-checkout the GRAMPS Gramps trunk into the chroot folder as usual.
Please note that before running the autogen-Script for generating makefiles, you may need to get some packages:
apt-get install python intltool libglib2.0-dev gedit
=== None of above ===
You have been warned! At a minimum name your test family trees 'a_test_name'. By starting with 'a_test' they show at the top of the family tree manager, and the test makes it clear what they are for.
 
[[Category:Developers/General|G]]
== Mac OS X ==
The last only works with X11, which is no longer included in OS X but can be installed separately. MacPorts can be built with/for either X11 or OS X's native Quartz graphics backend, and Gtk-OSX is exclusively for Quartz.
== Get the source tree Install a text editor ==To get the source tree, ;Whichever editor you will need SVN. Please have a look at the dedicated tutorial [[Brief introduction to SVN]] for details on getting the source trees for the latest current stable branch and the development trunk. You can also use a graphical SVN manager like "kdesvn" or "SVN Workbench". '''This tutorial now assumes you have downloaded GRAMPS' trunk into "~/gramps-trunk". If not, you have to change this path when make sure that it is used below.'''  {{man warn|Warning:|Let it be clear set up so that the settings directory "~/.gramps/" indent level is a '''different''' hidden directory in your home-dir4 spaces. Do not store anything thereuse the Tab character to indent.''}}
== Install a text editor ==The following is in alphabetic order. Choose the one you like. Whichever editor you use, make sure that it is set up so that the indent level is 4 spaces. Do not use the Tab character to indent.
=== Eclipse + pydev ===
First, you have to set the path to your python interpreter. Go in the menu "Window"->"Preferences...", then choose "Pydev"->"Interpreter - Python". With "new", you can create a link to "/usr/bin/python2.5". there you are.
Next, you have to set up a pydev project. Go in the menu "File" -> "New" -> "Project", and choose a Pydev projet. Project name could be "GRAMPS Gramps trunk", uncheck "Use defaults" and choose "~/gramps-trunk" as the project directory. Project type is "Python 2.6", and then you can press "Finish". You are now ready to start coding !
=== pycharm ===
'Version Control » Update Project' automatically syncs up with the svn (which it picks up from the .svn directories, unlike Eclipse+pydev that dumbly shows the .svn directories for me and keeps complaining on things going out of sync).
Some free software projects qualify for a Jetbrains free pycharm usage licences. We have applied for one to use in GRAMPS Gramps development, and currently GRAMPS Gramps has been awarded such a license -- as a consequence of the GRAMPS Gramps distribution terms (GPL). Here's what you should do to get a copy ('''and use it for GRAMPS Gramps development only, not for other work, under this license!'''), according to [[User:Bmcage|Benny]]:
1/ be a gramps developer with commit rights to our repository
2/ write [[User:BACbKA|Vassilii]] with your sourceforge login name and ask him for the license key
[http://kate-editor.org/ Kate] works well as a general editor for Python. It also recognizes key words of Python and marks them in colours. Kate is a Linux KDE desktop program. Of course, it also works on gnome installations.
"'''Idle" ''' is a handy simple editor that takes advantage of the interpreter features of Python. Often Idle comes with Python packages. Idle works well in Linux and other OS's, including the "dominant OS". If you install Windows version of Python, you will probably install from the same package Idle. One feature of Idle tends to confuse newcomers: Idle main window is NOT used for program writing, but for displaying the results. Notice that there is a Python tutorial, automagically installed with Idle on a Windows box. It is worth noting that the Tutorial gives quite extensive introduction into Python and is authored by the originator of Python: Guido van Rossum.
(If you have a favourite Editor and want to share it : describe how to set it up here.)
== Get the source tree ==To get the source tree, you will need SVN. Please have a look at the dedicated tutorial [[Brief introduction to SVN]] for details on getting the source trees for the latest current stable branch and the development trunk. (You could use [[Git]] rather than subversion if you prefer.) You can also use a graphical SVN manager like "kdesvn" or "SVN Workbench". '''This tutorial now assumes you have downloaded Gramps' trunk using SVN into "~/gramps-trunk" or using GIT into "~/Gramps". If not, you have to change this path when it is used below.''' {{man warn|Warning:|Let it be clear that the settings directory "~/.gramps/" is a '''different''' hidden directory in your home-dir. Do not store anything there.''}} == Run GRAMPS Gramps from the source ==To test that you did all well, you may want to run GRAMPS Gramps from your downloaded svn SVN tree or GIT tree. This is explained in the [[Brief introduction to SVN]] but or [[Git]]; here are the quick steps :;Under SVN
cd ~/gramps-trunk
python setup.py build
;Under GIT cd ~/Gramps python setup.py build For the internationalization piece code to work, you need to have the translation tools. You obviously also need subversion (SVN) or GIT and friends.  On Debian, just run (as root) - ('''Only if Debian installs Gramps 4.0+ as Gramps version!):
apt-get build-dep gramps
On Fedora 8 - 10(Fedora is up to version 17 now so does this still apply?), you will need:
yum install intltool gettext subversion rcs
=== Option 1: run from source repo ===
Here, we use the code in (for SVN use: gramps-trunk / for GIT use: Gramps ) to run Gramps. '''This means that compiled python files will be stored there. This is not ideal, but the easiest way to develop Gramps, as changes are immediately picked up by the code., use option 2 to develop'''
Copy the const.py file created in build to your source directory if you want to use your source directory to work with Gramps:
PYTHONPATH=/usr/local/lib/python2.7/site-packages/ LD_LIBRARY_PATH=/usr/local/lib python Gramps.py
=== Option 2: use the build code (SVN)===Here, we use the code build in ''gramps-trunk/build '' to run Gramps. For this, do
cd ~/gramps-trunk/build/lib.linux-x86_64-2.7/
python -c 'from gramps.grampsapp import main; main()'
or again more generally
PYTHONPATH=~/gramps-trunk/build/lib.linux-x86_64-2.7/:/usr/local/lib/python2.7/site-packages/ LD_LIBRARY_PATH=/usr/local/lib python grampsapp.py
 
'''Note''': at the time of writing, only the last, so using grampsapp.py works, as not all imports in Gramps have been converted to relative or absolute imports. This conversion will be finished by end of 2012 however.
 
=== Option 2: use the build code (GIT)===
Here, we use the code build in ''Gramps/build'' to run Gramps. For this, do
cd ~/Gramps/build/lib.linux-x86_64-2.7/
python -c 'from gramps.grampsapp import main; main()'
 
Again, it might be needed to set with PYTHONPATH where dependencies can be found, and with LD_LIBRARY_PATH link libraries, see option 1.
 
If you point your PYTHONPATH to the build directory, you can actually run Gramps from a random directory. Like this:
 
cd
PYTHONPATH=~/Gramps/build/lib.linux-x86_64-2.7/ python -c 'from gramps.grampsapp import main; main()'
 
So, more general:
cd
PYTHONPATH=~/Gramps/build/lib.linux-x86_64-2.7/:/usr/local/lib/python2.7/site-packages/ LD_LIBRARY_PATH=/usr/local/lib python -c 'from gramps.grampsapp import main; main()'
 
If the build directory is in your PYTHONPATH, you can also just execute the grampsapp.py module. So this will work too:
cd ~/Gramps/build/lib.linux-x86_64-2.7/gramps
PYTHONPATH=~/Gramps/build/lib.linux-x86_64-2.7/ python grampsapp.py
 
or again more generally
PYTHONPATH=~/Gramps/build/lib.linux-x86_64-2.7/:/usr/local/lib/python2.7/site-packages/ LD_LIBRARY_PATH=/usr/local/lib python grampsapp.py
'''Note''': at the time of writing, only the last, so using grampsapp.py works, as not all imports in Gramps have been converted to relative or absolute imports. This conversion will be finished by end of 2012 however.
=== gramps/gen ===
This is Gramps' core. It defines genealogy objects (Person, Place, Note...), database classes, generic plugins, and database access :
* '''gramps/gen/db''' : GRAMPS Gramps Database Handling* '''gramps/gen/lib''' : The core library of GRAMPS Gramps objects* '''gramps/gen/proxy''' : Proxy class for the GRAMPS Gramps databases. This is a very powerful tool used to propose a filtered view of the database : Objects which are not marked private, (not) living persons...* '''gramps/gen/utils''' : Common utilities for GRAMPS Gramps code (progess monitor dialog, database utilities, callbacks between UI and database code)
=== other ===
* [[UI style]]
* [[Brief introduction to SVN]]
* [[Git|A guide for people who would like to use git rather than subversion (SVN). ]]
* [[Using database API]]
* [http://www.gramps-project.org/docs/ API Code Documentation] - Gramps v3.3.0
* [[Devhelp]]
 
[[Category:Developers/Tutorials]]
[[Category:Developers/General|G]]

Navigation menu