Example #1
0
def run_tests(path_to_calibre_debug, cwd_on_failure):
    if run(path_to_calibre_debug, '--test-build') != 0:
        os.chdir(cwd_on_failure)
        print(
            'running calibre build tests failed with:', path_to_calibre_debug, file=sys.stderr)
        run_shell()
        raise SystemExit('running calibre build tests failed')
Example #2
0
def build_c_extensions(ext_dir, args):
    writeable_src_dir = os.path.join(ext_dir, 'src')
    build_frozen_launcher.writeable_src_dir = writeable_src_dir
    shutil.copytree(KITTY_DIR,
                    writeable_src_dir,
                    symlinks=True,
                    ignore=shutil.ignore_patterns('b', 'build', 'dist',
                                                  '*_commands.json', '*.o',
                                                  '*.so', '*.dylib', '*.pyd'))

    with suppress(FileNotFoundError):
        os.unlink(os.path.join(writeable_src_dir, 'kitty', 'launcher',
                               'kitty'))

    cmd = [PYTHON, 'setup.py', 'macos-freeze' if ismacos else 'linux-freeze']
    if args.dont_strip:
        cmd.append('--debug')
    dest = kitty_constants['appname'] + ('.app' if ismacos else '')
    dest = build_frozen_launcher.prefix = os.path.join(ext_dir, dest)
    cmd += ['--prefix', dest, '--full']
    if run(*cmd, cwd=writeable_src_dir) != 0:
        print('Building of kitty package failed', file=sys.stderr)
        os.chdir(writeable_src_dir)
        run_shell()
        raise SystemExit('Building of kitty package failed')
    return ext_dir
