IGN:Rationalize build process

This commit is contained in:
Kovid Goyal 2008-07-22 18:59:55 -07:00
parent cff96e56a9
commit e39ae6a88d
18 changed files with 551 additions and 493 deletions

View File

@ -20,3 +20,6 @@ src/calibre/gui2/pictureflow/pictureflow_resource.rc
src/calibre/gui2/pictureflow/release/ src/calibre/gui2/pictureflow/release/
src/calibre/translations/compiled.py src/calibre/translations/compiled.py
installer/windows/calibre/build.log installer/windows/calibre/build.log
src/calibre/translations/.errors
src/calibre/plugins/*
src/calibre/gui2/pictureflow/.build

View File

@ -1,11 +1,6 @@
PYTHON = python PYTHON = python
all : plugins gui2 translations resources all : gui2 translations resources
plugins : src/calibre/plugins pictureflow lzx
src/calibre/plugins:
mkdir -p src/calibre/plugins
clean : clean :
cd src/calibre/gui2 && ${PYTHON} make.py clean cd src/calibre/gui2 && ${PYTHON} make.py clean
@ -25,26 +20,6 @@ resources:
manual: manual:
make -C src/calibre/manual clean html make -C src/calibre/manual clean html
pictureflow :
mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/*pictureflow* && \
cd src/calibre/gui2/pictureflow && rm -f *.o && \
mkdir -p .build && cd .build && rm -f * && \
qmake ../pictureflow.pro && make staticlib && \
cd ../PyQt && \
mkdir -p .build && \
cd .build && rm -f * && \
${PYTHON} ../configure.py && make && \
cd ../../../../../.. && \
cp src/calibre/gui2/pictureflow/PyQt/.build/pictureflow.so src/calibre/plugins/ && \
rm -rf src/calibre/gui2/pictureflow/.build rm -rf src/calibre/gui2/pictureflow/PyQt/.build
lzx :
mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/lzx.so && \
cd src/calibre/utils/lzx && \
${PYTHON} setup.py build --build-base=.build && cd - && \
cp src/calibre/utils/lzx/.build/lib*/lzx.so src/calibre/plugins/ && \
rm -rf src/calibre/utils/lzx/.build/
pot : pot :
cd src/calibre/translations && ${PYTHON} __init__.py pot cd src/calibre/translations && ${PYTHON} __init__.py pot

View File

@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en'
''' '''
Create linux binary. Create linux binary.
''' '''
import glob, sys, subprocess, tarfile, os, re, py_compile import glob, sys, subprocess, tarfile, os, re, py_compile, shutil
HOME = '/home/kovid' HOME = '/home/kovid'
PYINSTALLER = os.path.expanduser('~/build/pyinstaller') PYINSTALLER = os.path.expanduser('~/build/pyinstaller')
CALIBREPREFIX = '___' CALIBREPREFIX = '___'
@ -33,7 +33,6 @@ open(os.path.join(PYINSTALLER, 'hooks', 'hook-calibre.parallel.py'), 'wb').write
def run_pyinstaller(args=sys.argv): def run_pyinstaller(args=sys.argv):
subprocess.check_call(('/usr/bin/sudo', 'chown', '-R', 'kovid:users', glob.glob('/usr/lib/python*/site-packages/')[-1])) subprocess.check_call(('/usr/bin/sudo', 'chown', '-R', 'kovid:users', glob.glob('/usr/lib/python*/site-packages/')[-1]))
subprocess.check_call('rm -rf %(py)s/dist/* %(py)s/build/*'%dict(py=PYINSTALLER), shell=True) subprocess.check_call('rm -rf %(py)s/dist/* %(py)s/build/*'%dict(py=PYINSTALLER), shell=True)
subprocess.check_call('make plugins', shell=True)
cp = HOME+'/build/'+os.path.basename(os.getcwd()) cp = HOME+'/build/'+os.path.basename(os.getcwd())
spec = open(os.path.join(PYINSTALLER, 'calibre', 'calibre.spec'), 'wb') spec = open(os.path.join(PYINSTALLER, 'calibre', 'calibre.spec'), 'wb')
raw = re.sub(r'CALIBREPREFIX\s+=\s+\'___\'', 'CALIBREPREFIX = '+repr(cp), raw = re.sub(r'CALIBREPREFIX\s+=\s+\'___\'', 'CALIBREPREFIX = '+repr(cp),
@ -41,12 +40,14 @@ def run_pyinstaller(args=sys.argv):
spec.write(raw) spec.write(raw)
spec.close() spec.close()
os.chdir(PYINSTALLER) os.chdir(PYINSTALLER)
shutil.rmtree('calibre/dist')
os.mkdir('calibre/dist')
subprocess.check_call('python -OO Build.py calibre/calibre.spec', shell=True) subprocess.check_call('python -OO Build.py calibre/calibre.spec', shell=True)
return 0 return 0
if __name__ == '__main__' and 'linux_installer.py' in __file__: if __name__ == '__main__' and 'freeze.py' in __file__:
sys.exit(run_pyinstaller()) sys.exit(run_pyinstaller())
@ -59,7 +60,7 @@ os.chdir(os.environ.get("ORIGWD", "."))
sys.path.insert(0, os.path.join(sys.frozen_path, "library.pyz")) sys.path.insert(0, os.path.join(sys.frozen_path, "library.pyz"))
sys.path.insert(0, sys.frozen_path) sys.path.insert(0, sys.frozen_path)
from PyQt4.QtCore import QCoreApplication from PyQt4.QtCore import QCoreApplication
QCoreApplication.setLibraryPaths([sys.frozen_path, os.path.join(sys.frozen_path, "plugins")]) QCoreApplication.setLibraryPaths([sys.frozen_path, os.path.join(sys.frozen_path, "qtplugins")])
''') ''')
excludes = ['gtk._gtk', 'gtk.glade', 'qt', 'matplotlib.nxutils', 'matplotlib._cntr', excludes = ['gtk._gtk', 'gtk.glade', 'qt', 'matplotlib.nxutils', 'matplotlib._cntr',
'matplotlib.ttconv', 'matplotlib._image', 'matplotlib.ft2font', 'matplotlib.ttconv', 'matplotlib._image', 'matplotlib.ft2font',
@ -80,7 +81,7 @@ for entry in entry_points['console_scripts'] + entry_points['gui_scripts']:
scripts.append(os.path.join(CALIBRESRC, *map(lambda x: x.strip(), fields[1].split(':')[0].split('.')))+'.py') scripts.append(os.path.join(CALIBRESRC, *map(lambda x: x.strip(), fields[1].split(':')[0].split('.')))+'.py')
analyses = [Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), loader, script], analyses = [Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), loader, script],
pathex=[PYINSTALLER, CALIBRESRC, CALIBREPLUGINS], excludes=excludes) for script in scripts] pathex=[PYINSTALLER, CALIBRESRC], excludes=excludes) for script in scripts]
pyz = TOC() pyz = TOC()
binaries = TOC() binaries = TOC()
@ -104,6 +105,8 @@ for script, exe, a in zip(scripts, executables, analyses):
print 'Adding plugins...' print 'Adding plugins...'
for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so')): for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so')):
binaries += [('plugins/'+os.path.basename(f), f, 'BINARY')]
for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so.*')):
binaries += [(os.path.basename(f), f, 'BINARY')] binaries += [(os.path.basename(f), f, 'BINARY')]
print 'Adding external programs...' print 'Adding external programs...'
@ -121,7 +124,7 @@ for dirpath, dirnames, filenames in os.walk(plugdir):
for f in filenames: for f in filenames:
if not f.endswith('.so') or 'designer' in dirpath or 'codcs' in dirpath or 'sqldrivers' in dirpath : continue if not f.endswith('.so') or 'designer' in dirpath or 'codcs' in dirpath or 'sqldrivers' in dirpath : continue
f = os.path.join(dirpath, f) f = os.path.join(dirpath, f)
plugins.append(('plugins/'+f.replace(plugdir, ''), f, 'BINARY')) plugins.append(('qtplugins/'+f.replace(plugdir, ''), f, 'BINARY'))
binaries += plugins binaries += plugins
manifest = '/tmp/manifest' manifest = '/tmp/manifest'

