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.
This commit is contained in:
Dan Smith 2009-03-03 15:09:16 -08:00
parent 795f449638
commit 88db3e7c8c
6 changed files with 148 additions and 49 deletions

View file

@ -2,3 +2,5 @@
.*\.pyc$
.*\.orig$
.*\.rej$
dist
build/bdist

51
build/macos/make_pango.sh Normal file
View file

@ -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

View file

@ -15,4 +15,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CHIRP_VERSION="0.1.8"
CHIRP_VERSION="0.1.9b4"

View file

@ -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"))

5
chirpw
View file

@ -16,6 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from chirp import platform
# Hack to setup environment
platform.get_platform()
import gtk
import sys

127
setup.py
View file

@ -1,61 +1,92 @@
#!/usr/bin/python
#
# Copyright 2008 Dan Smith <dsmith@danplanet.com>
#
# 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 <http://www.gnu.org/licenses/>.
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()