Difference between revisions of "Mac OS X:Build from source:gtk-osx"

From Gramps
Jump to: navigation, search
(Page in process of creation, unfinished.)
 
(More page creation. Still incomplete, moduleset is wrong and patches half done. Hold on a bit.)
Line 35: Line 35:
 
Type
 
Type
 
* jhbuild bootstrap
 
* jhbuild bootstrap
to install a bunch of stuff from the web. A lot of text should scroll by, finishing with ** Success **.
+
to install a bunch of stuff from the web. A lot of text should scroll by, finishing with *** Success ***.
 +
 
 +
====Write definitions of the new programs====
 +
jhbuild needs a definition of the moduleset, the set of modules to build to make a program. It knows about most things (it fetches the definitions from the web) but not about a new python and not about gramps. I don't know hwo to provide a file here in the wiki for easy downloading, so I've pasted the text in here. Copy the text from here and paste it into the new file ~/Source/jhbuild/modulesets/python-gramps.modules
 +
 
 +
<?xml version="1.0" standalone="no"?> <!--*- mode: nxml -*-->
 +
<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
 +
<moduleset>
 +
  <tarball id="custompython" >
 +
    <source href="http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz"/>
 +
  </tarball>
 +
  <metamodule id="meta-python-2.6.2">
 +
    <dependencies>
 +
      <dep package="custompython" />
 +
    </dependencies>
 +
  </metamodule>
 +
  <tarball id="gramps" >
 +
    <source href="http://downloads.sourceforge.net/gramps/gramps-3.1.2.tar.gz"/>
 +
    <patches>
 +
    <patch file="gramps-3.1.2.patch" strip="0" />
 +
    </patches>
 +
  </tarball>
 +
  <metamodule id="meta-gramps-3.1.2">
 +
    <dependencies>
 +
      <dep package="gramps"/>
 +
    </dependencies>
 +
  </metamodule>
 +
</moduleset>
 +
 
 +
This file is telling jhbuild what "metamodules" (bunches of modules) are going to be built, what source is needed for each build, what patches are needed on the sources to make them work, and how to build them.
 +
 
 +
[Change this so the file just references modules, not metamodules. Simplify the naming.]
 +
 
 +
====Define the Patches Gramps needs for Mac====
 +
Gramps hasn't traditionally been developed for Mac, so some things don't quite work right out of the box. jhbuild can apply patches to code after it ahs been downloaded and before it has been built, which is very handy. It does this with the patch utility. jhbuild looks for the patch files, that drive the patching process, in the directory ~/Source/jhbuild/patches. Again, I should like to provide the file to download, but don't know how to do that, so paste this text into the file ~/Source/jhbuild/patches/gramps-3.1.2.patch.
 +
--- configure.orig      2009-06-20 20:17:18.000000000 +0100
 +
+++ configure  2009-06-20 20:19:28.000000000 +0100
 +
@@ -6514,7 +6514,8 @@
 +
      # Do not import gtk.glade, this can raise a RuntimeError if the
 +
      # display cannot be opened.  Just search it.
 +
      import imp
 +
-    imp.find_module('gtk/glade')
 +
+    # imp.find_module('gtk/glade')  # does not work on Mac
 +
+    imp.find_module('glade',[imp.find_module('gtk')[1]])  # Does work on Mac and also on Linux
 +
      out("gtk.glade")
 +
  except ImportError:
 +
      out("NO")
 +
 
 +
This is fixing the problem that find_module() cannot handle "/" in a filename on Mac, for unknown reasons.
 +
 
 +
====Build the custom python====
 +
Type
 +
jhbuild -m python-gramps build custompython
 +
and jhbuild should fetch the sources of python 2.6.2 from the web and build them into a new program, ~/gtk/inst/bin/python. It should finish with ***Success***. The -m python-gramps bit tells jhbuild to look in the file created in the previous step for the instructions.
 +
 
 +