Example #3
0
def run_tests(path_to_calibre_debug, cwd_on_failure):
    p = subprocess.Popen([path_to_calibre_debug, '--test-build'])
    if p.wait() != 0:
        os.chdir(cwd_on_failure)
        print('running calibre build tests failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.wait())
Example #4
0
def run_tests(path_to_calibre_debug, cwd_on_failure):
    p = subprocess.Popen([path_to_calibre_debug, '--test-build'])
    if p.wait() != 0:
        os.chdir(cwd_on_failure)
        print('running calibre build tests failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.wait())
Example #5
0
def build_c_extensions(ext_dir, args):
    writeable_src_dir = os.path.join(ext_dir, 'src')
    shutil.copytree(KITTY_DIR,
                    writeable_src_dir,
                    symlinks=True,
                    ignore=shutil.ignore_patterns('b', 'build', 'dist',
                                                  '*_commands.json', '*.o'))

    # Build the launcher as it is needed for the spawn test
    with suppress(FileNotFoundError):
        os.remove(os.path.join(writeable_src_dir, 'kitty', 'launcher',
                               'kitty'))
    if run(PYTHON, 'setup.py', 'build-launcher', cwd=writeable_src_dir) != 0:
        print('Building of kitty launcher failed', file=sys.stderr)
        os.chdir(KITTY_DIR)
        run_shell()
        raise SystemExit('Building of kitty launcher failed')

    cmd = [PYTHON, 'setup.py']
    bundle = 'macos-freeze' if ismacos else 'linux-freeze'
    cmd.append(bundle)
    dest = kitty_constants['appname'] + ('.app' if ismacos else '')
    dest = os.path.join(ext_dir, dest)
    cmd += ['--prefix', dest]
    if run(*cmd, cwd=writeable_src_dir) != 0:
        print('Building of kitty package failed', file=sys.stderr)
        os.chdir(KITTY_DIR)
        run_shell()
        raise SystemExit('Building of kitty package failed')
    return ext_dir
Example #6
0
def build_c_extensions(ext_dir):
    bdir = os.path.join(build_dir(), 'calibre-extension-objects')
    if run(PYTHON, 'setup.py', 'build', '--output-dir', ext_dir, '--build-dir',
           bdir) != 0:
        print('Building of calibre C extensions failed', file=sys.stderr)
        os.chdir(CALIBRE_DIR)
        run_shell()
        raise SystemExit('Building of calibre C extensions failed')
Example #7
0
def run_tests(path_to_kitty, cwd_on_failure):
    ret = run(PYTHON, 'test.py', cwd=cwd_on_failure)
    if ret != 0:
        os.chdir(cwd_on_failure)
        print(
            'running kitty tests failed with return code:', ret, file=sys.stderr)
        run_shell()
        raise SystemExit('running kitty tests failed')
Example #8
0
def run_tests(path_to_calibre_debug, cwd_on_failure):
    ret = run(path_to_calibre_debug, '--test-build')
    if ret != 0:
        os.chdir(cwd_on_failure)
        print(
            'running calibre build tests failed with return code:', ret, 'and exe:', path_to_calibre_debug, file=sys.stderr)
        run_shell()
        raise SystemExit('running calibre build tests failed')
Example #9
0
def build_frozen_launcher(extra_include_dirs):
    inc_dirs = [f'--extra-include-dirs={x}' for x in extra_include_dirs]
    cmd = SETUP_CMD + ['--prefix', build_frozen_launcher.prefix] + inc_dirs + ['build-frozen-launcher']
    if run(*cmd, cwd=build_frozen_launcher.writeable_src_dir) != 0:
        print('Building of frozen kitty launcher failed', file=sys.stderr)
        os.chdir(KITTY_DIR)
        run_shell()
        raise SystemExit('Building of kitty launcher failed')
    return build_frozen_launcher.writeable_src_dir
Example #10
0
def build_extensions(env, ext_dir):
    wenv = os.environ.copy()
    wenv.update(worker_env)
    wenv['LD_LIBRARY_PATH'] = LIBDIR
    wenv['QMAKE'] = os.path.join(QT_PREFIX, 'bin', 'qmake')
    wenv['SW'] = PREFIX
    wenv['SIP_BIN'] = os.path.join(PREFIX, 'bin', 'sip')
    p = subprocess.Popen([PYTHON, 'setup.py', 'build', '--build-dir=' + build_dir(), '--output-dir=' + ext_dir], env=wenv, cwd=CALIBRE_DIR)
    if p.wait() != 0:
        os.chdir(CALIBRE_DIR)
        print('building calibre extensions failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.returncode)
Example #11
0
def run_tests(kitty_exe):
    with tempfile.TemporaryDirectory() as tdir:
        env = {
            'KITTY_CONFIG_DIRECTORY': os.path.join(tdir, 'conf'),
            'KITTY_CACHE_DIRECTORY': os.path.join(tdir, 'cache')
        }
        [os.mkdir(x) for x in env.values()]
        cmd = [kitty_exe, '+runpy', 'from kitty_tests.main import run_tests; run_tests()']
        print(*map(shlex.quote, cmd), flush=True)
        if subprocess.call(cmd, env=env) != 0:
            print('Checking of kitty build failed', file=sys.stderr)
            os.chdir(os.path.dirname(kitty_exe))
            run_shell()
            raise SystemExit('Checking of kitty build failed')
Example #12
0
def run_tests(path_to_kitty, cwd_on_failure):
    kw = {'cwd': cwd_on_failure}
    if not ismacos:
        # this is needed for the spawn test which starts an interpreter
        # using the kitty launcher.
        kw['PYTHONHOME'] = PREFIX
    ret = run(PYTHON, 'test.py', **kw)
    if ret != 0:
        os.chdir(cwd_on_failure)
        print('running kitty tests failed with return code:',
              ret,
              file=sys.stderr)
        run_shell()
        raise SystemExit('running kitty tests failed')
Example #13
0
def build_c_extensions(ext_dir, args):
    bdir = os.path.join(build_dir(), 'calibre-extension-objects')
    cmd = [
        PYTHON, 'setup.py', 'build',
        '--output-dir', ext_dir, '--build-dir', bdir,
    ]
    if args.build_only:
        cmd.extend(('--only', args.build_only))
    if run(*cmd, COMPILER_CWD=bdir) != 0:
        print('Building of calibre C extensions failed', file=sys.stderr)
        os.chdir(CALIBRE_DIR)
        run_shell()
        raise SystemExit('Building of calibre C extensions failed')
    return ext_dir
Example #14
0
def build_c_extensions(ext_dir, args):
    writeable_src_dir = os.path.join(ext_dir, 'src')
    shutil.copytree(
        KITTY_DIR, writeable_src_dir, symlinks=True,
        ignore=shutil.ignore_patterns('b', 'build', 'dist', '*_commands.json', '*.o'))
    cmd = [PYTHON, 'setup.py']
    bundle = 'macos-freeze' if ismacos else 'linux-freeze'
    cmd.append(bundle)
    dest = kitty_constants['appname'] + ('.app' if ismacos else '')
    dest = os.path.join(ext_dir, dest)
    cmd += ['--prefix', dest]
    if run(*cmd, cwd=writeable_src_dir) != 0:
        print('Building of kitty package failed', file=sys.stderr)
        os.chdir(KITTY_DIR)
        run_shell()
        raise SystemExit('Building of kitty package failed')
    return ext_dir
Example #15
0
def build_extensions(env, ext_dir):
    wenv = os.environ.copy()
    wenv.update(worker_env)
    wenv['LD_LIBRARY_PATH'] = LIBDIR
    wenv['QMAKE'] = os.path.join(QT_PREFIX, 'bin', 'qmake')
    wenv['SW'] = PREFIX
    wenv['SIP_BIN'] = os.path.join(PREFIX, 'bin', 'sip')
    p = subprocess.Popen([
        PYTHON, 'setup.py', 'build', '--build-dir=' + build_dir(),
        '--output-dir=' + ext_dir
    ],
                         env=wenv,
                         cwd=CALIBRE_DIR)
    if p.wait() != 0:
        os.chdir(CALIBRE_DIR)
        print('building calibre extensions failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.returncode)
Example #16
0
 def altool(*args):
     args = ['xcrun', 'altool'
             ] + list(args) + ['--username', un, '--password', pw]
     p = subprocess.Popen(args,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
     stdout, stderr = p.communicate()
     stdout = stdout.decode('utf-8')
     stderr = stderr.decode('utf-8')
     output = stdout + '\n' + stderr
     print(output)
     if p.wait() != 0:
         print('The command {} failed with error code: {}'.format(
             args, p.returncode))
         try:
             run_shell()
         finally:
             raise SystemExit(1)
     return output
Example #17
0
 def run_shell(self):
     with current_dir(self.contents_dir):
         run_shell()