From 584d89c50e4dfde7006b789ab8c6e66bf517f262 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Aug 2008 18:18:17 -0700 Subject: [PATCH] IGN:Simplify build process --- Makefile | 30 ------------------ resources.py | 4 ++- setup.py | 62 ++++++++++++++++++++++++++++++++++++- src/calibre/manual/Makefile | 2 +- upload.py | 12 ++----- 5 files changed, 68 insertions(+), 42 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 1990ad22bd..0000000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -PYTHON = python - -all : gui2 translations resources - -clean : - cd src/calibre/gui2 && ${PYTHON} make.py clean - -gui2 : - cd src/calibre/gui2 && ${PYTHON} make.py - -test : gui2 - cd src/calibre/gui2 && ${PYTHON} make.py test - -translations : - cd src/calibre/translations && ${PYTHON} __init__.py - -resources: - ${PYTHON} resources.py - -manual: - make -C src/calibre/manual clean html - -pot : - cd src/calibre/translations && ${PYTHON} __init__.py pot - -egg : - ${PYTHON} setup.py bdist_egg --exclude-source-files - -linux_binary: - ${PYTHON} -c "import upload; upload._build_linux()" diff --git a/resources.py b/resources.py index 4b0bd846df..e5b426e2a4 100644 --- a/resources.py +++ b/resources.py @@ -37,7 +37,9 @@ def main(args=sys.argv): if not translations_found: print 'WARNING: Could not find Qt transations' - open('src'+os.sep+__appname__+os.sep+'/resources.py', 'wb').write(data) + dest = os.path.abspath(os.path.join('src', __appname__, 'resources.py')) + print 'Writing resources to', dest + open(dest, 'wb').write(data) return 0 if __name__ == '__main__': diff --git a/setup.py b/setup.py index 346c9059d5..0292aba9c0 100644 --- a/setup.py +++ b/setup.py @@ -47,9 +47,68 @@ main_functions = { if __name__ == '__main__': from setuptools import setup, find_packages, Extension + from distutils.command.build import build as _build + from distutils.core import Command from pyqtdistutils import PyQtExtension, build_ext import subprocess, glob + class pot(Command): + user_options = [] + def initialize_options(self): pass + def finalize_options(self): pass + + def run(self): + from calibre.translations import create_pot + create_pot() + + def build_manual(): + cwd = os.path.abspath(os.getcwd()) + os.chdir(os.path.join('src', 'calibre', 'manual')) + try: + for d in ('.build', 'cli'): + if os.path.exists(d): + shutil.rmtree(d) + os.makedirs(d) + if not os.path.exists('.build'+os.sep+'html'): + os.makedirs('.build'+os.sep+'html') + subprocess.check_call(['sphinx-build', '-b', 'custom', '-d', + '.build/doctrees', '.', '.build/html']) + finally: + os.chdir(cwd) + + class manual(Command): + user_options = [] + def initialize_options(self): pass + def finalize_options(self): pass + + def run(self): + build_manual() + + + class build(_build): + + def run(self): + # Build resources + resources = __import__('resources') + resources.main([sys.executable, 'resources.py']) + from calibre.translations import main as translations + cwd = os.path.abspath(os.getcwd()) + # Build translations + try: + os.chdir(os.path.join('src', 'calibre', 'translations')) + translations([sys.executable]) + finally: + os.chdir(cwd) + # Build GUI + from calibre.gui2.make import main as gui2 + try: + os.chdir(os.path.join('src', 'calibre', 'gui2')) + print 'Compiling GUI resources...' + gui2([sys.executable]) + finally: + os.chdir(cwd) + _build.run(self) + entry_points['console_scripts'].append('calibre_postinstall = calibre.linux:post_install') ext_modules = [ Extension('calibre.plugins.lzx', @@ -125,7 +184,8 @@ if __name__ == '__main__': 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: System :: Hardware :: Hardware Drivers' ], - cmdclass = {'build_ext': build_ext}, + cmdclass = {'build_ext': build_ext, 'build' : build, 'pot' : pot, + 'manual' : manual}, ) if 'develop' in ' '.join(sys.argv) and islinux: diff --git a/src/calibre/manual/Makefile b/src/calibre/manual/Makefile index 25e96dd637..b6f03e033b 100644 --- a/src/calibre/manual/Makefile +++ b/src/calibre/manual/Makefile @@ -21,7 +21,7 @@ help: @echo " linkcheck to check all external links for integrity" clean: - -rm -rf .build/* cli + rm -rf .build/* cli html: mkdir -p .build/html .build/doctrees diff --git a/upload.py b/upload.py index fc8a1754c2..e528c6f257 100644 --- a/upload.py +++ b/upload.py @@ -201,15 +201,9 @@ def upload_docs(): check_call('''scp docs/pdf/api.pdf divok:%s/'''%(DOCS,)) def upload_user_manual(): - cwd = os.getcwdu() - os.chdir('src/calibre/manual') - try: - check_call('make clean html') - check_call('ssh divok rm -rf %s/\\*'%USER_MANUAL) - check_call('scp -r .build/html/* divok:%s'%USER_MANUAL) - finally: - os.chdir(cwd) - + check_call('python setup.py manual') + check_call('scp -r .build/html/* divok:%s'%USER_MANUAL) + def build_src_tarball(): check_call('bzr export dist/calibre-%s.tar.bz2'%__version__)