def run (self): old_data.run(self) util.mkdir(self.data_install_dir) if (not hasattr(self.distribution, 'using_py2exe') or \ not self.distribution.using_py2exe) and self.data_dirs: for tpl in self.data_dirs: target = os.path.join(self.data_install_dir, tpl[0]) for d in tpl[1]: util.copy_tree(d, target, excludes=['.svn*', 'CVS*', 'Makefile*'])
def run(self): failed = False if self.distribution.subpackages != None: for idx in range(len(sys.argv)): if 'setup.py' in sys.argv[idx]: break argv = list(sys.argv[idx+1:]) build = self.get_finalized_command('build') failed = process_subpackages(build.distribution.parallel_build, 'test', build.build_base, self.distribution.subpackages, argv, False) ## PYTHON if self._has_python_tests(): self.run_command('build') build = self.get_finalized_command('build') build_dir = build.build_base environ = self.distribution.environment pkg_dirs = [build_dir, build.build_lib, os.path.join(build_dir, 'python')] lib_dirs = [build.build_temp] try: lib_dirs += environ['PATH'] # FIXME need boost, etc dlls for windows except: pass try: lib_dirs.append(os.path.join(environ['MINGW_DIR'], 'bin')) lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'bin')) lib_dirs.append(os.path.join(environ['MSYS_DIR'], 'lib')) except: pass postfix = '.'.join(build.build_temp.split('.')[1:]) for pkg, units in self._get_python_tests(): test_dir = os.path.join(build_dir, 'test_' + pkg) if not os.path.exists(test_dir): util.copy_tree('test', test_dir, excludes=['.svn*', 'CVS*']) f = open(os.path.join(test_dir, '__init__.py'), 'w') f.write("__all__ = ['" + "', '".join(units) + "']\n") f.close() outfile = os.path.join(build_dir, 'test_' + pkg + '.py') util.create_testscript('test_' + pkg, units, outfile, pkg_dirs) wrap = util.create_test_wrapper(outfile, build_dir, lib_dirs) log.info('Python unit tests for ' + pkg) try: util.check_call([wrap]) except Exception, e: failed = True print e
def run(self): if not self.distribution.doc_modules: return ## Make sure that sources are complete in build_lib. self.run_command('build_src') ## Ditto extensions self.run_command('build_ext') build = self.get_finalized_command('build') buildpy = self.get_finalized_command('build_py') target = os.path.abspath(os.path.join(build.build_base, 'http')) util.mkdir(target) build_verbose = self.distribution.verbose environ = self.distribution.environment for dext in self.distribution.doc_modules: if self.distribution.verbose: print 'building documentation "' + dext.name + '" sources' doc_dir = os.path.abspath(dext.source_directory) extra_dirs = dext.extra_directories working_dir = os.path.abspath(os.path.join(self.build_temp, dext.source_directory)) here = os.getcwd() reprocess = True ref = os.path.join(target, dext.name + '.html') root_dir = dext.name if os.path.exists(ref) and not self.force: reprocess = False docbase = os.path.join(doc_dir, 'modules') for root, dirnames, filenames in os.walk(docbase): for fn in fnmatch.filter(filenames, '*.rst'): doc = os.path.join(root, fn) if os.path.getmtime(ref) < os.path.getmtime(doc): reprocess = True break src = os.path.join(root_dir, root[len(docbase)+1:], fn[:-3] + 'py') if os.path.exists(src): if os.path.getmtime(ref) < os.path.getmtime(src): reprocess = True break if reprocess: src_dirs = [] for package in buildpy.packages: # Locate package source directory src_dirs.append(os.path.abspath(buildpy.get_package_dir(package))) #FIXME rst files in package sources (mutiple packages) #src_dir = src_dirs[0] src_dir = os.path.abspath('.') bld_dir = os.path.abspath(self.build_lib) doc_bld_dir = os.path.join(bld_dir, os.path.relpath(doc_dir, src_dir)) environ['BUILD_DIR'] = bld_dir environ['SOURCE_DIR'] = src_dir environ['RELATIVE_SOURCE_DIR'] = os.path.relpath(src_dir, doc_bld_dir) util.copy_tree(doc_dir, working_dir, True, excludes=['.svn', 'CVS', '.git', '.hg*']) for d in extra_dirs: subdir = os.path.basename(os.path.normpath(d)) util.copy_tree(d, os.path.join(target, subdir), True, excludes=['.svn', 'CVS', '.git', '.hg*']) ## Configure rst files util.configure_files(environ, src_dir, '*.rst', working_dir) if os.path.exists(os.path.join(doc_dir, dext.doxygen_cfg)): ## Doxygen + breathe 'Config ' + os.path.join(doc_dir, dext.doxygen_cfg) util.configure_file(environ, os.path.join(doc_dir, dext.doxygen_cfg), os.path.join(working_dir, dext.doxygen_cfg), style=dext.style) for s in dext.doxygen_srcs: util.configure_file(environ, os.path.join(doc_dir, s), os.path.join(working_dir, s), style=dext.style) try: doxygen_exe = util.find_program('doxygen') except: sys.stderr.write('ERROR: Doxygen not installed ' + '(required for documentation).\n') return reprocess = True ref = os.path.join(working_dir, 'html', 'index.html') if os.path.exists(ref) and not self.force: reprocess = False for d in environ['C_SOURCE_DIRS'].split(' '): for orig in glob.glob(os.path.join(d, '*.h*')): if os.path.getmtime(ref) < \ os.path.getmtime(orig): reprocess = True break if reprocess: if self.distribution.verbose: out = sys.stdout err = sys.stderr else: out = err = open('doxygen.log', 'w') os.chdir(working_dir) cmd_line = [doxygen_exe, dext.doxygen_cfg] status = subprocess.call(cmd_line, stdout=out, stderr=err) if status != 0: raise Exception("Command '" + str(cmd_line) + "' returned non-zero exit status " + str(status)) if not self.distribution.verbose: out.close() util.copy_tree('html', os.path.join(target, 'html'), True, excludes=['.svn', 'CVS', '.git', '.hg*']) os.chdir(here) create_breathe_stylesheet(target) for f in dext.extra_docs: shutil.copy(os.path.join(doc_dir, f), target) ## Sphinx if dext.without_sphinx: return if dext.sphinx_config is None: dext.sphinx_config = os.path.join(os.path.dirname(__file__), 'sphinx_conf.py.in') elif os.path.dirname(dext.sphinx_config) == '': dext.sphinx_config = os.path.join(doc_dir, dext.sphinx_config) util.configure_file(environ, dext.sphinx_config, os.path.join(working_dir, 'conf.py')) import warnings try: import sphinx from sphinx.application import Sphinx if 'windows' in platform.system().lower() or \ not build_verbose: from sphinx.util.console import nocolor except: sys.stderr.write('ERROR: Sphinx not installed ' + '(required for documentation).\n') return warnings.filterwarnings("ignore", category=PendingDeprecationWarning) warnings.filterwarnings("ignore", category=UserWarning) status = sys.stdout if not build_verbose: status = open('sphinx.log', 'w') if 'windows' in platform.system().lower() or not build_verbose: nocolor() try: sphinx_app = Sphinx(working_dir, working_dir, target, os.path.join(target, '.doctrees'), 'html', None, status) sphinx_app.build(True) except Exception, e: if build_verbose: print 'ERROR: ' + str(e) else: pass if not build_verbose: status.close() warnings.resetwarnings()
def iterate_assets( cache, settings, asset_folders, tools, platform ): # loop through each asset path and glob # run the tool associated with each file logging.info("Running tools on assets...") total_files = 0 modified_files = 0 for asset in asset_folders: try: search_path = os.path.join( asset.abs_src_folder, asset.glob ) #logging.info("Processing: \"%s\"" % search_path) if tools.has_key(asset.tool): tool = tools[asset.tool] else: raise UnknownToolException( "Unknown tool \"%s\"" % asset.tool ) path_created = False for root, subs, files in os.walk(asset.abs_src_folder, topdown=True): # filter files based on glob files[:] = fnmatch.filter(files, asset.glob) if not path_created: # make all asset destination folders make_dirs(asset.abs_dst_folder) path_created = True # filter subdirectories based on the glob matched_subs = fnmatch.filter(subs, asset.glob) # do not recurse into subdirectories subs[:] = [] if matched_subs: # One or more subdirectories matched the glob. # For now, copy each match over to the destination folder. # This is to specifically handle the case where directories are entire # folders (.dSYM, .app). These specific dirs should be # exceptions where the entire folder is simply copied. for folder in matched_subs: copy_tree(source_file_root, dst_file_root) for file in files: src_file_path = os.path.join(root, file) total_files += 1 if not cache.update(src_file_path): continue modified_files += 1 execute_commands( tools, tool, settings.paths, asset, src_file_path, platform ) except UnknownToolException as e: logging.warn(e.message) continue logging.info("Complete.") logging.info("Modified / Total - %i/%i" % (modified_files, total_files))
def process_events(self): queued_items = self.queue[:] self.queue = [] for target_path in queued_items: for asset in asset_folders: match = re.search(asset.get_abs_regex(), target_path) if match: # determine if this is a directory path # a file in a subdirectory source_to_target_path = os.path.relpath(target_path, self.settings.paths.source_root) asset_target_relative = os.path.relpath(source_to_target_path, asset.src_folder) subdir = os.path.sep in asset_target_relative is_directory = os.path.isdir(target_path) or subdir if is_directory: # We don't want to perform tree copies for modified files # inside of a subfolder; only do that on the root subfolder. if not subdir: source_path = target_path destination_path = os.path.join(settings.paths.destination_root, asset.dst_folder, asset_target_relative) copy_tree(source_path, destination_path) break try: # try to update the cache if not self.cache.update(target_path): break if self.tools.has_key(asset.tool): tool = tools[asset.tool] else: raise UnknownToolException( "Unknown tool \"%s\"" % asset.tool ) outputs = execute_commands( self.tools, tool, self.settings.paths, asset, target_path, self.platform ) # get the relative asset path from the source_root # to the asset being modified. relative_path = os.path.relpath(outputs[0], settings.paths.destination_root) if self.send_reload_requests: request_packet = { "type": "file_modified", "resource": relative_path } post = 80 host, uri = self.server_url.split("/") if ":" in host: host, port = host.split(":") port = int(port) try: connection = httplib.HTTPConnection(host, port) connection.request("PUT", ("/" + uri), json.dumps(request_packet)) response = connection.getresponse() if response.status != 204 and response.status != 200: logging.warn("Request failed: (%i) %s" % (response.status, response.reason)) except socket.error as exception: pass except: raise break except: raise
def run(self): if not self.web_ext_modules: return ## Make sure that extension sources are complete. self.run_command('build_src') build = self.get_finalized_command('build') environ = self.distribution.environment import pyjs ## TODO: use pyjs module directly (instead of 'pyjsbuild') for wext in self.web_ext_modules: if self.distribution.verbose: print 'building web extension "' + \ os.path.join(wext.public_subdir, wext.name) + '" sources' target = os.path.abspath(os.path.join(build.build_base, 'http', wext.public_subdir)) util.mkdir(target) here = os.getcwd() src_dir = os.path.abspath(wext.source_directory) working_dir = os.path.abspath(os.path.join(build.build_temp, 'web', wext.name)) util.mkdir(working_dir) for support in wext.extra_support_files: src_file = util.sysdevel_support_path(support + '.in') if not os.path.exists(src_file): src_file = src_file[:-3] dst_file = os.path.join(working_dir, support) util.configure_file(environ, src_file, dst_file) reprocess = True ref = os.path.join(target, wext.name + '.html') if os.path.exists(ref) and not self.force: reprocess = False for src in wext.sources: if os.path.getmtime(ref) < os.path.getmtime(src): reprocess = True if reprocess: for s in wext.sources: util.configure_file(environ, s, os.path.join(working_dir, os.path.basename(s))) ## Specifying public-folder is broken (see below) util.copy_tree(os.path.join(src_dir, 'public'), os.path.join(working_dir, 'public'), update=True, verbose=self.distribution.verbose, excludes=['.svn', 'CVS']) compiler = wext.compiler or \ environ['PYJSBUILD'] or self.pyjscompiler if compiler is None: raise DistutilsExecError, \ "no value pyjsbuild executable found or given" cmd_line = [os.path.abspath(compiler)] for arg in wext.extra_compile_args: if 'debug' in arg.lower(): cmd_line.append('--debug') cmd_line.append('--print-statements') else: cmd_line.append(arg) if self.distribution.verbose: cmd_line.append('--log-level=' + str(logging.INFO)) else: cmd_line.append('--log-level=' + str(logging.ERROR)) cmd_line.append('--output=' + target) ## RuntimeError: File not found '_pyjs.js' (bypassed above) #cmd_line.append('--public-folder=' + # os.path.join(src_dir, 'public')) cmd_line.append(wext.name) os.chdir(working_dir) status = subprocess.call(cmd_line) if status != 0: raise Exception("Command '" + str(cmd_line) + "' returned non-zero exit status " + str(status)) os.chdir(here) for filename in wext.extra_public_files: filepath = util.sysdevel_support_path(filename + '.in') if not os.path.exists(filepath): filepath = filepath[:-3] targetfile = os.path.join(target, filename) if not os.path.exists(targetfile): util.configure_file(environ, filepath, targetfile) js_dir = os.path.join(build.build_base, util.javascript_dir) if os.path.exists(js_dir): util.copy_tree(js_dir, os.path.join(target, util.javascript_dir)) if not os.path.lexists(os.path.join(target, 'index.html')): shutil.copyfile(os.path.join(target, wext.name + '.html'), os.path.join(target, 'index.html'))