The source of jhbuild itself now lives in ~/Source/jhbuild. The sources downloaded by jhbuild to build new programs all live in ~/gtk.
 +
 
 +
It's important that the system now uses this custom python, rather than any other, since there is a bug in the Apple python which stops the next step from working. To check that the right python is in use, type
 +
type python
 +
and the shell should say
 +
python is /Users/trial/gtk/inst/bin/python
 +
and should definitely not say
 +
python is /usr/bin/python
 +
====Build some more environment====
 +
Type
 +
jhbuild build meta-gtk-osx-bootstrap
 +
jhbuild build meta-gtk-osx-core
 +
and a whole pile of text should scroll by ending in ***Success*** each time. Each step will take quite a while.
 +
====Build everything else====
 +
Type
 +
jhbuild build meta-gtk-osx-python
 +
jhbuild build shared-mime-info
 +
jhbuild build -m python-gramps gramps-3.1.2
 +
and that should build everything that gramps needs, then gramps itself.
 +
Type
 +
gramps
 +
and it should pop into life!

Revision as of 14:51, 21 June 2009

Page in Process of Creation, Beware of Chaos!

This page tells how to build gramps and its supporting programs from source on Apple Mac OS X using the sourceforge gtk-osx project. This work is experimental and changing. It would be unwise to use this software with precious data at this time. It is hoped that, in some days or weeks (June 2009) a one-click-install packaged version of Mac gramps will become available. Meanwhile, it's still necessary to have a proper Apple development system, the xCode package, which is described at the Mac OS X MacPorts page. A system that has bult gramps with MacPorts should already have everything needed to build with gtk-osx.

One advantage of the gtk-osx Mac build is that this gramps no longer needs the Quartz Mac X11 software. That reduces complexity quite a bit. An advantage compared to Macports is that this gramps is built entirely in user space, with no admin access (root login, superuser mode) needed at all. That greatly reduces the chances of messing up the system by mistake. The python interpreter, libraries and gramps code all end up in the user files of whoever builds it, instead of embedded into the system-wide file space. Each user must have their own separate copy of gramps, but most Macs have onlyone user anyway.

There is gtk-osx documentation and jhbuild documentation but it shouldn't be necessary to read those if this page here works.

To build gramps with gtk-osx:

Set aside MacPorts and Fink

If Macports or Fink Files are in the PATH for looking up exectuables or libraries, or if shell variables have been set up by MacPorts or Fink for their specialised build methods, gtk-osx will fail in very obscure ways.

One way of avoiding any leftovers from MacPorts or Fink is to create a new user, using sytem preferences - accounts, and log in as that user. "trial" is a suitable name for the new user. That will create a new home directory /Users/trial where everything will live. User trial will not have write permission on any other user files, so cannot mess very much up. The trial account doesn't need admin privileges, so cannot even mess anything up with sudo. The symbol ~ means "my current home directory" and can be typed at the shell instead of /Users/trial (or whatever the account is called).

Get a terminal

Pop up a terminal with a command shell using Applications - Utilities - Terminal.

Get jhbuild for gtk-osx

Get get-osx-build-setup.sh and store it in the directory ~. (Move it there with the finder if it ended up on the desktop or in Downloads.) At the terminal window, give this program execute permission and execute by typing:

  • chmod +x get-osx-build-setup.sh
  • ./get-osx-build-setup.sh

The script should fetch the jhbuild code from the web. jhbuild is the tool used to control all the building here. The version fetched has been customised for gtk-osx. The script puts the code in ~/Source, and then builds the jhbuild executable. It's supposed to end up in ~/bin/jhbuild, but it seems to get stuck in ~/.local/bin/jhbuild, a hidden directory. The command ls -la shows hidden directories, which the finder cannot usually manage.

If jhbuild hasn't appeared in ~/bin, create ~/bin and link jhbuild there by typing

  • mkdir bin
  • ln .local/bin/jhbuild bin

Set up PATH to find new programs

Type

  • PATH=~/gtk/inst/bin:~/bin:$PATH