View File

@ -4,7 +4,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
''' Create an OSX installer ''' ''' Create an OSX installer '''
import sys, re, os, shutil, subprocess, stat, glob, zipfile import sys, re, os, shutil, subprocess, stat, glob, zipfile
from setup import VERSION, APPNAME, scripts, main_modules, basenames, main_functions l = {}
exec open('setup.py').read() in l
VERSION = l['VERSION']
APPNAME = l['APPNAME']
scripts = l['scripts']
basenames = l['basenames']
main_functions = l['main_functions']
main_modules = l['main_modules']
from setuptools import setup from setuptools import setup
from py2app.build_app import py2app from py2app.build_app import py2app
from modulegraph.find_modules import find_modules from modulegraph.find_modules import find_modules
@ -170,64 +177,46 @@ _check_symlinks_prescript()
for f in files: for f in files:
subprocess.check_call(['/usr/bin/install_name_tool', '-change', '/Library/Frameworks/Python.framework/Versions/2.5/Python', '@executable_path/../Frameworks/Python.framework/Versions/2.5/Python', f]) subprocess.check_call(['/usr/bin/install_name_tool', '-change', '/Library/Frameworks/Python.framework/Versions/2.5/Python', '@executable_path/../Frameworks/Python.framework/Versions/2.5/Python', f])
def fix_misc_dependencies(self, files):
for path in files:
frameworks_dir = os.path.join(self.dist_dir, APPNAME + '.app', 'Contents', 'Frameworks')
pipe = subprocess.Popen('/usr/bin/otool -L '+path, shell=True, stdout=subprocess.PIPE).stdout
for l in pipe.readlines():
match = re.search(r'\s+(.*?)\s+\(', l)
if match:
dep = match.group(1)
name = os.path.basename(dep)
if not name:
name = dep
bundle = os.path.join(frameworks_dir, name)
if os.path.exists(bundle):
subprocess.check_call(['/usr/bin/install_name_tool', '-change', dep,
'@executable_path/../Frameworks/'+name, path])
def build_distutils_plugins(self):
plugins = [
('lzx', os.path.join('utils', 'lzx')),
]
files = []
env = {'PATH':os.environ['PATH']}
for name, path in plugins:
print 'Building plugin', name
path = os.path.abspath(os.path.join('src', 'calibre', path))
cwd = os.getcwd()
os.chdir(path)
try:
if os.path.exists('.build'):
shutil.rmtree('.build')
subprocess.check_call((sys.executable, 'setup.py', 'build', '--build-base', '.build'),
env=env)
plugin = os.path.abspath(glob.glob('.build/lib*/%s.so'%name)[0])
files.append([plugin, os.path.basename(plugin)])
finally:
os.chdir(cwd)
return files
def build_plugins(self): def add_plugins(self):
cwd = os.getcwd() self.add_qt_plugins()
qmake = '/Users/kovid/qt/bin/qmake' frameworks_dir = os.path.join(self.dist_dir, APPNAME + '.app', 'Contents', 'Frameworks')
files = [] plugins_dir = os.path.join(frameworks_dir, 'plugins')
try: if not os.path.exists(plugins_dir):
print 'Building pictureflow' os.mkdir(plugins_dir)
os.chdir('src/calibre/gui2/pictureflow')
if not os.path.exists('.build'):
os.mkdir('.build')
os.chdir('.build')
for f in glob.glob('*'): os.unlink(f)
subprocess.check_call([qmake, '../pictureflow.pro'])
subprocess.check_call(['make'])
files.append((os.path.abspath(os.path.realpath('libpictureflow.dylib')), 'libpictureflow.dylib'))
os.chdir('../PyQt')
if not os.path.exists('.build'):
os.mkdir('.build')
os.chdir('.build')
for f in glob.glob('*'): os.unlink(f)
subprocess.check_call([PYTHON, '../configure.py'])
subprocess.check_call(['/usr/bin/make'])
files.append((os.path.abspath('pictureflow.so'), 'pictureflow.so'))
subprocess.check_call(['/usr/bin/install_name_tool', '-change', 'libpictureflow.0.dylib', '@executable_path/../Frameworks/libpictureflow.dylib', 'pictureflow.so'])
self.fix_python_dependencies((files[0][0], files[1][0]))
for i in range(2):
deps = BuildAPP.qt_dependencies(files[i][0])
BuildAPP.fix_qt_dependencies(files[i][0], deps)
return files maps = {}
finally: for f in glob.glob('src/calibre/plugins/*'):
os.chdir(cwd) tgt = plugins_dir
if f.endswith('.dylib'):
tgt = frameworks_dir
maps[f] = os.path.join(tgt, os.path.basename(f))
deps = []
for src, dst in maps.items():
shutil.copyfile(src, dst)
self.fix_qt_dependencies(dst, self.qt_dependencies(dst))
deps.append(dst)
self.fix_python_dependencies(deps)
self.fix_misc_dependencies(deps)
def run(self): def run(self):
plugin_files = self.build_distutils_plugins()
py2app.run(self) py2app.run(self)
resource_dir = os.path.join(self.dist_dir, resource_dir = os.path.join(self.dist_dir,
APPNAME + '.app', 'Contents', 'Resources') APPNAME + '.app', 'Contents', 'Resources')
@ -249,8 +238,8 @@ _check_symlinks_prescript()
f.close() f.close()
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\ os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP) |stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
self.add_qt_plugins() self.add_plugins()
plugin_files += self.build_plugins()
print print
print 'Adding clit' print 'Adding clit'
@ -266,11 +255,6 @@ _check_symlinks_prescript()
print 'Adding fontconfig' print 'Adding fontconfig'
for f in glob.glob(os.path.expanduser('~/fontconfig2/*')): for f in glob.glob(os.path.expanduser('~/fontconfig2/*')):
os.link(f, os.path.join(frameworks_dir, os.path.basename(f))) os.link(f, os.path.join(frameworks_dir, os.path.basename(f)))
for src, dest in plugin_files:
if 'dylib' in dest:
os.link(src, os.path.join(frameworks_dir, dest))
else:
os.link(src, os.path.join(module_dir, dest))
dst = os.path.join(resource_dir, 'fonts') dst = os.path.join(resource_dir, 'fonts')
if os.path.exists(dst): if os.path.exists(dst):
shutil.rmtree(dst) shutil.rmtree(dst)

