From 88db3e7c8cce060ca04710bc884b224e587eb65b Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 3 Mar 2009 15:09:16 -0800 Subject: [PATCH] Make the build scripts support MacOS .app building Also include some very hackish stuff to get the environment setup. Need to finish this off by properly importing the changed version of platform.py from D-RATS. --- .hgignore | 2 + build/macos/make_pango.sh | 51 +++++++++++++++ chirp/__init__.py | 2 +- chirp/platform.py | 10 +++ chirpw | 5 ++ setup.py | 127 ++++++++++++++++++++++++-------------- 6 files changed, 148 insertions(+), 49 deletions(-) create mode 100644 build/macos/make_pango.sh diff --git a/.hgignore b/.hgignore index ea080f5c..a0af2711 100644 --- a/.hgignore +++ b/.hgignore @@ -2,3 +2,5 @@ .*\.pyc$ .*\.orig$ .*\.rej$ +dist +build/bdist diff --git a/build/macos/make_pango.sh b/build/macos/make_pango.sh new file mode 100644 index 00000000..a4168e4f --- /dev/null +++ b/build/macos/make_pango.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +make_pango_modules() { + local src=$1 + local dst=$2 + local sf=${src}/etc/pango/pango.modules + local df=${dst}/etc/pango/pango.modules + + cat $sf | sed 's/\/opt\/.*\/lib/..\/Resources/' > $df +} + +make_pango_rc() { + local src=$1 + local dst=$2 + local sf=${src}/etc/pango/pangorc + local df=${dst}/etc/pango/pangorc + + cat $sf | sed 's/\/opt\/.*\/etc/.\/etc/' > $df +} + +make_pangox_aliases() { + local src=$1 + local dst=$2 + + cp ${src}/etc/pango/pangox.aliases ${dst}/etc/pango +} + +usage() { + echo 'Usage: make_pango.sh [PATH_TO_MACPORTS] [PATH_TO_APP]' + echo 'Example:' + echo ' make_pango.sh /opt/local dist/d-rats.app' +} + +if [ -z "$1" ]; then + usage + exit 1 +fi + +if [ -z "$2" ]; then + usage + exit 1 +fi + +base=$1 +app="$2/Contents/Resources" + +mkdir -p ${app}/etc/pango + +make_pango_modules $base $app +make_pango_rc $base $app +make_pangox_aliases $base $app diff --git a/chirp/__init__.py b/chirp/__init__.py index 5c162bb1..99833756 100644 --- a/chirp/__init__.py +++ b/chirp/__init__.py @@ -15,4 +15,4 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -CHIRP_VERSION="0.1.8" +CHIRP_VERSION="0.1.9b4" diff --git a/chirp/platform.py b/chirp/platform.py index 5d3b7f40..da3bb0ed 100644 --- a/chirp/platform.py +++ b/chirp/platform.py @@ -182,6 +182,16 @@ class UnixPlatform(Platform): Platform.__init__(self, basepath) + # This is a hack that needs to be properly fixed by importing the + # latest changes to this module from d-rats. In the interest of + # time, however, I'll throw it here + if sys.platform == "darwin": + if not os.environ.has_key("DISPLAY"): + print "Forcing DISPLAY for MacOS" + os.environ["DISPLAY"] = ":0" + + os.environ["PANGO_RC_FILE"] = "../Resources/etc/pango/pangorc" + def default_dir(self): return os.path.abspath(os.getenv("HOME")) diff --git a/chirpw b/chirpw index bd329523..5d4c5adb 100755 --- a/chirpw +++ b/chirpw @@ -16,6 +16,11 @@ # along with this program. If not, see . +from chirp import platform + +# Hack to setup environment +platform.get_platform() + import gtk import sys diff --git a/setup.py b/setup.py index 4651e790..5313252e 100644 --- a/setup.py +++ b/setup.py @@ -1,61 +1,92 @@ -#!/usr/bin/python -# -# Copyright 2008 Dan Smith -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from distutils.core import setup import sys -from chirp import CHIRP_VERSION -try: - # if this doesn't work, try import modulefinder - import py2exe.mf as modulefinder - import win32com - for p in win32com.__path__[1:]: - modulefinder.AddPackagePath("win32com", p) - for extra in ["win32com.shell"]: #,"win32com.mapi" - __import__(extra) - m = sys.modules[extra] - for p in m.__path__[1:]: - modulefinder.AddPackagePath(extra, p) -except ImportError: - # no build path setup, no worries. - pass +import os -if sys.platform == "win32": +CHIRP_VERSION="0.1.9b5" + +def win32_build(): + from distutils.core import setup import py2exe + + try: + # if this doesn't work, try import modulefinder + import py2exe.mf as modulefinder + import win32com + for p in win32com.__path__[1:]: + modulefinder.AddPackagePath("win32com", p) + for extra in ["win32com.shell"]: #,"win32com.mapi" + __import__(extra) + m = sys.modules[extra] + for p in m.__path__[1:]: + modulefinder.AddPackagePath(extra, p) + except ImportError: + # no build path setup, no worries. + pass + + opts = { "py2exe" : { - "includes" : "pango,atk,gobject,cairo,pangocairo,win32gui,win32com,win32com.shell", + "includes" : "pango,atk,gobject,cairo,pangocairo,win32gui,win32com,win32com.shell,email.iterators,email.generator", "compressed" : 1, "optimize" : 2, "bundle_files" : 3, + # "packages" : "" } } - setup(name="chirp", - windows=[{'script' : "chirpw"}], - console=[{'script' : "chirp.py"}], - packages=['chirp', 'chirpui'], - version=CHIRP_VERSION, - scripts=['chirpw'], - options=opts) + setup( + windows=[{'script' : "chirpw" },], + options=opts) + +def macos_build(): + from setuptools import setup + import shutil + + APP = ['chirp-%s.py' % CHIRP_VERSION] + shutil.copy("chirpw", APP[0]) + DATA_FILES = [('../Frameworks', + ['/opt/local/lib/libpangox-1.0.0.2203.1.dylib']), + ('../Resources/pango/1.6.0/modules', ['/opt/local/lib/pango/1.6.0/modules/pango-basic-atsui.so']), + ] + OPTIONS = {'argv_emulation': True, "includes" : "gtk,atk,pangocairo,cairo"} + + setup( + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], + ) + +def default_build(): + from distutils.core import setup + from glob import glob + + desktop_files = glob("share/*.desktop") + #form_files = glob("forms/*.x?l") + image_files = glob("images/*") + #_locale_files = glob("locale/*/LC_MESSAGES/D-RATS.mo") + _locale_files = [] + + locale_files = [] + for f in _locale_files: + locale_files.append(("/usr/share/chirp/%s" % os.path.dirname(f), [f])) + + print "LOC: %s" % str(locale_files) + + setup( + name="chirp", + packages=["chirp", "chirpui"], + version=CHIRP_VERSION, + scripts=["chirpw"], + data_files=[('/usr/share/applications', desktop_files), + ('/usr/share/chirp/images', image_files), + ] + locale_files) + +if sys.platform == "darwin": + macos_build() +elif sys.platform == "win32": + win32_build() else: - setup(name="chirp", - packages=['chirp', 'chirpui'], - version=CHIRP_VERSION, - scripts=['chirpw'], - data_files=[('/usr/share/chirp', ['chirp.xsd', 'chirp_memory.xsd', 'chirp_banks.xsd']), - ('/usr/share/applications', ['chirp.desktop'])]) + default_build() + +