Esempio n. 1
0
    def run(self, opts):
        base = os.path.join(self.d(self.SRC))
        for x in ('dist', 'build'):
            x = os.path.join(base, x)
            if os.path.exists(x):
                shutil.rmtree(x)
            os.mkdir(x)

        self.info('Starting builds for all platforms, this will take a while...')

        session = ['layout vertical']
        platforms = 'linux', 'osx', 'win'
        for x in platforms:
            cmd = (
                '''{exe} -c "import subprocess; subprocess.Popen(['{exe}', './setup.py', '{x}']).wait() != 0 and'''
                ''' input('Build of {x} failed, press Enter to exit');"'''
            ).format(exe=sys.executable, x=x)
            session.append('title ' + x)
            session.append('launch ' + cmd)

        p = subprocess.Popen([
            'kitty', '-o', 'enabled_layouts=vertical,stack', '-o', 'scrollback_lines=20000',
            '-o', 'close_on_child_death=y', '--session=-'
        ], stdin=subprocess.PIPE)

        p.communicate('\n'.join(session).encode('utf-8'))
        p.wait()

        for installer in installers(include_source=False):
            installer = self.j(self.d(self.SRC), installer)
            if not os.path.exists(installer) or os.path.getsize(installer) < 10000:
                raise SystemExit(
                    'The installer %s does not exist' % os.path.basename(installer)
                )
Esempio n. 2
0
    def run(self, opts):
        from distutils.spawn import find_executable
        for x in glob.glob(os.path.join(self.d(self.SRC), 'dist', '*')):
            os.remove(x)
        build = os.path.join(self.d(self.SRC), 'build')
        if os.path.exists(build):
            shutil.rmtree(build)
        processes = []
        tdir = tempfile.mkdtemp('_build_logs')
        atexit.register(shutil.rmtree, tdir)
        self.info(
            'Starting builds for all platforms, this will take a while...')

        def kill_child_on_parent_death():
            import ctypes, signal
            libc = ctypes.CDLL("libc.so.6")
            libc.prctl(1, signal.SIGTERM)

        for x in ('linux', 'osx', 'win'):
            log = open(os.path.join(tdir, x), 'w+b',
                       buffering=1)  # line buffered
            p = subprocess.Popen([sys.executable, 'setup.py', x],
                                 stdout=log,
                                 stderr=subprocess.STDOUT,
                                 cwd=self.d(self.SRC),
                                 preexec_fn=kill_child_on_parent_death)
            p.log, p.start_time, p.bname = log, time.time(), x
            p.duration = None
            processes.append(p)

        def workers_running():
            running = False
            for p in processes:
                rc = p.poll()
                if rc is not None:
                    if p.duration is None:
                        p.duration = int(time.time() - p.start_time)
                else:
                    running = True
            return running

        mtexe = find_executable('multitail')
        if mtexe:
            mtexe = subprocess.Popen([mtexe, '--basename'] +
                                     [pr.log.name for pr in processes],
                                     preexec_fn=kill_child_on_parent_death)

        while workers_running():
            os.waitpid(-1, 0)

        if mtexe and mtexe.poll() is None:
            mtexe.terminate(), mtexe.wait()

        failed = False
        for p in processes:
            if p.poll() != 0:
                failed = True
                log = p.log
                log.flush()
                log.seek(0)
                raw = log.read()
                self.info('Building of %s failed' % p.bname)
                sys.stderr.write(raw)
                sys.stderr.write(b'\n\n')
        if failed:
            raise SystemExit('Building of installers failed!')

        for p in sorted(processes, key=lambda p: p.duration):
            self.info('Built %s in %d minutes and %d seconds' %
                      (p.bname, p.duration // 60, p.duration % 60))

        for installer in installers(include_source=False):
            if not os.path.exists(self.j(self.d(self.SRC), installer)):
                raise SystemExit('The installer %s does not exist' %
                                 os.path.basename(installer))
Esempio n. 3
0
    def run(self, opts):
        from setup.multitail import pipe, multitail
        for x in glob.glob(os.path.join(self.d(self.SRC), 'dist', '*')):
            os.remove(x)
        build = os.path.join(self.d(self.SRC), 'build')
        if os.path.exists(build):
            shutil.rmtree(build)
        processes = []
        tdir = tempfile.mkdtemp('_build_logs')
        atexit.register(shutil.rmtree, tdir)
        self.info('Starting builds for all platforms, this will take a while...')
        def kill_child_on_parent_death():
            import ctypes, signal
            libc = ctypes.CDLL("libc.so.6")
            libc.prctl(1, signal.SIGTERM)

        for x in ('linux', 'osx', 'win'):
            r, w = pipe()
            p = subprocess.Popen([sys.executable, 'setup.py', x], stdout=w, stderr=subprocess.STDOUT,
                                 cwd=self.d(self.SRC), preexec_fn=kill_child_on_parent_death)
            p.log, p.start_time, p.bname = r, time.time(), x
            p.save = open(os.path.join(tdir, x), 'w+b')
            p.duration = None
            processes.append(p)

        def workers_running():
            running = False
            for p in processes:
                rc = p.poll()
                if rc is not None:
                    if p.duration is None:
                        p.duration = int(time.time() - p.start_time)
                else:
                    running = True
            return running

        stop_multitail = multitail(
            [proc.log for proc in processes],
            name_map={proc.log:proc.bname for proc in processes},
            copy_to=[proc.save for proc in processes]
        )[0]

        while workers_running():
            os.waitpid(-1, 0)

        stop_multitail()

        failed = False
        for p in processes:
            if p.poll() != 0:
                failed = True
                log = p.save
                log.flush()
                log.seek(0)
                raw = log.read()
                self.info('Building of %s failed' % p.bname)
                sys.stderr.write(raw)
                sys.stderr.write(b'\n\n')
        if failed:
            raise SystemExit('Building of installers failed!')

        for p in sorted(processes, key=lambda p:p.duration):
            self.info('Built %s in %d minutes and %d seconds' % (p.bname, p.duration // 60, p.duration % 60))

        for installer in installers(include_source=False):
            if not os.path.exists(self.j(self.d(self.SRC), installer)):
                raise SystemExit('The installer %s does not exist' % os.path.basename(installer))