View File

@ -240,7 +240,6 @@ File ::B145A772-C20C-A6F2-E872-ACC229FFE1C7 -name fb2-meta.exe -parent 6CCF3F71-
File ::168973D9-DEE6-7307-9A2E-746EB9456311 -name txt2lrf.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::168973D9-DEE6-7307-9A2E-746EB9456311 -name txt2lrf.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::BD39D6F0-5125-F3A3-043F-E8FD1C87A823 -name isbndb.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::BD39D6F0-5125-F3A3-043F-E8FD1C87A823 -name isbndb.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::6C294A11-52D4-C567-64F7-1DCF21AB06D7 -name epub2lrf.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::6C294A11-52D4-C567-64F7-1DCF21AB06D7 -name epub2lrf.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::BBE8D78B-6646-5327-563C-7F8EE5842D7B -name pictureflow.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::A9BB9531-5BC4-92C1-F614-B84B93F8698F -name pywintypes25.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::A9BB9531-5BC4-92C1-F614-B84B93F8698F -name pywintypes25.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::AA725BD8-5FFA-B426-733F-5A1264A30DA2 -name Qt.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::AA725BD8-5FFA-B426-733F-5A1264A30DA2 -name Qt.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::B48D9BFD-326D-1C92-4D94-C17F9ACD9207 -name epub2lrf.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::B48D9BFD-326D-1C92-4D94-C17F9ACD9207 -name epub2lrf.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
@ -264,7 +263,6 @@ File ::2AABAB06-38EF-6F8C-3675-575D8B044E0C -name calibredb.exe -parent 6CCF3F71
File ::A7EA318A-0542-FBB8-5C93-A39B364A51D9 -name epub-meta.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::A7EA318A-0542-FBB8-5C93-A39B364A51D9 -name epub-meta.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::4CD878C5-1487-1FFD-99A1-EDFC90892F0A -name win32security.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::4CD878C5-1487-1FFD-99A1-EDFC90892F0A -name win32security.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::ADFDF202-EED8-0319-0D69-DF1C44AE465B -name librarything.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::ADFDF202-EED8-0319-0D69-DF1C44AE465B -name librarything.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::B522E7CC-3C9B-325B-B0BA-3CAFD0228B6D -name pictureflow0.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::0E83E956-FF8D-27AB-9BE9-A24C57F8886A -name pythoncom25.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::0E83E956-FF8D-27AB-9BE9-A24C57F8886A -name pythoncom25.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::F8DAAE4E-9BF0-F75A-78BD-81E0F4BD1F99 -name epub-meta.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::F8DAAE4E-9BF0-F75A-78BD-81E0F4BD1F99 -name epub-meta.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::E2982BD3-D0BB-70B4-0BF8-18B2B68C9918 -name QtWebKit4.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::E2982BD3-D0BB-70B4-0BF8-18B2B68C9918 -name QtWebKit4.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
@ -351,6 +349,13 @@ File ::92701E8F-1D91-A796-C899-2A266029F61D -name _socket.pyd -parent 6CCF3F71-7
File ::45BD27B5-B910-7633-C827-37E82E89C27C -name w9xpopen.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::45BD27B5-B910-7633-C827-37E82E89C27C -name w9xpopen.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::45C27909-D761-787F-84B2-66596E5C4E99 -name bz2.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::45C27909-D761-787F-84B2-66596E5C4E99 -name bz2.pyd -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::7B2DE5D8-17A6-B167-ABC7-799AEBCC1C02 -name clit.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3 File ::7B2DE5D8-17A6-B167-ABC7-799AEBCC1C02 -name clit.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::36E8EEAC-F54D-5DE9-02D8-ECDFEBB4B5E2 -type dir -name plugins -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::71930E14-A27B-C23C-8D94-C7E97ADB8723 -name pictureflow.pyd -parent 36E8EEAC-F54D-5DE9-02D8-ECDFEBB4B5E2
File ::293E6ABE-17C9-5E53-1B44-C27029C8C061 -name winutil.pyd -parent 36E8EEAC-F54D-5DE9-02D8-ECDFEBB4B5E2
File ::A5737158-18DF-7F20-2BDF-2DF615663891 -name lzx.pyd -parent 36E8EEAC-F54D-5DE9-02D8-ECDFEBB4B5E2
File ::87085EC3-26D5-975D-A820-0691F193733D -name pictureflow1.dll -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::CA9E098C-2931-9781-1303-213C242F9A5E -name lit2oeb.exe -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
File ::16B5A447-066C-C93E-F63D-8BC0D57CA544 -name lit2oeb.exe.local -parent 6CCF3F71-74BB-ED69-D0E6-9F12348ABDD3
Component ::F6829AB7-9F66-4CEE-CA0E-21F54C6D3609 -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows} -name Main -parent Components Component ::F6829AB7-9F66-4CEE-CA0E-21F54C6D3609 -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows} -name Main -parent Components
SetupType ::D9ADE41C-B744-690C-2CED-CF826BF03D2E -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows} -name Typical -parent SetupTypes SetupType ::D9ADE41C-B744-690C-2CED-CF826BF03D2E -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows} -name Typical -parent SetupTypes

