mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:More work on leopard build
This commit is contained in:
parent
0acbb330e9
commit
6ad672ae40
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -39,13 +38,19 @@ def _run():
|
|||||||
import os, sys, site
|
import os, sys, site
|
||||||
sys.frozen = 'macosx_app'
|
sys.frozen = 'macosx_app'
|
||||||
base = os.environ['RESOURCEPATH']
|
base = os.environ['RESOURCEPATH']
|
||||||
sys.frameworks_dir = os.path.join(os.path.dirname(base, 'Frameworks'))
|
sys.frameworks_dir = os.path.join(os.path.dirname(base), 'Frameworks')
|
||||||
sys.new_app_bundle = True
|
sys.new_app_bundle = True
|
||||||
site.addsitedir(base)
|
site.addsitedir(base)
|
||||||
site.addsitedir(os.path.join(base, 'Python', 'site-packages'))
|
site.addsitedir(os.path.join(base, 'Python', 'site-packages'))
|
||||||
exe = os.environ.get('CALIBRE_LAUNCH_MODULE', 'calibre.gui2.main')
|
exe = os.environ.get('CALIBRE_LAUNCH_MODULE', 'calibre.gui2.main')
|
||||||
exe = os.path.join(base, 'Python', 'site-packages', *exe.split('.'))
|
exe = os.path.join(base, 'Python', 'site-packages', *exe.split('.'))
|
||||||
|
exe += '.py'
|
||||||
sys.argv[0] = __file__ = exe
|
sys.argv[0] = __file__ = exe
|
||||||
|
argv = os.environ.get('CALIBRE_LAUNCH_ARGV', None)
|
||||||
|
if argv is not None:
|
||||||
|
import cPickle
|
||||||
|
argv = cPickle.loads(argv)
|
||||||
|
sys.argv[1:] = argv
|
||||||
execfile(exe, globals(), globals())
|
execfile(exe, globals(), globals())
|
||||||
|
|
||||||
_run()
|
_run()
|
||||||
|
@ -5,7 +5,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
import os, sys
|
import os, sys, cPickle
|
||||||
|
|
||||||
ENV = {}##ENV##
|
ENV = {}##ENV##
|
||||||
MODULE = ''##MODULE##
|
MODULE = ''##MODULE##
|
||||||
@ -18,13 +18,16 @@ resources_dir = os.path.join(base_dir, 'Resources')
|
|||||||
frameworks_dir = os.path.join(base_dir, 'Frameworks')
|
frameworks_dir = os.path.join(base_dir, 'Frameworks')
|
||||||
exe_dir = os.path.join(base_dir, 'MacOS')
|
exe_dir = os.path.join(base_dir, 'MacOS')
|
||||||
base_name = os.path.splitext(name)[0]
|
base_name = os.path.splitext(name)[0]
|
||||||
python = os.path.join(base_dir, 'MacOS', 'calibre')
|
python = os.path.join(base_dir, 'MacOS', 'Python')
|
||||||
|
|
||||||
for key, val in ENV.items():
|
for key, val in ENV.items():
|
||||||
if val.startswith('@exec'):
|
if val.startswith('@exec'):
|
||||||
ENV[key] = os.path.normpath(val.replace('@executable_path', exe_dir))
|
ENV[key] = os.path.normpath(val.replace('@executable_path', exe_dir))
|
||||||
ENV['CALIBRE_LAUNCH_MODULE'] = MODULE
|
ENV['CALIBRE_LAUNCH_MODULE'] = MODULE
|
||||||
|
ENV['CALIBRE_LAUNCH_ARGV'] = cPickle.dumps(sys.argv[1:], -1)
|
||||||
|
ENV['RESOURCEPATH'] = resources_dir
|
||||||
os.environ.update(ENV)
|
os.environ.update(ENV)
|
||||||
args = [path] + sys.argv[1:]
|
launcher = os.path.join(resources_dir, 'launcher.py')
|
||||||
|
args = ['-OO', launcher]
|
||||||
os.execv(python, args)
|
os.execv(python, args)
|
||||||
|
|
||||||
|
@ -864,9 +864,10 @@ static int py2app_main(int argc, char * const *argv, char * const *envp) {
|
|||||||
if (!getApplicationName()) return report_error(ERR_NONAME);
|
if (!getApplicationName()) return report_error(ERR_NONAME);
|
||||||
pyLocations = (CFArrayRef)getKey("PyRuntimeLocations");
|
pyLocations = (CFArrayRef)getKey("PyRuntimeLocations");
|
||||||
if (!pyLocations) return report_error(ERR_PYRUNTIMELOCATIONS);
|
if (!pyLocations) return report_error(ERR_PYRUNTIMELOCATIONS);
|
||||||
|
printf("1111111\n;");
|
||||||
pyLocation = findPyLocation(pyLocations);
|
pyLocation = findPyLocation(pyLocations);
|
||||||
if (!pyLocation) return report_error(ERR_NOPYTHONRUNTIME);
|
if (!pyLocation) return report_error(ERR_NOPYTHONRUNTIME);
|
||||||
|
printf("2222222\n");
|
||||||
setExecutablePath();
|
setExecutablePath();
|
||||||
setResourcePath();
|
setResourcePath();
|
||||||
/* check for ':' in path, not compatible with Python due to Py_GetPath */
|
/* check for ':' in path, not compatible with Python due to Py_GetPath */
|
||||||
@ -895,7 +896,7 @@ static int py2app_main(int argc, char * const *argv, char * const *envp) {
|
|||||||
xCFStringGetCString(pyLocation, buf, sizeof(buf), kCFStringEncodingUTF8);
|
xCFStringGetCString(pyLocation, buf, sizeof(buf), kCFStringEncodingUTF8);
|
||||||
py_dylib = dlopen(buf, PYMACAPP_DYLD_FLAGS);
|
py_dylib = dlopen(buf, PYMACAPP_DYLD_FLAGS);
|
||||||
if (py_dylib == NULL) return report_linkEdit_error();
|
if (py_dylib == NULL) return report_linkEdit_error();
|
||||||
|
printf("3333333\n");
|
||||||
#define LOOKUP_SYMBOL(NAME) \
|
#define LOOKUP_SYMBOL(NAME) \
|
||||||
tmpSymbol = dlsym(py_dylib, # NAME)
|
tmpSymbol = dlsym(py_dylib, # NAME)
|
||||||
#define LOOKUP_DEFINEADDRESS(NAME, ADDRESS) \
|
#define LOOKUP_DEFINEADDRESS(NAME, ADDRESS) \
|
||||||
|
@ -26,6 +26,7 @@ ENV = dict(
|
|||||||
PYTHONIOENCODING='utf-8:replace',
|
PYTHONIOENCODING='utf-8:replace',
|
||||||
PYTHONPATH='@executable_path/../Resources/Python/site-packages',
|
PYTHONPATH='@executable_path/../Resources/Python/site-packages',
|
||||||
PYTHONHOME='@executable_path/../Resources/Python',
|
PYTHONHOME='@executable_path/../Resources/Python',
|
||||||
|
PYTHONOPTIMIZE='2',
|
||||||
QT_PLUGIN_PATH='@executable_path'
|
QT_PLUGIN_PATH='@executable_path'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ class Py2App(object):
|
|||||||
self.contents_dir = join(self.build_dir, 'Contents')
|
self.contents_dir = join(self.build_dir, 'Contents')
|
||||||
self.resources_dir = join(self.contents_dir, 'Resources')
|
self.resources_dir = join(self.contents_dir, 'Resources')
|
||||||
self.frameworks_dir = join(self.contents_dir, 'Frameworks')
|
self.frameworks_dir = join(self.contents_dir, 'Frameworks')
|
||||||
|
self.version_info = '.'.join(map(str, sys.version_info[:2]))
|
||||||
self.to_strip = []
|
self.to_strip = []
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
|
|
||||||
@ -141,6 +143,9 @@ class Py2App(object):
|
|||||||
launcher = launcher.replace('{}##ENV##', repr(ENV))
|
launcher = launcher.replace('{}##ENV##', repr(ENV))
|
||||||
os.mkdir(join(self.resources_dir, 'loaders'))
|
os.mkdir(join(self.resources_dir, 'loaders'))
|
||||||
for basename, module in zip(all_names, all_modules):
|
for basename, module in zip(all_names, all_modules):
|
||||||
|
py_file = join('src', *module.split('.'))+'.py'
|
||||||
|
shutil.copy2(py_file, join(self.resources_dir, 'Python',
|
||||||
|
'site-packages', *module.split('.'))+'.py')
|
||||||
raw = launcher.replace("''##MODULE##", repr(module))
|
raw = launcher.replace("''##MODULE##", repr(module))
|
||||||
path = join(self.resources_dir, 'loaders', basename)
|
path = join(self.resources_dir, 'loaders', basename)
|
||||||
open(path, 'wb').write(raw)
|
open(path, 'wb').write(raw)
|
||||||
@ -174,13 +179,10 @@ class Py2App(object):
|
|||||||
raw = subprocess.Popen(['otool', '-L', path_to_lib],
|
raw = subprocess.Popen(['otool', '-L', path_to_lib],
|
||||||
stdout=subprocess.PIPE).stdout.read()
|
stdout=subprocess.PIPE).stdout.read()
|
||||||
for line in raw.splitlines():
|
for line in raw.splitlines():
|
||||||
if 'compatibility' not in line:
|
if 'compatibility' not in line or line.strip().endswith(':'):
|
||||||
continue
|
continue
|
||||||
idx = line.find('(')
|
idx = line.find('(')
|
||||||
path = line[:idx].strip()
|
path = line[:idx].strip()
|
||||||
bname = os.path.basename(path).partition('.')[0]
|
|
||||||
if bname in path_to_lib:
|
|
||||||
continue
|
|
||||||
yield path
|
yield path
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
@ -213,6 +215,7 @@ class Py2App(object):
|
|||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_python_framework(self):
|
def add_python_framework(self):
|
||||||
|
print '\nAdding Python framework'
|
||||||
src = join(SW, 'python', 'Python.framework')
|
src = join(SW, 'python', 'Python.framework')
|
||||||
x = join(self.frameworks_dir, 'Python.framework')
|
x = join(self.frameworks_dir, 'Python.framework')
|
||||||
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
||||||
@ -223,6 +226,10 @@ class Py2App(object):
|
|||||||
shutil.copy2(join(curr, 'Python'), currd)
|
shutil.copy2(join(curr, 'Python'), currd)
|
||||||
self.set_id(join(currd, 'Python'),
|
self.set_id(join(currd, 'Python'),
|
||||||
self.FID+'/Python.framework/Versions/%s/Python'%basename(curr))
|
self.FID+'/Python.framework/Versions/%s/Python'%basename(curr))
|
||||||
|
python = '%s/python/Python.framework/Versions/%s/Resources/Python.app/Contents/MacOS/Python'\
|
||||||
|
% (SW, self.version_info)
|
||||||
|
shutil.copy2(python, join(self.contents_dir, 'MacOS'))
|
||||||
|
self.fix_dependencies_in_lib(join(self.contents_dir, 'MacOS', 'Python'))
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_qt_frameworks(self):
|
def add_qt_frameworks(self):
|
||||||
@ -279,7 +286,7 @@ class Py2App(object):
|
|||||||
CFBundleSignature='????',
|
CFBundleSignature='????',
|
||||||
CFBundleExecutable='calibre',
|
CFBundleExecutable='calibre',
|
||||||
LSMinimumSystemVersion='10.5.2',
|
LSMinimumSystemVersion='10.5.2',
|
||||||
PyRuntimeLocations=[self.FID+'/Python.framework/Versions/Current/Python'],
|
PyRuntimeLocations=[self.FID+'/Python.framework/Versions/%s/Python'%self.version_info],
|
||||||
LSRequiresNativeExecution=True,
|
LSRequiresNativeExecution=True,
|
||||||
NSAppleScriptEnabled=False,
|
NSAppleScriptEnabled=False,
|
||||||
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
||||||
@ -369,7 +376,9 @@ class Py2App(object):
|
|||||||
def add_misc_libraries(self):
|
def add_misc_libraries(self):
|
||||||
for x in ('usb', 'unrar'):
|
for x in ('usb', 'unrar'):
|
||||||
print '\nAdding', x
|
print '\nAdding', x
|
||||||
shutil.copy2(join(SW, 'lib', 'lib%s.dylib'%x), self.frameworks_dir)
|
x = 'lib%s.dylib'%x
|
||||||
|
shutil.copy2(join(SW, 'lib', x), self.frameworks_dir)
|
||||||
|
self.set_id(join(self.frameworks_dir, x), self.FID+'/'+x)
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_site_packages(self):
|
def add_site_packages(self):
|
||||||
@ -436,6 +445,11 @@ class Py2App(object):
|
|||||||
dest = join(dest, basename(x))
|
dest = join(dest, basename(x))
|
||||||
shutil.copytree(x, dest, symlinks=True, ignore=ignore)
|
shutil.copytree(x, dest, symlinks=True, ignore=ignore)
|
||||||
self.postprocess_package(x, dest)
|
self.postprocess_package(x, dest)
|
||||||
|
for x in os.walk(dest):
|
||||||
|
for f in x[-1]:
|
||||||
|
if f.endswith('.so'):
|
||||||
|
f = join(x[0], f)
|
||||||
|
self.fix_dependencies_in_lib(f)
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
def filter_package(self, name):
|
def filter_package(self, name):
|
||||||
@ -450,20 +464,22 @@ class Py2App(object):
|
|||||||
def add_stdlib(self):
|
def add_stdlib(self):
|
||||||
print '\nAdding python stdlib'
|
print '\nAdding python stdlib'
|
||||||
src = join(SW, 'python/Python.framework/Versions/Current/lib/python')
|
src = join(SW, 'python/Python.framework/Versions/Current/lib/python')
|
||||||
src += '.'.join(map(str, sys.version_info[:2]))
|
src += self.version_info
|
||||||
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
||||||
dest += '.'.join(map(str, sys.version_info[:2]))
|
dest += self.version_info
|
||||||
|
os.makedirs(dest)
|
||||||
for x in os.listdir(src):
|
for x in os.listdir(src):
|
||||||
if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
|
if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
|
||||||
'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
|
'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
|
||||||
continue
|
continue
|
||||||
|
x = join(src, x)
|
||||||
if os.path.isdir(x):
|
if os.path.isdir(x):
|
||||||
self.add_package_dir(join(src, x), dest)
|
self.add_package_dir(x, dest)
|
||||||
elif os.path.splitext(x) in ('.so', '.py'):
|
elif os.path.splitext(x)[1] in ('.so', '.py'):
|
||||||
shutil.copy2(join(src, x), dest)
|
shutil.copy2(x, dest)
|
||||||
dest = join(dest, basename(x))
|
dest2 = join(dest, basename(x))
|
||||||
if dest.endswith('.so'):
|
if dest2.endswith('.so'):
|
||||||
self.fix_dependencies_in_lib(dest)
|
self.fix_dependencies_in_lib(dest2)
|
||||||
self.remove_bytecode(join(self.resources_dir, 'Python', 'lib'))
|
self.remove_bytecode(join(self.resources_dir, 'Python', 'lib'))
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
@ -509,8 +525,10 @@ class Py2App(object):
|
|||||||
@flush
|
@flush
|
||||||
def copy_launcher_and_site(self):
|
def copy_launcher_and_site(self):
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
for x in ('launcher', 'site'):
|
shutil.copy2(join(base, 'launcher.py'), self.resources_dir)
|
||||||
shutil.copy2(join(base, x+'.py'), self.resources_dir)
|
shutil.copy2(join(base, 'site.py'), join(self.resources_dir, 'Python',
|
||||||
|
'lib', 'python'+self.version_info))
|
||||||
|
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
def makedmg(self, d, volname,
|
def makedmg(self, d, volname,
|
||||||
|
@ -305,6 +305,7 @@ Device._fields_ = [ \
|
|||||||
]
|
]
|
||||||
|
|
||||||
if _libusb is not None:
|
if _libusb is not None:
|
||||||
|
try:
|
||||||
_libusb.usb_get_busses.restype = POINTER(Bus)
|
_libusb.usb_get_busses.restype = POINTER(Bus)
|
||||||
_libusb.usb_open.restype = POINTER(DeviceHandle)
|
_libusb.usb_open.restype = POINTER(DeviceHandle)
|
||||||
_libusb.usb_open.argtypes = [POINTER(Device)]
|
_libusb.usb_open.argtypes = [POINTER(Device)]
|
||||||
@ -321,6 +322,8 @@ if _libusb is not None:
|
|||||||
_libusb.usb_set_configuration.argtypes = [POINTER(DeviceHandle), c_int]
|
_libusb.usb_set_configuration.argtypes = [POINTER(DeviceHandle), c_int]
|
||||||
_libusb.usb_set_configuration.restype = c_int
|
_libusb.usb_set_configuration.restype = c_int
|
||||||
_libusb.usb_init()
|
_libusb.usb_init()
|
||||||
|
except:
|
||||||
|
_libusb = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,8 +523,9 @@ class VMInstaller(OptionlessCommand):
|
|||||||
--exclude "*.pyc" --exclude "*.pyo" --exclude "*.swp" --exclude "*.swo" \
|
--exclude "*.pyc" --exclude "*.pyo" --exclude "*.swp" --exclude "*.swo" \
|
||||||
rsync://%(host)s/work/%(project)s . && \
|
rsync://%(host)s/work/%(project)s . && \
|
||||||
cd %(project)s && \
|
cd %(project)s && \
|
||||||
|
rm -rf src/calibre/plugins/* && \
|
||||||
%%s && \
|
%%s && \
|
||||||
rm -rf build/* dist/* src/calibre/plugins/* && \
|
rm -rf build/* dist/* && \
|
||||||
%%s %%s
|
%%s %%s
|
||||||
'''%dict(host=HOST, project=__appname__))
|
'''%dict(host=HOST, project=__appname__))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user