def clean(self, scm, dist): term.green("Removing bytecode files...") for filename in shell.dirs('.', '__pycache__'): shell.rm_rf(filename) for filename in shell.files('.', '*.py[co]'): shell.rm(filename) for filename in shell.files('.', '*$py.class'): shell.rm(filename)
def clean(self, scm, dist): term.green("Removing python byte code...") for name in shell.dirs('.', '__pycache__'): shell.rm_rf(name) for name in shell.files('.', '*.py[co]'): shell.rm(name) term.green("Removing c extensions...") for name in shell.files('.', '*.so'): shell.rm(name) for name in shell.files('.', '*.pyd'): shell.rm(name) shell.rm_rf(self.dirs['build'])
def clean(self, scm, dist): term.green("Removing python byte code...") for name in shell.dirs('.', '__pycache__'): shell.rm_rf(name) for name in shell.files('.', '*.py[co]'): shell.rm(name) for name in shell.files('.', '*$py.class'): shell.rm(name) term.green("Removing c extensions...") for name in shell.files('.', '*.so'): shell.rm(name) for name in shell.files('.', '*.pyd'): shell.rm(name) shell.rm_rf(self.dirs['build'])
def run(self): import setup _old_argv = _sys.argv try: _sys.argv = ['setup.py', '-q', 'build'] if not self.HIDDEN: _sys.argv.remove('-q') setup.setup() if 'java' not in _sys.platform.lower(): _sys.argv = [ 'setup.py', '-q', 'install_lib', '--install-dir', shell.native(self.dirs['lib']), '--optimize', '2', ] if not self.HIDDEN: _sys.argv.remove('-q') setup.setup() finally: _sys.argv = _old_argv for name in shell.files("%s/gensaschema" % self.dirs['lib'], '*.py'): self.compile(name) term.write("%(ERASE)s") term.green("All files successfully compiled.")
def digest_files(self, exts): """ digest files """ digests = {} digestnames = {} for ext in exts: for name in _shell.files(self._dist, '*' + ext, False): basename = _os.path.basename(name) if basename not in digests: digests[basename] = [] digests[basename].extend(self.digest(name)) digestname = basename[:-len(ext)] if digestname not in digestnames: digestnames[digestname] = [] digestnames[digestname].append(basename) result = [] for name, basenames in digestnames.items(): result.append(_os.path.join(self._dist, name + '.digests')) fp = open(result[-1], 'wb') try: fp.write( b'\n# The file may contain MD5, SHA1 and SHA256 digests\n') fp.write(b'# Check archive integrity with, e.g. md5sum -c\n') fp.write(b'# Check digest file integrity with PGP\n\n') basenames.sort() for basename in basenames: for digest in digests[basename]: fp.write( ("%s *%s\n" % (digest, basename)).encode('utf-8')) finally: fp.close() return result
def _cleanup_epydoc(target): """ Cleanup epydoc generated files This removes the epydoc-footer. It changes every release because of the timestamp. That creates bad diffs (accidently it's also invalid html). """ search = _re.compile(r'<table[^<>]+width="100%%"').search for filename in _shell.files(target, '*.html'): fp = open(filename, 'r') try: html = fp.read() finally: fp.close() match = search(html) if match: start = match.start() end = html.find('</table>', start) if end >= 0: end += len('</table>') + 1 html = html[:start] + html[end:] fp = open(filename, 'w') try: fp.write(html) finally: fp.close()
def clean(self, scm, dist): term.green("Removing python byte code...") for name in shell.dirs(".", "__pycache__"): shell.rm_rf(name) for name in shell.files(".", "*.py[co]"): shell.rm(name) for name in shell.files(".", "*$py.class"): shell.rm(name) term.green("Removing c extensions...") for name in shell.files(".", "*.so"): shell.rm(name) for name in shell.files(".", "*.pyd"): shell.rm(name) shell.rm_rf(self.dirs["build"])
def run(self): import setup _old_argv = _sys.argv try: _sys.argv = ["setup.py", "-q", "build"] if not self.HIDDEN: _sys.argv.remove("-q") setup.setup() if "java" not in _sys.platform.lower(): _sys.argv = [ "setup.py", "-q", "install_lib", "--install-dir", shell.native(self.dirs["lib"]), "--optimize", "2", ] if not self.HIDDEN: _sys.argv.remove("-q") setup.setup() finally: _sys.argv = _old_argv for name in shell.files("%s/tdi" % self.dirs["lib"], "*.py"): self.compile(name) term.write("%(ERASE)s") term.green("All files successfully compiled.")
def run(self): import setup _old_argv = _sys.argv try: _sys.argv = ['setup.py', '-q', 'build'] if not self.HIDDEN: _sys.argv.remove('-q') setup.setup() if 'java' not in _sys.platform.lower(): _sys.argv = [ 'setup.py', '-q', 'install_lib', '--install-dir', shell.native(self.dirs['lib']), '--optimize', '2', ] if not self.HIDDEN: _sys.argv.remove('-q') setup.setup() finally: _sys.argv = _old_argv for name in shell.files("%s/wtf" % self.dirs['lib'], '*.py'): self.compile(name) term.write("%(ERASE)s") term.green("All files successfully compiled.")
def digest_files(self, exts): """ digest files """ digests = {} digestnames = {} for ext in exts: for name in shell.files(self.dirs["dist"], "*" + ext, False): basename = _os.path.basename(name) if basename not in digests: digests[basename] = [] digests[basename].extend(self.digest(name)) digestname = basename[: -len(ext)] if digestname not in digestnames: digestnames[digestname] = [] digestnames[digestname].append(basename) result = [] for name, basenames in digestnames.items(): result.append(_os.path.join(self.dirs["dist"], name + ".digests")) fp = textopen(result[-1], "wb") try: fp.write("\n# The file may contain MD5, SHA1 and SHA256 digests\n") fp.write("# Check archive integrity with, e.g. md5sum -c\n") fp.write("# Check digest file integrity with PGP\n\n") basenames.sort() for basename in basenames: for digest in digests[basename]: fp.write("%s *%s\n" % (digest, basename)) finally: fp.close() return result
def digest_files(self, exts): """ digest files """ digests = {} digestnames = {} for ext in exts: for name in _shell.files(self._dist, '*' + ext, False): basename = _os.path.basename(name) if basename not in digests: digests[basename] = [] digests[basename].extend(self.digest(name)) digestname = basename[:-len(ext)] if digestname not in digestnames: digestnames[digestname] = [] digestnames[digestname].append(basename) result = [] for name, basenames in digestnames.items(): result.append(_os.path.join(self._dist, name + '.digests')) fp = open(result[-1], 'wb') try: fp.write( b'\n# The file may contain MD5, SHA1 and SHA256 digests\n' ) fp.write(b'# Check archive integrity with, e.g. md5sum -c\n') fp.write(b'# Check digest file integrity with PGP\n\n') basenames.sort() for basename in basenames: for digest in digests[basename]: fp.write(( "%s *%s\n" % (digest, basename)).encode('utf-8') ) finally: fp.close() return result
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 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 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 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 clean(self, scm, dist): """ Clean versioned files """ if scm: term.green("Removing generated ebuild files") for name in shell.files(self.dirs['ebuild'], '*.ebuild'): shell.rm(name)
def copy_ebuilds(self): for src in shell.files(self.dirs["ebuild"], "*.ebuild"): shell.cp(src, self.dirs["dist"])
def run(self): from _setup.util import SafeConfigParser as parser parser = parser() parser.read("package.cfg", **cfgread) strversion = parser.get("package", "version.number") shortversion = tuple(map(int, strversion.split(".")[:2])) shell.rm_rf(self.dirs["_website"]) shell.cp_r(self.dirs["userdoc_source"], _os.path.join(self.dirs["_website"], "src")) for filename in shell.files(_os.path.join(self.dirs["_website"], "src"), "*.txt"): fp = textopen(filename, "r") try: content = fp.read().replace("../examples/", "examples/") finally: fp.close() fp = textopen(filename, "w") try: fp.write(content) finally: fp.close() shell.cp_r(self.dirs["examples"], _os.path.join(self.dirs["_website"], "src", "examples")) shell.rm_rf(_os.path.join(self.dirs["_website"], "build")) shell.rm_rf(self.dirs["website"]) _os.makedirs(self.dirs["website"]) filename = _os.path.join(self.dirs["_website"], "src", "website_download.txt") fp = textopen(filename) try: download = fp.read() finally: fp.close() filename = _os.path.join(self.dirs["_website"], "src", "index.txt") fp = textopen(filename) try: indexlines = fp.readlines() finally: fp.close() fp = textopen(filename, "w") try: for line in indexlines: if line.startswith(".. placeholder: Download"): line = download fp.write(line) finally: fp.close() shell.cp_r(self.dirs["examples"], _os.path.join(self.dirs["website"], "examples")) for top, dirs, _ in shell.walk(_os.path.join(self.dirs["website"], "examples")): if ".svn" in dirs: dirs.remove(".svn") shell.rm_rf(_os.path.join(top, ".svn")) if ".git" in dirs: dirs.remove(".git") shell.rm_rf(_os.path.join(top, ".git")) shell.cp_r(self.dirs["apidoc"], _os.path.join(self.dirs["website"], "doc-%d.%d" % shortversion)) shell.cp_r(self.dirs["apidoc"], _os.path.join(self.dirs["_website"], "src", "doc-%d.%d" % shortversion)) fp = textopen(_os.path.join(self.dirs["_website"], "src", "conf.py"), "a") try: fp.write( "\nepydoc = dict(tdi=%r)\n" % (_os.path.join(shell.native(self.dirs["_website"]), "src", "doc-%d.%d" % shortversion),) ) fp.write("\nexclude_trees.append(%r)\n" % "doc-%d.%d" % shortversion) fp.write("\nexclude_trees.append('examples')\n") finally: fp.close() from _setup.dev import userdoc userdoc.sphinx( build=shell.native(_os.path.join(self.dirs["_website"], "build")), source=shell.native(_os.path.join(self.dirs["_website"], "src")), target=shell.native(self.dirs["website"]), ) shell.rm(_os.path.join(self.dirs["website"], ".buildinfo")) fp = open(_os.path.join(self.dirs["website"], "examples", ".htaccess"), "wb") try: fp.write("Options -Indexes\n") fp.write("<Files *.py>\n") fp.write("ForceType text/plain\n") fp.write("</Files>\n") fp.write("<Files *.out>\n") fp.write("ForceType text/plain\n") fp.write("</Files>\n") finally: fp.close()
def make_manifest(manifest, config, docs, kwargs): """ Create file list to pack up """ # pylint: disable = R0912 kwargs = kwargs.copy() kwargs['script_args'] = ['install'] kwargs['packages'] = list(kwargs.get('packages') or ()) + [ '_setup', '_setup.py2', '_setup.py3', ] + list(manifest.get('packages.extra', '').split() or ()) _core._setup_stop_after = "commandline" try: dist = _core.setup(**kwargs) finally: _core._setup_stop_after = None result = ['MANIFEST', 'PKG-INFO', 'setup.py'] + list(config) # TODO: work with default values: for key in ('classifiers', 'description', 'summary', 'provides', 'license'): filename = docs.get('meta.' + key, '').strip() if filename and _os.path.isfile(filename): result.append(filename) cmd = dist.get_command_obj("build_py") cmd.ensure_finalized() #from pprint import pprint; pprint(("build_py", cmd.get_source_files())) for item in cmd.get_source_files(): result.append(_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) )) cmd = dist.get_command_obj("build_ext") cmd.ensure_finalized() #from pprint import pprint; pprint(("build_ext", cmd.get_source_files())) for item in cmd.get_source_files(): result.append(_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) )) for ext in cmd.extensions: if ext.depends: result.extend([_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) ) for item in ext.depends]) cmd = dist.get_command_obj("build_clib") cmd.ensure_finalized() if cmd.libraries: #import pprint; pprint.pprint(("build_clib", cmd.get_source_files())) for item in cmd.get_source_files(): result.append(_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) )) for lib in cmd.libraries: if lib[1].get('depends'): result.extend([_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) ) for item in lib[1]['depends']]) cmd = dist.get_command_obj("build_scripts") cmd.ensure_finalized() #import pprint; pprint.pprint(("build_scripts", cmd.get_source_files())) if cmd.get_source_files(): for item in cmd.get_source_files(): result.append(_posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep) )) cmd = dist.get_command_obj("install_data") cmd.ensure_finalized() #from pprint import pprint; pprint(("install_data", cmd.get_inputs())) try: strings = str except NameError: strings = (str, str) for item in cmd.get_inputs(): if isinstance(item, strings): result.append(item) else: result.extend(item[1]) for item in manifest.get('dist', '').split(): result.append(item) if _os.path.isdir(item): for filename in _shell.files(item): result.append(filename) result = list(dict([(item, None) for item in result]).keys()) result.sort() return result
def copy_ebuilds(self): if self._ebuilds is not None: for src in _shell.files(self._ebuilds, '*.ebuild'): _shell.cp(src, self._dist)
def make_manifest(manifest, config, docs, kwargs): """ Create file list to pack up """ # pylint: disable = R0912 kwargs = kwargs.copy() kwargs['script_args'] = ['install'] kwargs['packages'] = list(kwargs.get('packages') or ()) + [ '_setup', '_setup.py2', '_setup.py3', ] + list(manifest.get('packages.extra', '').split() or ()) _core._setup_stop_after = "commandline" try: dist = _core.setup(**kwargs) finally: _core._setup_stop_after = None result = ['MANIFEST', 'PKG-INFO', 'setup.py'] + list(config) # TODO: work with default values: for key in ('classifiers', 'description', 'summary', 'provides', 'license'): filename = docs.get('meta.' + key, '').strip() if filename and _os.path.isfile(filename): result.append(filename) cmd = dist.get_command_obj("build_py") cmd.ensure_finalized() #from pprint import pprint; pprint(("build_py", cmd.get_source_files())) for item in cmd.get_source_files(): result.append( _posixpath.sep.join(_os.path.normpath(item).split(_os.path.sep))) cmd = dist.get_command_obj("build_ext") cmd.ensure_finalized() #from pprint import pprint; pprint(("build_ext", cmd.get_source_files())) for item in cmd.get_source_files(): result.append( _posixpath.sep.join(_os.path.normpath(item).split(_os.path.sep))) for ext in cmd.extensions: if ext.depends: result.extend([ _posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep)) for item in ext.depends ]) cmd = dist.get_command_obj("build_clib") cmd.ensure_finalized() if cmd.libraries: #import pprint; pprint.pprint(("build_clib", cmd.get_source_files())) for item in cmd.get_source_files(): result.append( _posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep))) for lib in cmd.libraries: if lib[1].get('depends'): result.extend([ _posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep)) for item in lib[1]['depends'] ]) cmd = dist.get_command_obj("build_scripts") cmd.ensure_finalized() #import pprint; pprint.pprint(("build_scripts", cmd.get_source_files())) if cmd.get_source_files(): for item in cmd.get_source_files(): result.append( _posixpath.sep.join( _os.path.normpath(item).split(_os.path.sep))) cmd = dist.get_command_obj("install_data") cmd.ensure_finalized() #from pprint import pprint; pprint(("install_data", cmd.get_inputs())) try: strings = basestring except NameError: strings = (str, unicode) for item in cmd.get_inputs(): if isinstance(item, strings): result.append(item) else: result.extend(item[1]) for item in manifest.get('dist', '').split(): result.append(item) if _os.path.isdir(item): for filename in _shell.files(item): result.append(filename) result = dict([(item, None) for item in result]).keys() result.sort() return result