View File

@ -50,58 +50,16 @@ class BuildEXE(py2exe.build_exe.py2exe):
</trustInfo> </trustInfo>
</assembly> </assembly>
''' '''
def build_distutil_plugins(self):
plugins = [
('lzx', os.path.join('utils', 'lzx')),
]
for name, path in plugins:
print 'Building plugin', name
path = os.path.abspath(os.path.join('src', 'calibre', path))
cwd = os.getcwd()
dd = os.path.join(cwd, self.dist_dir)
os.chdir(path)
try:
if os.path.exists('.build'):
shutil.rmtree('.build')
subprocess.check_call(('python', 'setup.py', 'build', '--build-base', '.build'))
plugin = os.path.abspath(glob.glob('.build\\lib*\\%s.pyd'%name)[0])
shutil.copyfile(plugin, os.path.join(dd, os.path.basename(plugin)))
finally:
os.chdir(cwd)
def build_plugins(self):
cwd = os.getcwd()
dd = os.path.join(cwd, self.dist_dir)
try:
os.chdir(os.path.join('src', 'calibre', 'gui2', 'pictureflow'))
if os.path.exists('.build'):
shutil.rmtree('.build')
os.mkdir('.build')
os.chdir('.build')
subprocess.check_call(['qmake', '../pictureflow.pro'])
subprocess.check_call(['mingw32-make', '-f', 'Makefile.Release'])
shutil.copyfile('release\\pictureflow0.dll', os.path.join(dd, 'pictureflow0.dll'))
os.chdir('..\\PyQt')
if not os.path.exists('.build'):
os.mkdir('.build')
os.chdir('.build')
subprocess.check_call(['python', '..\\configure.py'])
subprocess.check_call(['mingw32-make', '-f', 'Makefile'])
shutil.copyfile('pictureflow.pyd', os.path.join(dd, 'pictureflow.pyd'))
os.chdir('..')
shutil.rmtree('.build', True)
os.chdir('..')
shutil.rmtree('.build', True)
finally:
os.chdir(cwd)
def run(self): def run(self):
if not os.path.exists(self.dist_dir):
os.makedirs(self.dist_dir)
print 'Building custom plugins...'
self.build_distutil_plugins()
self.build_plugins()
py2exe.build_exe.py2exe.run(self) py2exe.build_exe.py2exe.run(self)
print 'Adding plugins...'
tgt = os.path.join(self.dist_dir, 'plugins')
if not os.path.exists(tgt):
os.mkdir(tgt)
for f in glob.glob(os.path.join(BASE_DIR, 'src', 'calibre', 'plugins', '*.dll')):
shutil.copyfile(f, os.path.join(self.dist_dir, os.path.basename(f)))
for f in glob.glob(os.path.join(BASE_DIR, 'src', 'calibre', 'plugins', '*.pyd')):
shutil.copyfile(f, os.path.join(tgt, os.path.basename(f)))
qtsvgdll = None qtsvgdll = None
for other in self.other_depends: for other in self.other_depends:
if 'qtsvg4.dll' in other.lower(): if 'qtsvg4.dll' in other.lower():
@ -116,7 +74,7 @@ class BuildEXE(py2exe.build_exe.py2exe):
print 'Adding', qtxmldll print 'Adding', qtxmldll
shutil.copyfile(qtxmldll, shutil.copyfile(qtxmldll,
os.path.join(self.dist_dir, os.path.basename(qtxmldll))) os.path.join(self.dist_dir, os.path.basename(qtxmldll)))
print 'Adding plugins...', print 'Adding Qt plugins...',
qt_prefix = QT_DIR qt_prefix = QT_DIR
if qtsvgdll: if qtsvgdll:
qt_prefix = os.path.dirname(os.path.dirname(qtsvgdll)) qt_prefix = os.path.dirname(os.path.dirname(qtsvgdll))

View File

