mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:New windows build system
This commit is contained in:
parent
5e65dd3499
commit
a04024d455
@ -7,15 +7,12 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Freeze app into executable using py2exe.
|
Freeze app into executable using py2exe.
|
||||||
'''
|
'''
|
||||||
QT_DIR = 'C:\\Qt\\4.5.2'
|
QT_DIR = 'C:\\Qt\\4.5.2'
|
||||||
LIBUSB_DIR = 'C:\\libusb'
|
LIBUSB_DIR = r'C:\cygwin\home\kovid\win32\libusb'
|
||||||
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
|
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
|
||||||
PDFTOHTML = 'C:\\cygwin\\home\\kovid\\poppler-0.10.6\\rel\\pdftohtml.exe'
|
BINARIES = r'C:\cygwin\home\kovid\win32\bin'
|
||||||
POPPLER = 'C:\\cygwin\\home\\kovid\\poppler'
|
IMAGEMAGICK_DIR = r'C:\cygwin\home\kovid\win32\imagemagick'
|
||||||
IMAGEMAGICK_DIR = 'C:\\ImageMagick'
|
FONTCONFIG_DIR = r'C:\cygwin\home\kovid\win32\etc'
|
||||||
PDFTK = 'C:\\pdftk.exe'
|
VC90 = r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT'
|
||||||
PODOFO = 'C:\\podofo'
|
|
||||||
FONTCONFIG_DIR = 'C:\\fontconfig'
|
|
||||||
VC90 = r'C:\VC90.CRT'
|
|
||||||
|
|
||||||
# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
|
# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
|
||||||
import sys
|
import sys
|
||||||
@ -98,25 +95,17 @@ class BuildEXE(py2exe.build_exe.py2exe):
|
|||||||
shutil.copyfile(f, os.path.join(tdir, os.path.basename(f)))
|
shutil.copyfile(f, os.path.join(tdir, os.path.basename(f)))
|
||||||
print '\tAdding unrar'
|
print '\tAdding unrar'
|
||||||
shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR)))
|
shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR)))
|
||||||
print '\tAdding poppler'
|
print '\tAdding Binaries'
|
||||||
for x in ('bin\\pdftohtml.exe', 'bin\\poppler-qt4.dll',
|
for x in glob.glob(os.path.join(BINARIES, '*.dll')) + \
|
||||||
'bin\\freetype.dll', 'bin\\jpeg62.dll'):
|
[os.path.join(BINARIES, 'pdftohtml.exe')] + \
|
||||||
shutil.copyfile(os.path.join(POPPLER, x),
|
glob.glob(os.path.join(BINARIES, '*.manifest')):
|
||||||
os.path.join(PY2EXE_DIR, os.path.basename(x)))
|
shutil.copyfile(x, os.path.join(PY2EXE_DIR, os.path.basename(x)))
|
||||||
print '\tAdding podofo'
|
|
||||||
for f in glob.glob(os.path.join(PODOFO, '*.dll')):
|
|
||||||
shutil.copyfile(f, os.path.join(PY2EXE_DIR, os.path.basename(f)))
|
|
||||||
|
|
||||||
print '\tAdding ImageMagick'
|
print '\tAdding ImageMagick'
|
||||||
for f in os.listdir(IMAGEMAGICK_DIR):
|
for f in os.listdir(IMAGEMAGICK_DIR):
|
||||||
shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f))
|
shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f))
|
||||||
print '\tCopying fontconfig'
|
print '\tCopying fontconfig'
|
||||||
for f in glob.glob(os.path.join(FONTCONFIG_DIR, '*')):
|
tgt = os.path.join(PY2EXE_DIR, 'etc')
|
||||||
tgt = os.path.join(PY2EXE_DIR, os.path.basename(f))
|
shutil.copytree(FONTCONFIG_DIR, tgt)
|
||||||
if os.path.isdir(f):
|
|
||||||
shutil.copytree(f, tgt)
|
|
||||||
else:
|
|
||||||
shutil.copyfile(f, tgt)
|
|
||||||
|
|
||||||
print
|
print
|
||||||
print 'Doing DLL redirection' # See http://msdn.microsoft.com/en-us/library/ms682600(VS.85).aspx
|
print 'Doing DLL redirection' # See http://msdn.microsoft.com/en-us/library/ms682600(VS.85).aspx
|
||||||
@ -169,8 +158,7 @@ def main(args=sys.argv):
|
|||||||
'email.iterators',
|
'email.iterators',
|
||||||
'email.generator',
|
'email.generator',
|
||||||
'win32process', 'win32api', 'msvcrt',
|
'win32process', 'win32api', 'msvcrt',
|
||||||
'win32event', 'calibre.ebooks.lrf.any.*',
|
'win32event',
|
||||||
'calibre.ebooks.lrf.feeds.*',
|
|
||||||
'BeautifulSoup', 'pyreadline',
|
'BeautifulSoup', 'pyreadline',
|
||||||
'pydoc', 'IPython.Extensions.*',
|
'pydoc', 'IPython.Extensions.*',
|
||||||
'calibre.web.feeds.recipes.*',
|
'calibre.web.feeds.recipes.*',
|
||||||
|
17
setup.py
17
setup.py
@ -94,8 +94,8 @@ if __name__ == '__main__':
|
|||||||
sources=['src/calibre/utils/windows/winutil.c'],
|
sources=['src/calibre/utils/windows/winutil.c'],
|
||||||
libraries=['shell32', 'setupapi'],
|
libraries=['shell32', 'setupapi'],
|
||||||
include_dirs=os.environ.get('INCLUDE',
|
include_dirs=os.environ.get('INCLUDE',
|
||||||
'C:/WinDDK/6001.18001/inc/api/;'
|
'C:/WinDDK/7600.16385.0/inc/api/;'
|
||||||
'C:/WinDDK/6001.18001/inc/crt/').split(';'),
|
'C:/WinDDK/7600.16385.0/inc/crt/').split(';'),
|
||||||
extra_compile_args=['/X']
|
extra_compile_args=['/X']
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ if __name__ == '__main__':
|
|||||||
poppler_lib = '/usr/lib'
|
poppler_lib = '/usr/lib'
|
||||||
poppler_libs = []
|
poppler_libs = []
|
||||||
if iswindows:
|
if iswindows:
|
||||||
poppler_inc = r'C:\cygwin\home\kovid\poppler\include\poppler\qt4'
|
poppler_inc = r'C:\cygwin\home\kovid\win32\include\poppler\qt4'
|
||||||
poppler_lib = r'C:\cygwin\home\kovid\poppler\lib'
|
poppler_lib = r'C:\cygwin\home\kovid\win32\lib'
|
||||||
poppler_libs = ['QtCore4', 'QtGui4']
|
poppler_libs = ['QtCore4', 'QtGui4']
|
||||||
if isosx:
|
if isosx:
|
||||||
poppler_inc = '/Volumes/sw/build/poppler-0.10.7/qt4/src'
|
poppler_inc = '/Volumes/sw/build/poppler-0.10.7/qt4/src'
|
||||||
@ -124,9 +124,10 @@ if __name__ == '__main__':
|
|||||||
print 'POPPLER_LIB_DIR environment variables.'
|
print 'POPPLER_LIB_DIR environment variables.'
|
||||||
|
|
||||||
podofo_inc = '/usr/include/podofo' if islinux else \
|
podofo_inc = '/usr/include/podofo' if islinux else \
|
||||||
'C:\\podofo\\include\\podofo' if iswindows else \
|
r'C:\cygwin\home\kovid\win32\include\podofo' if iswindows else \
|
||||||
'/usr/local/include/podofo'
|
'/usr/local/include/podofo'
|
||||||
podofo_lib = '/usr/lib' if islinux else r'C:\podofo' if iswindows else \
|
podofo_lib = '/usr/lib' if islinux else \
|
||||||
|
r'C:\cygwin\home\kovid\win32\lib' if iswindows else \
|
||||||
'/usr/local/lib'
|
'/usr/local/lib'
|
||||||
podofo_inc = os.environ.get('PODOFO_INC_DIR', podofo_inc)
|
podofo_inc = os.environ.get('PODOFO_INC_DIR', podofo_inc)
|
||||||
if os.path.exists(os.path.join(podofo_inc, 'podofo.h')):
|
if os.path.exists(os.path.join(podofo_inc, 'podofo.h')):
|
||||||
@ -141,10 +142,10 @@ if __name__ == '__main__':
|
|||||||
print 'PODOFO_LIB_DIR environment variables.'
|
print 'PODOFO_LIB_DIR environment variables.'
|
||||||
|
|
||||||
fc_inc = '/usr/include/fontconfig' if islinux else \
|
fc_inc = '/usr/include/fontconfig' if islinux else \
|
||||||
r'C:\cygwin\home\kovid\fontconfig\include\fontconfig' if iswindows else \
|
r'C:\cygwin\home\kovid\win32\include\fontconfig' if iswindows else \
|
||||||
'/Users/kovid/fontconfig/include/fontconfig'
|
'/Users/kovid/fontconfig/include/fontconfig'
|
||||||
fc_lib = '/usr/lib' if islinux else \
|
fc_lib = '/usr/lib' if islinux else \
|
||||||
r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \
|
r'C:\cygwin\home\kovid\win32\lib' if iswindows else \
|
||||||
'/Users/kovid/fontconfig/lib'
|
'/Users/kovid/fontconfig/lib'
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class LibraryServer(object):
|
|||||||
<title>${authors}</title>
|
<title>${authors}</title>
|
||||||
<id>urn:calibre:${record[FM['id']]}</id>
|
<id>urn:calibre:${record[FM['id']]}</id>
|
||||||
<updated>${timestamp}</updated>
|
<updated>${timestamp}</updated>
|
||||||
<link type="application/atom+xml" href="/?authorid=${record[FM['id']]}" />
|
<link type="application/atom+xml" href="/stanza/?authorid=${record[FM['id']]}" />
|
||||||
</entry>
|
</entry>
|
||||||
'''))
|
'''))
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class LibraryServer(object):
|
|||||||
<title>calibre Library</title>
|
<title>calibre Library</title>
|
||||||
<id>$id</id>
|
<id>$id</id>
|
||||||
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link rel="search" title="Search" type="application/atom+xml" href="/?search={searchTerms}"/>
|
<link rel="search" title="Search" type="application/atom+xml" href="/stanza/?search={searchTerms}"/>
|
||||||
<author>
|
<author>
|
||||||
<name>calibre</name>
|
<name>calibre</name>
|
||||||
<uri>http://calibre.kovidgoyal.net</uri>
|
<uri>http://calibre.kovidgoyal.net</uri>
|
||||||
@ -140,7 +140,7 @@ class LibraryServer(object):
|
|||||||
<title>calibre Library</title>
|
<title>calibre Library</title>
|
||||||
<id>$id</id>
|
<id>$id</id>
|
||||||
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link rel="search" title="Search" type="application/atom+xml" href="/?search={searchTerms}"/>
|
<link rel="search" title="Search" type="application/atom+xml" href="/stanza/?search={searchTerms}"/>
|
||||||
<author>
|
<author>
|
||||||
<name>calibre</name>
|
<name>calibre</name>
|
||||||
<uri>http://calibre.kovidgoyal.net</uri>
|
<uri>http://calibre.kovidgoyal.net</uri>
|
||||||
@ -152,19 +152,19 @@ class LibraryServer(object):
|
|||||||
<title>By Author</title>
|
<title>By Author</title>
|
||||||
<id>urn:uuid:fc000fa0-8c23-11de-a31d-0002a5d5c51b</id>
|
<id>urn:uuid:fc000fa0-8c23-11de-a31d-0002a5d5c51b</id>
|
||||||
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link type="application/atom+xml" href="/?sortby=byauthor" />
|
<link type="application/atom+xml" href="/stanza/?sortby=byauthor" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<title>By Title</title>
|
<title>By Title</title>
|
||||||
<id>urn:uuid:1df4fe40-8c24-11de-b4c6-0002a5d5c51b</id>
|
<id>urn:uuid:1df4fe40-8c24-11de-b4c6-0002a5d5c51b</id>
|
||||||
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link type="application/atom+xml" href="/?sortby=bytitle" />
|
<link type="application/atom+xml" href="/stanza/?sortby=bytitle" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<title>By Newest</title>
|
<title>By Newest</title>
|
||||||
<id>urn:uuid:3c6d4940-8c24-11de-a4d7-0002a5d5c51b</id>
|
<id>urn:uuid:3c6d4940-8c24-11de-a4d7-0002a5d5c51b</id>
|
||||||
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
|
||||||
<link type="application/atom+xml" href="/?sortby=bynewest" />
|
<link type="application/atom+xml" href="/stanza/?sortby=bynewest" />
|
||||||
</entry>
|
</entry>
|
||||||
</feed>
|
</feed>
|
||||||
'''))
|
'''))
|
||||||
|
59
upload.py
59
upload.py
@ -528,6 +528,27 @@ class VMInstaller(OptionlessCommand):
|
|||||||
def get_build_script(self, subs):
|
def get_build_script(self, subs):
|
||||||
return self.BUILD_SCRIPT%subs
|
return self.BUILD_SCRIPT%subs
|
||||||
|
|
||||||
|
def vmware_started(self):
|
||||||
|
return 'started' in subprocess.Popen('/etc/init.d/vmware status', shell=True, stdout=subprocess.PIPE).stdout.read()
|
||||||
|
|
||||||
|
def start_vmware(self):
|
||||||
|
if not self.vmware_started():
|
||||||
|
if os.path.exists('/dev/kvm'):
|
||||||
|
check_call('sudo rmmod -w kvm-intel kvm', shell=True)
|
||||||
|
subprocess.Popen('sudo /etc/init.d/vmware start', shell=True)
|
||||||
|
|
||||||
|
def stop_vmware(self):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
check_call('sudo /etc/init.d/vmware stop', shell=True)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
while 'vmblock' in open('/proc/modules').read():
|
||||||
|
check_call('sudo rmmod -f vmblock')
|
||||||
|
check_call('sudo modprobe kvm-intel', shell=True)
|
||||||
|
|
||||||
|
|
||||||
def run_vm(self):
|
def run_vm(self):
|
||||||
vmware = ('vmware', '-q', '-x', '-n', self.VM)
|
vmware = ('vmware', '-q', '-x', '-n', self.VM)
|
||||||
self.__p = Popen(vmware)
|
self.__p = Popen(vmware)
|
||||||
@ -547,9 +568,18 @@ class VMInstaller(OptionlessCommand):
|
|||||||
check_call(('scp', t.name, ssh_host+':build-calibre'))
|
check_call(('scp', t.name, ssh_host+':build-calibre'))
|
||||||
check_call('ssh -t %s bash build-calibre'%ssh_host, shell=True)
|
check_call('ssh -t %s bash build-calibre'%ssh_host, shell=True)
|
||||||
|
|
||||||
class build_linux32(VMInstaller):
|
class KVMInstaller(VMInstaller):
|
||||||
|
|
||||||
|
def run_vm(self):
|
||||||
|
self.stop_vmware()
|
||||||
|
self.__p = Popen(self.VM)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class build_linux32(KVMInstaller):
|
||||||
|
|
||||||
description = 'Build linux 32bit installer'
|
description = 'Build linux 32bit installer'
|
||||||
|
VM = '/vmware/bin/linux_build'
|
||||||
|
|
||||||
def run_vm(self):
|
def run_vm(self):
|
||||||
self.__p = Popen('/vmware/bin/linux_build')
|
self.__p = Popen('/vmware/bin/linux_build')
|
||||||
@ -569,25 +599,23 @@ class build_linux32(VMInstaller):
|
|||||||
return _build_linux()
|
return _build_linux()
|
||||||
|
|
||||||
|
|
||||||
class build_windows(VMInstaller):
|
class build_windows(KVMInstaller):
|
||||||
description = 'Build windows installer'
|
description = 'Build windows installer'
|
||||||
VM = '/mnt/backup/calibre_windows_xp_home/calibre_windows_xp_home.vmx'
|
VM = '/vmware/bin/win_build'
|
||||||
if not os.path.exists(VM):
|
|
||||||
VM = '/home/kovid/calibre_windows_xp_home/calibre_windows_xp_home.vmx'
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
installer = installer_name('exe')
|
installer = installer_name('exe')
|
||||||
self.start_vm('windows', ('python setup.py develop',
|
self.start_vm('win_build', ('python setup.py develop',
|
||||||
'python',
|
'python',
|
||||||
r'installer\\windows\\freeze.py'))
|
r'installer\\windows\\freeze.py'))
|
||||||
if os.path.exists('build/py2exe'):
|
if os.path.exists('build/py2exe'):
|
||||||
shutil.rmtree('build/py2exe')
|
shutil.rmtree('build/py2exe')
|
||||||
check_call(('scp', '-rp', 'windows:build/%s/build/py2exe'%__appname__,
|
check_call(('scp', '-rp', 'win_build:build/%s/build/py2exe'%__appname__,
|
||||||
'build'))
|
'build'))
|
||||||
if not os.path.exists('build/py2exe'):
|
if not os.path.exists('build/py2exe'):
|
||||||
raise Exception('Failed to run py2exe')
|
raise Exception('Failed to run py2exe')
|
||||||
if not self.dont_shutdown:
|
if not self.dont_shutdown:
|
||||||
Popen(('ssh', 'windows', 'shutdown', '-s', '-t', '0'))
|
Popen(('ssh', 'win_build', 'shutdown', '-s', '-t', '0'))
|
||||||
self.run_windows_install_jammer(installer)
|
self.run_windows_install_jammer(installer)
|
||||||
return os.path.basename(installer)
|
return os.path.basename(installer)
|
||||||
|
|
||||||
@ -613,9 +641,7 @@ class build_osx(VMInstaller):
|
|||||||
def run(self):
|
def run(self):
|
||||||
installer = installer_name('dmg')
|
installer = installer_name('dmg')
|
||||||
python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python'
|
python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python'
|
||||||
if os.path.exists('/dev/kvm'):
|
self.start_vmware()
|
||||||
check_call('sudo rmmod -w kvm-intel kvm', shell=True)
|
|
||||||
check_call('sudo /etc/init.d/vmware restart', shell=True)
|
|
||||||
self.start_vm('osx_build', ('sudo %s setup.py develop'%python, python,
|
self.start_vm('osx_build', ('sudo %s setup.py develop'%python, python,
|
||||||
'installer/osx/freeze.py'))
|
'installer/osx/freeze.py'))
|
||||||
check_call(('scp', 'osx_build:build/calibre/dist/*.dmg', 'dist'))
|
check_call(('scp', 'osx_build:build/calibre/dist/*.dmg', 'dist'))
|
||||||
@ -624,18 +650,9 @@ class build_osx(VMInstaller):
|
|||||||
if not self.dont_shutdown:
|
if not self.dont_shutdown:
|
||||||
Popen(('ssh', 'osx_build', 'sudo', '/sbin/shutdown', '-h', 'now'))
|
Popen(('ssh', 'osx_build', 'sudo', '/sbin/shutdown', '-h', 'now'))
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
while True:
|
self.stop_vmware()
|
||||||
try:
|
|
||||||
check_call('sudo /etc/init.d/vmware stop', shell=True)
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
check_call('sudo modprobe kvm-intel', shell=True)
|
|
||||||
|
|
||||||
return os.path.basename(installer)
|
return os.path.basename(installer)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class upload_installers(OptionlessCommand):
|
class upload_installers(OptionlessCommand):
|
||||||
description = 'Upload any installers present in dist/'
|
description = 'Upload any installers present in dist/'
|
||||||
def curl_list_dir(self, url=MOBILEREAD, listonly=1):
|
def curl_list_dir(self, url=MOBILEREAD, listonly=1):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user