~gtk/inst/bin is where jhbuild will put the programs it builds, including gramps. It's important that it is the first place that the system looks, at the front of the PATH, because jhbuild will also put a python there which has to be used in preference to any existing python program.

Set up the jhbuild environment

Type

  • jhbuild bootstrap

to install a bunch of stuff from the web. A lot of text should scroll by, finishing with *** Success ***.

Write definitions of the new programs

jhbuild needs a definition of the moduleset, the set of modules to build to make a program. It knows about most things (it fetches the definitions from the web) but not about a new python and not about gramps. I don't know hwo to provide a file here in the wiki for easy downloading, so I've pasted the text in here. Copy the text from here and paste it into the new file ~/Source/jhbuild/modulesets/python-gramps.modules

<?xml version="1.0" standalone="no"?> 
<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
<moduleset>
 <tarball id="custompython" >
   <source href="http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz"/>
 </tarball>
 <metamodule id="meta-python-2.6.2">
   <dependencies>
     <dep package="custompython" />
   </dependencies>
 </metamodule>
 <tarball id="gramps" >
   <source href="http://downloads.sourceforge.net/gramps/gramps-3.1.2.tar.gz"/>
   <patches>
    <patch file="gramps-3.1.2.patch" strip="0" />
   </patches>
 </tarball>
 <metamodule id="meta-gramps-3.1.2">
   <dependencies>
     <dep package="gramps"/>
   </dependencies>
 </metamodule>
</moduleset>

This file is telling jhbuild what "metamodules" (bunches of modules) are going to be built, what source is needed for each build, what patches are needed on the sources to make them work, and how to build them.

[Change this so the file just references modules, not metamodules. Simplify the naming.]

Define the Patches Gramps needs for Mac

Gramps hasn't traditionally been developed for Mac, so some things don't quite work right out of the box. jhbuild can apply patches to code after it ahs been downloaded and before it has been built, which is very handy. It does this with the patch utility. jhbuild looks for the patch files, that drive the patching process, in the directory ~/Source/jhbuild/patches. Again, I should like to provide the file to download, but don't know how to do that, so paste this text into the file ~/Source/jhbuild/patches/gramps-3.1.2.patch.

--- configure.orig      2009-06-20 20:17:18.000000000 +0100
+++ configure   2009-06-20 20:19:28.000000000 +0100
@@ -6514,7 +6514,8 @@
     # Do not import gtk.glade, this can raise a RuntimeError if the
     # display cannot be opened.  Just search it.
     import imp
-    imp.find_module('gtk/glade')
+    # imp.find_module('gtk/glade')   # does not work on Mac
+    imp.find_module('glade',[imp.find_module('gtk')[1]])   # Does work on Mac and also on Linux
     out("gtk.glade")
 except ImportError:
     out("NO")

This is fixing the problem that find_module() cannot handle "/" in a filename on Mac, for unknown reasons.

Build the custom python

Type

jhbuild -m python-gramps build custompython

and jhbuild should fetch the sources of python 2.6.2 from the web and build them into a new program, ~/gtk/inst/bin/python. It should finish with ***Success***. The -m python-gramps bit tells jhbuild to look in the file created in the previous step for the instructions.

The source of jhbuild itself now lives in ~/Source/jhbuild. The sources downloaded by jhbuild to build new programs all live in ~/gtk.

It's important that the system now uses this custom python, rather than any other, since there is a bug in the Apple python which stops the next step from working. To check that the right python is in use, type

type python

and the shell should say

python is /Users/trial/gtk/inst/bin/python

and should definitely not say

python is /usr/bin/python

Build some more environment

Type

jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core

and a whole pile of text should scroll by ending in ***Success*** each time. Each step will take quite a while.

Build everything else

Type

jhbuild build meta-gtk-osx-python
jhbuild build shared-mime-info
jhbuild build -m python-gramps gramps-3.1.2

and that should build everything that gramps needs, then gramps itself. Type

gramps

and it should pop into life!