@ -4,7 +4,9 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import sys, re, os, shutil import sys, re, os, shutil
sys.path.append('src') sys.path.append('src')
islinux = not ('win32' in sys.platform or 'win64' in sys.platform or 'darwin' in sys.platform) iswindows = re.search('win(32|64)', sys.platform)
isosx = 'darwin' in sys.platform
islinux = not isosx and not iswindows
src = open('src/calibre/__init__.py', 'rb').read() src = open('src/calibre/__init__.py', 'rb').read()
VERSION = re.search(r'__version__\s+=\s+[\'"]([^\'"]+)[\'"]', src).group(1) VERSION = re.search(r'__version__\s+=\s+[\'"]([^\'"]+)[\'"]', src).group(1)
APPNAME = re.search(r'__appname__\s+=\s+[\'"]([^\'"]+)[\'"]', src).group(1) APPNAME = re.search(r'__appname__\s+=\s+[\'"]([^\'"]+)[\'"]', src).group(1)
@ -44,10 +46,72 @@ main_functions = {
} }
if __name__ == '__main__': if __name__ == '__main__':
from setuptools import setup, find_packages from setuptools import setup, find_packages, Extension
import subprocess, glob import subprocess, glob
entry_points['console_scripts'].append('calibre_postinstall = calibre.linux:post_install') entry_points['console_scripts'].append('calibre_postinstall = calibre.linux:post_install')
ext_modules = [Extension('calibre.plugins.lzx',
sources=['src/calibre/utils/lzx/lzxmodule.c',
'src/calibre/utils/lzx/lzxd.c'],
include_dirs=['src/calibre/utils/lzx'])]
if iswindows:
ext_modules.append(Extension('calibre.plugins.winutil',
sources=['src/calibre/utils/winutil.c'], libraries=['shell32'])
)
# Build PyQt extensions
for path in [(os.path.join('src', 'calibre', 'gui2', 'pictureflow'))]:
pro = glob.glob(os.path.join(path, '*.pro'))[0]
raw = open(pro).read()
base = qtplugin = re.search(r'TARGET\s*=\s*(.*)', raw).group(1)
ver = re.search(r'VERSION\s*=\s*(\d+)', raw).group(1)
cwd = os.getcwd()
os.chdir(os.path.dirname(pro))
try:
if not os.path.exists('.build'):
os.mkdir('.build')
os.chdir('.build')
subprocess.check_call(( (os.path.expanduser('~/qt/bin/qmake') if isosx else 'qmake'), '..'+os.sep+os.path.basename(pro)))
subprocess.check_call(['mingw32-make' if iswindows else 'make'])
ext = '.dll' if iswindows else '.dylib' if isosx else '.so'
if iswindows:
pat = re.compile(qtplugin+ver+ext)
elif isosx:
pat = re.compile('lib'+qtplugin+'.'+ver+ext)
else:
pat = re.compile('lib'+qtplugin+ext+'.'+ver+'$')
if iswindows:
os.chdir('release')
qtplugin = None
for f in glob.glob('*'+ext+'*'):
if pat.match(f):
qtplugin = os.path.realpath(os.path.abspath(f))
f = os.path.join(cwd, 'src', 'calibre', 'plugins', f)
shutil.copyfile(qtplugin, f)
if islinux:
os.symlink(f, f.rpartition(ext)[0]+ext)
if isosx:
os.symlink(f, f.replace('.'+ver, ''))
break
os.chdir(os.path.join('..'+(os.sep+'..' if iswindows else ''), 'PyQt'))
if not os.path.exists('.build'):
os.mkdir('.build')
os.chdir('.build')
python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python' if isosx else 'python'
subprocess.check_call([python, '..'+os.sep+'configure.py'])
subprocess.check_call(['mingw32-make' if iswindows else 'make'])
ext = '.pyd' if iswindows else '.so'
plugin = glob.glob(base+ext)[0]
shutil.copyfile(plugin, os.path.join(cwd, 'src', 'calibre', 'plugins', plugin))
finally:
os.chdir(cwd)
if islinux or isosx:
for f in glob.glob(os.path.join('src', 'calibre', 'plugins', '*')):
try:
os.readlink(f)
os.unlink(f)
except:
continue
setup( setup(
name=APPNAME, name=APPNAME,
@ -62,6 +126,7 @@ if __name__ == '__main__':
entry_points = entry_points, entry_points = entry_points,
zip_safe = False, zip_safe = False,
options = { 'bdist_egg' : {'exclude_source_files': True,}, }, options = { 'bdist_egg' : {'exclude_source_files': True,}, },
ext_modules=ext_modules,
description = description =
''' '''
E-book management application. E-book management application.

View File

@ -43,6 +43,39 @@ try:
except: except:
preferred_encoding = 'utf-8' preferred_encoding = 'utf-8'
if getattr(sys, 'frozen', False):
if iswindows:
plugin_path = os.path.join(os.path.dirname(sys.executable), 'plugins')
elif isosx:
plugin_path = os.path.join(getattr(sys, 'frameworks_dir'), 'plugins')
elif islinux:
plugin_path = os.path.join(getattr(sys, 'frozen_path'), 'plugins')
sys.path.insert(0, plugin_path)
else:
import pkg_resources
plugins = getattr(pkg_resources, 'resource_filename')(__appname__, 'plugins')
sys.path.insert(0, plugins)
if iswindows and getattr(sys, 'frozen', False):
sys.path.insert(1, os.path.dirname(sys.executable))
plugins = {}
for plugin in ['pictureflow', 'lzx'] + (['winutil'] if iswindows else []):
try:
p, err = __import__(plugin), ''
except Exception, err:
p = None
err = str(err)
plugins[plugin] = (p, err)
if iswindows:
winutil, winutilerror = plugins['winutil']
if not winutil:
raise RuntimeError('Failed to load the winutil plugin: %s'%winutilerror)
sys.argv[1:] = winutil.argv()[1:]
_abspath = os.path.abspath _abspath = os.path.abspath
def my_abspath(path, encoding=sys.getfilesystemencoding()): def my_abspath(path, encoding=sys.getfilesystemencoding()):
''' '''
@ -606,22 +639,3 @@ if isosx:
exec 'from calibre.ebooks.lrf.fonts.liberation.'+font+' import font_data' exec 'from calibre.ebooks.lrf.fonts.liberation.'+font+' import font_data'
open(os.path.join(fdir, font+'.ttf'), 'wb').write(font_data) open(os.path.join(fdir, font+'.ttf'), 'wb').write(font_data)
if islinux and not getattr(sys, 'frozen', False):
import pkg_resources
plugins = pkg_resources.resource_filename(__appname__, 'plugins')
sys.path.insert(1, plugins)
if iswindows and getattr(sys, 'frozen', False):
sys.path.insert(1, os.path.dirname(sys.executable))
plugins = {}
for plugin in ['pictureflow', 'lzx']:
try:
p, err = __import__(plugin), ''
except Exception, err:
p = None
err = str(err)
plugins[plugin] = (p, err)

View File

@ -64,7 +64,8 @@ def process_file(path, options, logger=None):
logger = logging.getLogger('lit2lrf') logger = logging.getLogger('lit2lrf')
setup_cli_handlers(logger, level) setup_cli_handlers(logger, level)
lit = os.path.abspath(os.path.expanduser(path)) lit = os.path.abspath(os.path.expanduser(path))
tdir = generate_html2(lit, logger) if options.lit2oeb else generate_html(lit, logger) tdir = generate_html2(lit, logger) if getattr(options, 'lit2oeb', False) \
else generate_html(lit, logger)
try: try:
opf = glob.glob(os.path.join(tdir, '*.opf')) opf = glob.glob(os.path.join(tdir, '*.opf'))
if opf: if opf:

View File

@ -1,46 +0,0 @@
TARGET = pictureflow.so
OFILES = sippictureflowcmodule.o sippictureflowPictureFlow.o
HFILES = sipAPIpictureflow.h
CC = gcc
CXX = g++
LINK = g++
CPPFLAGS = -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I. -I/usr/include/python2.5 -I/usr/lib/qt-3.3/mkspecs/default -I/usr/lib/qt-3.3/include
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fPIC -Wall -W -D_REENTRANT
CXXFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fPIC -Wall -W -D_REENTRANT
LFLAGS = -shared -Wl,--version-script=pictureflow.exp
LIBS = -L.. -L/usr/lib/qt-3.3/lib -lpictureflow -lqt-mt -lXext -lX11 -lm -lpthread
MOC = /usr/lib/qt-3.3/bin/moc
.SUFFIXES: .c .o .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(TARGET): $(OFILES)
@echo '{ global: initpictureflow; local: *; };' > pictureflow.exp
$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
$(OFILES): $(HFILES)
install: $(TARGET)
@test -d $(DESTDIR)/usr/lib/python2.5/site-packages || mkdir -p $(DESTDIR)/usr/lib/python2.5/site-packages
cp -f $(TARGET) $(DESTDIR)/usr/lib/python2.5/site-packages/$(TARGET)
clean:
-rm -f $(TARGET)
-rm -f sippictureflowcmodule.o
-rm -f sippictureflowPictureFlow.o
-rm -f pictureflow.exp

View File

@ -1,4 +1,4 @@
import os, sys, glob, shutil import os, sys
import sipconfig import sipconfig
if os.environ.get('PYQT4PATH', None): if os.environ.get('PYQT4PATH', None):
print os.environ['PYQT4PATH'] print os.environ['PYQT4PATH']
@ -35,16 +35,14 @@ makefile = pyqtconfig.QtGuiModuleMakefile (
# Add the library we are wrapping. The name doesn't include any platform # Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows). # ".dll" extension on Windows).
if 'linux' in sys.platform: d = os.path.dirname
for f in glob.glob('../../.build/libpictureflow.a'): makefile.extra_lib_dirs += [os.path.abspath(os.path.join(d(d(d(d(os.getcwd())))), 'plugins')).replace(os.sep, '/')]
shutil.copyfile(f, os.path.basename(f)) makefile.extra_libs += ['pictureflow1' if 'win32' in sys.platform else 'pictureflow']
makefile.extra_lib_dirs = ['.']
else:
makefile.extra_lib_dirs = ['..\\..\\.build\\release', '../../.build', '.']
makefile.extra_libs = ['pictureflow0' if 'win' in sys.platform and 'darwin' not in sys.platform else "pictureflow"]
makefile.extra_cflags = ['-arch i386', '-arch ppc'] if 'darwin' in sys.platform else [] makefile.extra_cflags = ['-arch i386', '-arch ppc'] if 'darwin' in sys.platform else []
makefile.extra_lflags = ['-arch i386', '-arch ppc'] if 'darwin' in sys.platform else [] makefile.extra_lflags = ['-arch i386', '-arch ppc'] if 'darwin' in sys.platform else []
makefile.extra_cxxflags = makefile.extra_cflags makefile.extra_cxxflags = makefile.extra_cflags
if 'win32' in sys.platform:
makefile.extra_lib_dirs += ['C:/Python25/libs']
# Generate the Makefile itself. # Generate the Makefile itself.
makefile.generate() makefile.generate()
@ -60,6 +58,6 @@ content = {
# This creates the helloconfig.py module from the helloconfig.py.in # This creates the helloconfig.py module from the helloconfig.py.in
# template and the dictionary. # template and the dictionary.
sipconfig.create_config_module("pictureflowconfig.py", "../pictureflowconfig.py.in", content) sipconfig.create_config_module("pictureflowconfig.py", '..'+os.sep+'pictureflowconfig.py.in', content)

View File

@ -2,5 +2,5 @@ TARGET = pictureflow
TEMPLATE = lib TEMPLATE = lib
HEADERS = pictureflow.h HEADERS = pictureflow.h
SOURCES = pictureflow.cpp SOURCES = pictureflow.cpp
VERSION = 0.2.0 VERSION = 1.0.0
CONFIG += x86 ppc CONFIG += x86 ppc

View File

@ -251,8 +251,14 @@ def download_tarball():
except ValueError: except ValueError:
print 'Downloading calibre...' print 'Downloading calibre...'
pb = None pb = None
src = urllib2.urlopen(MOBILEREAD+'calibre-%version-i686.tar.bz2') local = 'calibre-test.tar.bz2'
src = open(local) if os.access(local, os.R_OK) else urllib2.urlopen(MOBILEREAD+'calibre-%version-i686.tar.bz2')
if hasattr(src, 'info'):
size = int(src.info()['content-length']) size = int(src.info()['content-length'])
else:
src.seek(0, 2)
size = src.tell()
src.seek(0)
f = tempfile.NamedTemporaryFile() f = tempfile.NamedTemporaryFile()
while f.tell() < size: while f.tell() < size:
f.write(src.read(4*1024)) f.write(src.read(4*1024))

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
from distutils.core import setup, Extension
setup(name="lzx", version="1.0",
ext_modules=[Extension('lzx', sources=['lzx/lzxmodule.c', 'lzx/lzxd.c'],
include_dirs=['lzx'])])

View File

@ -1,15 +0,0 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
'''
Build the lzx decompressor extension
'''
from distutils.core import setup, Extension
setup(name="lzx", version="1.0",
ext_modules=[Extension('lzx',
sources=['lzxmodule.c', 'lzxd.c'],
include_dirs=['.'])])

View File

@ -0,0 +1,99 @@
#define UNICODE
#include <shlobj.h>
#include <Windows.h>
#include <Python.h>
#include <stdio.h>
static PyObject *
winutil_folder_path(PyObject *self, PyObject *args) {
int res; DWORD dwFlags;
PyObject *ans = NULL;
TCHAR wbuf[MAX_PATH]; CHAR buf[4*MAX_PATH];
memset(wbuf, 0, sizeof(TCHAR)*MAX_PATH); memset(buf, 0, sizeof(CHAR)*MAX_PATH);
if (!PyArg_ParseTuple(args, "l", &dwFlags)) return NULL;
res = SHGetFolderPath(NULL, dwFlags, NULL, 0, wbuf);
if (res != S_OK) {
if (res == E_FAIL) PyErr_SetString(PyExc_ValueError, "Folder does not exist.");
PyErr_SetString(PyExc_ValueError, "Folder not valid");
return NULL;
}
res = WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, buf, 4*MAX_PATH, NULL, NULL);
ans = PyUnicode_DecodeUTF8(buf, res-1, "strict");
return ans;
}
static PyObject *
winutil_argv(PyObject *self, PyObject *args) {
PyObject *argv, *v;
LPWSTR *_argv;
LPSTR buf;
int argc, i, bytes;
if (!PyArg_ParseTuple(args, "")) return NULL;
_argv = CommandLineToArgvW(GetCommandLine(), &argc);
if (_argv == NULL) { PyErr_SetString(PyExc_RuntimeError, "Out of memory."); return NULL; }
argv = PyList_New(argc);
if (argv != NULL) {
for (i = 0; i < argc; i++) {
bytes = WideCharToMultiByte(CP_UTF8, 0, _argv[i], -1, NULL, 0, NULL, NULL);
buf = (LPSTR)PyMem_Malloc(sizeof(CHAR)*bytes);
if (buf == NULL) { Py_DECREF(argv); argv = NULL; break; }
WideCharToMultiByte(CP_UTF8, 0, _argv[i], -1, buf, bytes, NULL, NULL);
v = PyUnicode_DecodeUTF8(buf, bytes-1, "strict");
PyMem_Free(buf);
if (v == NULL) { Py_DECREF(argv); argv = NULL; break; }
PyList_SetItem(argv, i, v);
}
}
LocalFree(_argv);
return argv;
}
static PyMethodDef WinutilMethods[] = {
{"folder_path", winutil_folder_path, METH_VARARGS,
"folder_path(csidl_id) -> path\n\n"
"Get paths to common system folders. "
"See windows documentation of SHGetFolderPath. "
"The paths are returned as unicode objects. csidl_id should be one "
"of the symbolic constants defined in this module. You can also OR "
"a symbolic constant with CSIDL_FLAG_CREATE to force the operating "
"system to create a folder if it does not exist."},
{"argv", winutil_argv, METH_VARARGS,
"argv() -> list of command line arguments\n\n"
"Get command line arguments as unicode objects. Note that the "
"first argument will be the path to the interpreter, *not* the "
"script being run. So to replace sys.argv, you should use "
"sys.argv[1:] = argv()[1:]."},
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC
initwinutil(void) {
PyObject *m;
m = Py_InitModule3("winutil", WinutilMethods,
"Defines utility methods to interface with windows."
);
if (m == NULL) return;
PyModule_AddIntConstant(m, "CSIDL_ADMINTOOLS", CSIDL_ADMINTOOLS);
PyModule_AddIntConstant(m, "CSIDL_APPDATA", CSIDL_APPDATA);
PyModule_AddIntConstant(m, "CSIDL_COMMON_ADMINTOOLS", CSIDL_COMMON_ADMINTOOLS);
PyModule_AddIntConstant(m, "CSIDL_COMMON_APPDATA", CSIDL_COMMON_APPDATA);
PyModule_AddIntConstant(m, "CSIDL_COMMON_DOCUMENTS", CSIDL_COMMON_DOCUMENTS);
PyModule_AddIntConstant(m, "CSIDL_COOKIES", CSIDL_COOKIES);
PyModule_AddIntConstant(m, "CSIDL_FLAG_CREATE", CSIDL_FLAG_CREATE);
PyModule_AddIntConstant(m, "CSIDL_FLAG_DONT_VERIFY", CSIDL_FLAG_DONT_VERIFY);
PyModule_AddIntConstant(m, "CSIDL_HISTORY", CSIDL_HISTORY);
PyModule_AddIntConstant(m, "CSIDL_INTERNET_CACHE", CSIDL_INTERNET_CACHE);
PyModule_AddIntConstant(m, "CSIDL_LOCAL_APPDATA", CSIDL_LOCAL_APPDATA);
PyModule_AddIntConstant(m, "CSIDL_MYPICTURES", CSIDL_MYPICTURES);
PyModule_AddIntConstant(m, "CSIDL_PERSONAL", CSIDL_PERSONAL);
PyModule_AddIntConstant(m, "CSIDL_PROGRAM_FILES", CSIDL_PROGRAM_FILES);
PyModule_AddIntConstant(m, "CSIDL_PROGRAM_FILES_COMMON", CSIDL_PROGRAM_FILES_COMMON);
PyModule_AddIntConstant(m, "CSIDL_SYSTEM", CSIDL_SYSTEM);
PyModule_AddIntConstant(m, "CSIDL_WINDOWS", CSIDL_WINDOWS);
}

View File

@ -29,10 +29,10 @@ BUILD_SCRIPT ='''\
#!/bin/bash #!/bin/bash
cd ~/build && \ cd ~/build && \
rsync -avz --exclude src/calibre/plugins --exclude docs --exclude .bzr --exclude .build --exclude build --exclude dist --exclude "*.pyc" --exclude "*.pyo" rsync://%(host)s/work/%(project)s . && \ rsync -avz --exclude src/calibre/plugins --exclude docs --exclude .bzr --exclude .build --exclude build --exclude dist --exclude "*.pyc" --exclude "*.pyo" rsync://%(host)s/work/%(project)s . && \
cd %(project)s && \ cd %(project)s && rm -rf build dist src/calibre/plugins && \
mkdir -p build dist src/calibre/plugins && \ mkdir -p build dist src/calibre/plugins && \
%%s && \ %%s && \
rm -rf build/* dist/* && \ rm -rf build/* && \
%%s %%s %%s %%s
'''%dict(host=HOST, project=PROJECT) '''%dict(host=HOST, project=PROJECT)
check_call = partial(_check_call, shell=True) check_call = partial(_check_call, shell=True)
@ -63,6 +63,15 @@ def start_vm(vm, ssh_host, build_script, sleep=75):
subprocess.check_call(('scp', t.name, ssh_host+':build-'+PROJECT)) subprocess.check_call(('scp', t.name, ssh_host+':build-'+PROJECT))
subprocess.check_call('ssh -t %s bash build-%s'%(ssh_host, PROJECT), shell=True) subprocess.check_call('ssh -t %s bash build-%s'%(ssh_host, PROJECT), shell=True)
def run_windows_install_jammer(installer):
ibp = os.path.abspath('installer/windows')
sys.path.insert(0, ibp)
import build_installer
sys.path.remove(ibp)
build_installer.run_install_jammer(installer_name=os.path.basename(installer))
if not os.path.exists(installer):
raise Exception('Failed to run installjammer')
def build_windows(shutdown=True): def build_windows(shutdown=True):
installer = installer_name('exe') installer = installer_name('exe')
vm = '/vmware/Windows XP/Windows XP Professional.vmx' vm = '/vmware/Windows XP/Windows XP Professional.vmx'
@ -72,20 +81,14 @@ def build_windows(shutdown=True):
raise Exception('Failed to run py2exe') raise Exception('Failed to run py2exe')
if shutdown: if shutdown:
subprocess.Popen(('ssh', 'windows', 'shutdown', '-s', '-t', '0')) subprocess.Popen(('ssh', 'windows', 'shutdown', '-s', '-t', '0'))
ibp = os.path.abspath('installer/windows') run_windows_install_jammer(installer)
sys.path.insert(0, ibp)
import build_installer
sys.path.remove(ibp)
build_installer.run_install_jammer(installer_name=os.path.basename(installer))
if not os.path.exists(installer):
raise Exception('Failed to run installjammer')
return os.path.basename(installer) return os.path.basename(installer)
def build_osx(shutdown=True): def build_osx(shutdown=True):
installer = installer_name('dmg') installer = installer_name('dmg')
vm = '/vmware/Mac OSX/Mac OSX.vmx' vm = '/vmware/Mac OSX/Mac OSX.vmx'
python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python' python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python'
start_vm(vm, 'osx', BUILD_SCRIPT%('sudo %s setup.py develop'%python, python, 'osx_installer.py')) start_vm(vm, 'osx', (BUILD_SCRIPT%('sudo %s setup.py develop'%python, python, 'installer/osx/freeze.py')).replace('rm ', 'sudo rm '))
subprocess.check_call(('scp', 'osx:build/%s/dist/*.dmg'%PROJECT, 'dist')) subprocess.check_call(('scp', 'osx:build/%s/dist/*.dmg'%PROJECT, 'dist'))
if not os.path.exists(installer): if not os.path.exists(installer):
raise Exception('Failed to build installer '+installer) raise Exception('Failed to build installer '+installer)
@ -97,7 +100,7 @@ def build_osx(shutdown=True):
def build_linux(shutdown=True): def build_linux(shutdown=True):
installer = installer_name('tar.bz2') installer = installer_name('tar.bz2')
vm = '/vmware/linux/libprs500-gentoo.vmx' vm = '/vmware/linux/libprs500-gentoo.vmx'
start_vm(vm, 'linux', BUILD_SCRIPT%('sudo python setup.py develop', 'python','linux_installer.py')) start_vm(vm, 'linux', (BUILD_SCRIPT%('sudo python setup.py develop', 'python','installer/linux/freeze.py')).replace('rm ', 'sudo rm '))
subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist')) subprocess.check_call(('scp', 'linux:/tmp/%s'%os.path.basename(installer), 'dist'))
if not os.path.exists(installer): if not os.path.exists(installer):
raise Exception('Failed to build installer '+installer) raise Exception('Failed to build installer '+installer)