From deb68118e10ab656e3e18734676cde7f9bf0b140 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 22 Jun 2016 11:24:42 +0530 Subject: [PATCH] Add a --ephemeral option to bootstrap to speed up fetching of translations --- setup/install.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/setup/install.py b/setup/install.py index cf35a3c827..7fcfe4d041 100644 --- a/setup/install.py +++ b/setup/install.py @@ -329,12 +329,21 @@ class Bootstrap(Command): TRANSLATIONS_REPO = 'https://github.com/kovidgoyal/calibre-translations.git' sub_commands = 'build iso639 iso3166 translations gui resources cacerts mathjax'.split() + def add_options(self, parser): + parser.add_option('--ephemeral', default=False, action='store_true', + help='Do not download all the history for the translation repo. Speeds up first time download but subsequent downloads will be slower.') + def pre_sub_commands(self, opts): tdir = self.j(self.d(self.SRC), 'translations') - if os.path.exists(tdir): - subprocess.check_call(['git', 'pull'], cwd=tdir) + if opts.ephemeral: + if os.path.exists(tdir): + shutil.rmtree(tdir) + subprocess.check_call(['git', 'clone', '--depth=1', self.TRANSLATIONS_REPO, 'translations'], cwd=self.d(self.SRC)) else: - subprocess.check_call(['git', 'clone', self.TRANSLATIONS_REPO, 'translations'], cwd=self.d(self.SRC)) + if os.path.exists(tdir): + subprocess.check_call(['git', 'pull'], cwd=tdir) + else: + subprocess.check_call(['git', 'clone', self.TRANSLATIONS_REPO, 'translations'], cwd=self.d(self.SRC)) def run(self, opts): self.info('\n\nAll done! You should now be able to run "%s setup.py install" to install calibre' % sys.executable)