def _check_committed(self): """ Check if everything is committed """ git = shell.frompath('git') lines = shell.spawn( git, 'branch', '--color=never', stdout=True, env=dict(_os.environ, LC_ALL='C') ).splitlines() for line in lines: if line.startswith('*'): branch = line.split(None, 1)[1] break else: make.fail("Could not determine current branch.") if branch != 'master': rex = _re.compile(r'^\d+(?:\.\d+)*\.[xX]$').match match = rex(branch) if not match: make.fail("Not in master or release branch.") lines = shell.spawn( git, 'status', '--porcelain', stdout=True, env=dict(_os.environ, LC_ALL='C'), ) if lines: make.fail("Uncommitted changes!")
def _update_versions(self): """ Update versions """ self.runner('revision', 'version', seen={}) git = shell.frompath('git') shell.spawn(git, 'commit', '-a', '-m', 'Pre-release: version update', echo=True )
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read('package.cfg', **cfgread) strversion = parser.get('package', 'version.number') version = strversion trunk_url = self._repo_url() if not trunk_url.endswith('/trunk'): rex = _re.compile(r'/branches/\d+(?:\.\d+)*\.[xX]$').search match = rex(trunk_url) if not match: make.fail("Not in trunk or release branch!") found = match.start(0) else: found = -len('/trunk') release_url = trunk_url[:found] + '/releases/' + version svn = shell.frompath('svn') shell.spawn( svn, 'copy', '-m', 'Release version ' + version, '--', trunk_url, release_url, echo=True, )
def _check_committed(self): """ Check if everything is committed """ git = shell.frompath('git') lines = shell.spawn(git, 'branch', '--color=never', stdout=True, env=dict(_os.environ, LC_ALL='C')).splitlines() for line in lines: if line.startswith('*'): branch = line.split(None, 1)[1] break else: make.fail("Could not determine current branch.") if branch != 'master': rex = _re.compile(r'^\d+(?:\.\d+)*\.[xX]$').match match = rex(branch) if not match: make.fail("Not in master or release branch.") lines = shell.spawn( git, 'status', '--porcelain', stdout=True, env=dict(_os.environ, LC_ALL='C'), ) if lines: make.fail("Uncommitted changes!")
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read('package.cfg', **cfgread) strversion = parser.get('package', 'version.number') isdev = parser.getboolean('package', 'version.dev') revision = parser.getint('package', 'version.revision') version = strversion if isdev: version += '-dev-r%d' % (revision,) trunk_url = self._repo_url() if not trunk_url.endswith('/trunk'): rex = _re.compile(r'/branches/\d+(?:\.\d+)*\.[xX]$').search match = rex(trunk_url) if not match: make.fail("Not in trunk or release branch!") found = match.start(0) else: found = -len('/trunk') release_url = trunk_url[:found] + '/releases/' + version svn = shell.frompath('svn') shell.spawn( svn, 'copy', '-m', 'Release version ' + version, '--', trunk_url, release_url, echo=True, )
def sign_external(self, filename, detach=True): """ Sign calling gpg """ gpg = _shell.frompath('gpg') if gpg is None: _make.warn('GPG not found -> cannot sign') return False if detach: _shell.spawn( gpg, '--armor', '--output', filename + '.asc', '--detach-sign', '--', filename, ) else: _shell.spawn( gpg, '--output', filename + '.signed', '--clearsign', '--', filename, ) _os.rename(filename + '.signed', filename) return True
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read("package.cfg", **cfgread) strversion = parser.get("package", "version.number") isdev = parser.getboolean("package", "version.dev") revision = parser.getint("package", "version.revision") version = strversion if isdev: version += "-dev-r%d" % (revision,) trunk_url = self._repo_url() if not trunk_url.endswith("/trunk"): rex = _re.compile(r"/branches/\d+(?:\.\d+)*\.[xX]$").search match = rex(trunk_url) if not match: make.fail("Not in trunk or release branch!") found = match.start(0) else: found = -len("/trunk") release_url = trunk_url[:found] + "/releases/" + version svn = shell.frompath("svn") shell.spawn(svn, "copy", "-m", "Release version " + version, "--", trunk_url, release_url, echo=True)
def _update_versions(self): """ Update versions """ self.runner('version', seen={}) svn = shell.frompath('svn') shell.spawn(svn, 'commit', '-m', 'Pre-release: version update', echo=True )
def dist_pkg(self): term.green("Building package...") dist.run_setup("sdist", "--formats", "tar,zip", fakeroot=shell.frompath("fakeroot")) exts = [".zip"] for name in shell.files(self.dirs["dist"], "*.tar", False): exts.extend(self.compress(name)) shell.rm(name) return exts
def compress_external(self, infile, outfile, *argv): argv = list(argv) argv[0] = _shell.frompath(argv[0]) if argv[0] is not None: return not _shell.spawn(*argv, **{ 'filepipe': True, 'stdin': infile, 'stdout': outfile, }) return None
def _update_versions(self): """ Update versions """ self.runner('version', seen={}) svn = shell.frompath('svn') shell.spawn(svn, 'commit', '-m', 'Pre-release: version update', echo=True)
def dist_pkg(self): _term.green("Building package...") _dist.run_setup("sdist", "--formats", "tar,zip", fakeroot=_shell.frompath('fakeroot') ) exts = ['.zip'] for name in _shell.files(self._dist, '*.tar', False): exts.extend(self.compress(name)) _shell.rm(name) return exts
def run(self): files = list(shell.files(self.dirs['bench'], '*.css')) if self.python is None: python = _sys.executable else: python = shell.frompath(self.python) return not shell.spawn(*[ python, '-mbench.main', '-c10', ] + files)
def compress_external(self, infile, outfile, *argv): argv = list(argv) argv[0] = _shell.frompath(argv[0]) if argv[0] is not None: return not _shell.spawn( *argv, **{ 'filepipe': True, 'stdin': infile, 'stdout': outfile, }) return None
def dist_pkg(self): _term.green("Building package...") _dist.run_setup("sdist", "--formats", "tar,zip", fakeroot=_shell.frompath('fakeroot')) exts = ['.zip'] for name in _shell.files(self._dist, '*.tar', False): exts.extend(self.compress(name)) _shell.rm(name) return exts
def run(self): files = list(shell.files(self.dirs['bench'], '*.js')) if self.python is None: python = _sys.executable else: python = shell.frompath(self.python) return not shell.spawn(*[ python, '-mbench.main', '-c10', ] + files)
def sign_external(self, filename, detach=True): """ Sign calling gpg """ gpg = shell.frompath("gpg") if gpg is None: make.warn("GPG not found -> cannot sign") return False if detach: shell.spawn(gpg, "--armor", "--output", filename + ".asc", "--detach-sign", "--", filename) else: shell.spawn(gpg, "--output", filename + ".signed", "--clearsign", "--", filename) _os.rename(filename + ".signed", filename) return True
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read('package.cfg', **cfgread) strversion = parser.get('package', 'version.number') version = strversion git = shell.frompath('git') shell.spawn( git, 'tag', '-a', '-m', 'Release version ' + version, '--', version, echo=True, )
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read("package.cfg", **cfgread) strversion = parser.get("package", "version.number") isdev = parser.getboolean("package", "version.dev") revision = parser.getint("package", "version.revision") version = strversion if isdev: version += "-dev-r%d" % (revision,) git = shell.frompath("git") shell.spawn(git, "tag", "-a", "-m", "Release version " + version, "--", version, echo=True)
def _revision(self): """ Find SVN revision """ rev = shell.spawn(shell.frompath('svnversion'), '.', stdout=True) rev = rev.strip() if ':' in rev: rev = rev.split(':')[1] try: rev = int(rev) except ValueError: try: rev = int(rev[:-1]) except ValueError: make.fail("No clean revision found (%s)" % rev) return rev
def _check_committed(self): """ Check if everything is committed """ if not self._repo_url().endswith('/trunk'): rex = _re.compile(r'/branches/\d+(?:\.\d+)*\.[xX]$').search match = rex(self._repo_url()) if not match: make.fail("Not in trunk or release branch!") svn = shell.frompath('svn') lines = shell.spawn(svn, 'stat', '--ignore-externals', stdout=True, env=dict(_os.environ, LC_ALL='C'), ).splitlines() for line in lines: if line.startswith('X'): continue make.fail("Uncommitted changes!")
def _repo_url(self): """ Determine URL """ from xml.dom import minidom svn = shell.frompath('svn') info = minidom.parseString( shell.spawn(svn, 'info', '--xml', stdout=True)) try: url = info.getElementsByTagName('url')[0] text = [] for node in url.childNodes: if node.nodeType == node.TEXT_NODE: text.append(node.data) finally: info.unlink() return ''.join(text).encode('utf-8')
def _repo_url(self): """ Determine URL """ from xml.dom import minidom svn = shell.frompath("svn") info = minidom.parseString(shell.spawn(svn, "info", "--xml", stdout=True)) try: url = info.getElementsByTagName("url")[0] text = [] for node in url.childNodes: if node.nodeType == node.TEXT_NODE: text.append(node.data) finally: info.unlink() return ("".decode("ascii")).join(text).encode("utf-8")
def _repo_url(self): """ Determine URL """ from xml.dom import minidom svn = shell.frompath('svn') info = minidom.parseString( shell.spawn(svn, 'info', '--xml', stdout=True) ) try: url = info.getElementsByTagName('url')[0] text = [] for node in url.childNodes: if node.nodeType == node.TEXT_NODE: text.append(node.data) finally: info.unlink() return ''.join(text).encode('utf-8')
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read('package.cfg', **cfgread) strversion = parser.get('package', 'version.number') isdev = parser.getboolean('package', 'version.dev') revision = parser.getint('package', 'version.revision') version = strversion if isdev: version += '-dev-r%d' % (revision,) git = shell.frompath('git') shell.spawn( git, 'tag', '-a', '-m', 'Release version ' + version, '--', version, echo=True, )
def _tag_release(self): """ Tag release """ from _setup.util import SafeConfigParser as parser parser = parser() parser.read('package.cfg', **cfgread) strversion = parser.get('package', 'version.number') isdev = parser.getboolean('package', 'version.dev') revision = parser.getint('package', 'version.revision') version = strversion if isdev: version += '.dev%d' % (revision,) git = shell.frompath('git') shell.spawn( git, 'tag', '-a', '-m', 'Release version ' + version, '--', version, echo=True, )
def sphinx(**kwargs): """ Run sphinx """ prog = _shell.frompath('sphinx-build') if prog is None: _term.red("sphinx-build not found") return False env = dict(_os.environ) argv = [ prog, '-a', '-d', _os.path.join(kwargs['build'], 'doctrees'), '-b', 'html', kwargs['source'], kwargs['target'], ] return not _shell.spawn(*argv, **{'env': env})
def _check_committed(self): """ Check if everything is committed """ git = shell.frompath("git") lines = shell.spawn(git, "branch", "--color=never", stdout=True, env=dict(_os.environ, LC_ALL="C")).splitlines() for line in lines: if line.startswith("*"): branch = line.split(None, 1)[1] break else: make.fail("Could not determine current branch.") if branch != "master": rex = _re.compile(r"^\d+(?:\.\d+)*\.[xX]$").match match = rex(branch) if not match: make.fail("Not in master or release branch.") lines = shell.spawn(git, "status", "--porcelain", stdout=True, env=dict(_os.environ, LC_ALL="C")) if lines: make.fail("Uncommitted changes!")
def sphinx(**kwargs): """ Run sphinx """ prog = _shell.frompath("sphinx-build") if prog is None: _term.red("sphinx-build not found") return False env = dict(_os.environ) argv = [ prog, "-a", "-d", _os.path.join(kwargs["build"], "doctrees"), "-b", "html", kwargs["source"], kwargs["target"], ] return not _shell.spawn(*argv, **{"env": env})
def sign_external(self, filename, detach=True): """ Sign calling gpg """ gpg = _shell.frompath('gpg') if gpg is None: _make.warn('GPG not found -> cannot sign') return False if detach: _shell.spawn(gpg, '--armor', '--output', filename + '.asc', '--detach-sign', '--', filename, ) else: _shell.spawn(gpg, '--output', filename + '.signed', '--clearsign', '--', filename, ) _os.rename(filename + '.signed', filename) return True
def compress_external(self, infile, outfile, *argv): argv = list(argv) argv[0] = shell.frompath(argv[0]) if argv[0] is not None: return not shell.spawn(*argv, **{"filepipe": True, "stdin": infile, "stdout": outfile}) return None
def _update_versions(self): """ Update versions """ self.runner("revision", "version", seen={}) git = shell.frompath("git") shell.spawn(git, "commit", "-a", "-m", "Pre-release: version update", echo=True)
def epydoc(**kwargs): """ Run epydoc """ # pylint: disable = R0912 prog = kwargs.get('epydoc') or 'epydoc' if not _os.path.dirname(_os.path.normpath(prog)): prog = _shell.frompath(prog) if not prog: _term.red("%(epydoc)s not found", epydoc=kwargs.get('epydoc') or 'epydoc', ) return False version = _VERSION_SEARCH(_shell.spawn(prog, "--version", stdout=True)) if version is not None: try: version = tuple(map(int, version.group('major', 'minor'))) except (TypeError, ValueError): version = None if version is None: _term.red("%(prog)s version not recognized" % locals()) return False if version < (3, 0): _term.red("%(prog)s is too old %(version)r < (3, 0)" % locals()) return False env = dict(_os.environ) prepend = kwargs.get('prepend') if prepend: toprepend = _os.pathsep.join(map(str, prepend)) if 'PYTHONPATH' in env: env['PYTHONPATH'] = _os.pathsep.join(( toprepend, env['PYTHONPATH'] )) else: env['PYTHONPATH'] = toprepend append = kwargs.get('append') if append: toappend = _os.pathsep.join(map(str, append)) if 'PYTHONPATH' in env: env['PYTHONPATH'] = _os.pathsep.join(( env['PYTHONPATH'], toappend )) else: env['PYTHONPATH'] = toappend moreenv = kwargs.get('env') if moreenv: env.update(moreenv) config = kwargs.get('config') or _shell.native('docs/epydoc.conf') argv = [prog, '--config', config] res = not _shell.spawn(*argv, **{'env': env}) if res: cfg = _util.SafeConfigParser() cfg.read(config) try: target = dict(cfg.items('epydoc'))['target'] except KeyError: pass else: _cleanup_epydoc(target) return res