diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index 294fc98434..470fee7f9b 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -27,9 +27,6 @@ jobs: - name: Install calibre dependencies run: setup/arch-ci.sh - - name: Install translations dependencies - run: python -m pip install transifex-client - - name: Bootstrap calibre run: runuser -u ci -- python setup.py bootstrap --ephemeral diff --git a/setup/translations.py b/setup/translations.py index 01cbbb656e..c875935c3c 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -37,7 +37,7 @@ class POT(Command): # {{{ kw['cwd'] = kw.get('cwd', self.TRANSLATIONS) if hasattr(cmd, 'format'): cmd = shlex.split(cmd) - cmd = ['tx', '--traceback'] + cmd + cmd = [os.environ.get('TX', 'tx')] + cmd self.info(' '.join(cmd)) return subprocess.check_call(cmd, **kw) @@ -690,7 +690,7 @@ class GetTranslations(Translations): # {{{ if opts.check_for_errors: self.check_all() return - self.tx('pull -a --parallel --no-interactive') + self.tx('pull -a') if not self.is_modified: self.info('No translations were updated') return diff --git a/setup/unix-ci.py b/setup/unix-ci.py index de4c21bc86..5d7f8bc604 100644 --- a/setup/unix-ci.py +++ b/setup/unix-ci.py @@ -3,12 +3,16 @@ import glob +import io +import json import os import shlex import subprocess import sys +import tarfile import time from tempfile import NamedTemporaryFile +from urllib.request import urlopen _plat = sys.platform.lower() ismacos = 'darwin' in _plat @@ -106,6 +110,23 @@ def install_linux_deps(): run('sudo', 'apt-get', 'install', '-y', 'gettext', 'libgl1-mesa-dev') +def get_tx_tarball_url(): + data = json.load(urlopen( + 'https://api.github.com/repos/transifex/cli/releases/latest')) + for asset in data['assets']: + if asset['name'] == 'tx-linux-amd64.tar.gz': + return asset['browser_download_url'] + + +def get_tx(): + url = get_tx_tarball_url() + print('Downloading:', url) + with urlopen(url) as f: + raw = f.read() + with tarfile.open(fileobj=io.BytesIO(raw), mode='r') as tf: + tf.extract('tx') + + def main(): if iswindows: import runpy @@ -130,16 +151,19 @@ def main(): elif action == 'pot': transifexrc = '''\ [https://www.transifex.com] -api_hostname = https://api.transifex.com +api_hostname = https://api.transifex.com +rest_hostname = https://rest.api.transifex.com hostname = https://www.transifex.com password = PASSWORD +token = PASSWORD username = api '''.replace('PASSWORD', os.environ['tx']) with open(os.path.expanduser('~/.transifexrc'), 'w') as f: f.write(transifexrc) install_qt_source_code() install_env() - run(sys.executable, '-m', 'pip', 'install', 'transifex-client') + get_tx() + os.environ['TX'] = os.path.abspath('tx') run(sys.executable, 'setup.py', 'pot') elif action == 'test': os.environ['CI'] = 'true'