def main(self, *args, **kwargs): """execute the fabricate.main function with default kwargs as given to __init__ and globals_dict=self.to_dict() """ kwargs['globals_dict'] = kwargs.pop('globals_dict', self.to_dict()) for name in self._main_kwargs: kwargs[name] = kwargs.pop(name, self._main_kwargs[name]) # --- intercept any exit atexit functions exithandlers = [] def atexit_register(func, *targs, **kargs): exithandlers.append((func, targs, kargs)) return func def run_exitfuncs(): exc_info = None while exithandlers: func, targs, kargs = exithandlers.pop() try: func(*targs, **kargs) except SystemExit: exc_info = sys.exc_info() except: import traceback print >> sys.stderr, "Error in mock_env.run_exitfuncs:" traceback.print_exc() exc_info = sys.exc_info() if exc_info is not None: raise (exc_info[0], exc_info[1], exc_info[2]) monkeypatch = MonkeyPatch() monkeypatch.setattr(atexit, 'register', atexit_register) try: fabricate.main(*args, **kwargs) run_exitfuncs() finally: monkeypatch.undo()
def namecoindns_run(): env = os.environ env['NAMECOIN_USERNAME'] = '******' env['NAMECOIN_PASSWORD'] = '******' env['NAMECOIN_HOSTNAME'] = 'localhost.localdomain' shell('docker', 'run', '-d', '-t', '-p', '53053:53', '-p', '53053:53/udp', 'pjz/namecoin-dns', silent=False, env=env) def tahoe_images(): run('docker', 'build', '-t', 'pjzz/tahoe-lafs-introducer', '.', cwd=_docker_dir('tahoe-lafs-introducer'), silent=False) run('docker', 'build', '-t', 'pjzz/tahoe-lafs-storage', '.', cwd=_docker_dir('tahoe-lafs-storage'), silent=False) def clean(): namecoindns_clean() autoclean() def show_targets(): print("""Valid targets: all - build all images base_image - build the base (debian) image namecoindns_image - build the namecoin DNS image namecoindns_run - run the namecoin DNS image tahoe_images - build the tahoe introducer and storage images """) sys.exit() main( default='show_targets', runner='always_runner' )
yield finally: os.chdir(curdir) # actual build process def build(): run('mkdir', BUILDDIR) for d in [ 'css', 'fonts', 'images', 'js', 'sass' ]: run('cp', '-r', os.path.join(UIKIT, d), BUILDDIR) run('cp', '-r', 'www/*', BUILDDIR, shell=True) def publish(): build() shell('s3cmd', 'sync', BUILDDIR + '/', S3_BUCKET) def clean(): autoclean() shell('rm','-rf', BUILDDIR) def show_targets(): print("""Valid targets: show_targets - this build - build into """ + BUILDDIR + """ publish - publish up to S3, building if necessary clean - clean out """ + BUILDDIR + """ """) main()
#!/usr/bin/env python if __name__ == '__main__': import sys sys.path.append('../../') import fabricate default = 'myfab' def myfab(): fabricate.run('touch', 'testfile') def clean(): fabricate.autoclean() if len(sys.argv) > 1: default = sys.argv[1] fabricate.main(command_line=[default])
shell('rm', '-rf', 'jython-testresults.xml') def show_targets(): print("""Valid targets: show_targets (default) - this build - build an aspen egg aspen - set up a test aspen environment in env/ dev - set up an environment able to run tests in env/ docs - run the doc server smoke - run a smoke test test - run the unit tests analyse - run the unit tests with code coverage enabled pylint - run pylint on the source clean - remove all build artifacts clean_{env,jenv,smoke,test,jtest} - clean some build artifacts jython_test - install jython and run unit tests with code coverage. (requires java) """) sys.exit() extra_options = [ make_option('--python', action="store", dest="python", default="python"), ] main( extra_options=extra_options , default='show_targets' , ignoreprefix="python" # workaround for gh190 )
show_targets (default) - this build_""" + ',\n build_'.join(PLUGINS) + """ - build individual plugin build - build all the plugins release_""" + ',\n release_'.join(PLUGINS) + """ - release individual plugin release - release all plugins dev - make a dev environment in the 'env' directory test - build a test environment and run unit tests clean - remove all build artifacts clean_{build,dev} - clean some build artifacts """) sys.exit() extra_options = [ make_option('--python', action="store", dest="python", default="python"), ] # make a target for each plugin PLUGIN_TARGS = dict([ ("build_" + plugin, _mkbuild(plugin)) for plugin in PLUGINS ]) PLUGIN_TARGS.update(dict([ ("release_" + plugin, _mkrelease(plugin)) for plugin in PLUGINS ])) # add all existing targets locals().update(PLUGIN_TARGS) main(extra_options=extra_options, default='show_targets')
raise ValueError('in %s: target %s could not be resolved' % (path + '/' + 'module', module.path + ':' + rulename)) # TODO: detect and abort on circular dependencies for dep in rule.deps: deptargets = eval_target(dep, root, path, modules, queue) rule.deprules[dep] = deptargets rule.execute() return [rule] def module_relative_path(buildroot, path): relpath = os.path.relpath(os.getcwd() + '/', buildroot) if relpath == ".": return None return "/" + relpath if __name__=="__main__": parser = argparse.ArgumentParser() # todo: add 'run' command to rules where applicable #parser.add_argument('command', nargs=1, choices=['build','run']) parser.add_argument('target', nargs='+') (options, args) = parser.parse_known_args() build.targets = options.target build.root = find_buildroot() if build.root is None: raise AssertionError("Could not locate the buildroot") build.relpath = module_relative_path(build.root, os.getcwd()) os.chdir(build.root) fabricate.main(default="build", build_dir=os.getcwd(), command_line=args)
targets = ['show_targets', None, 'env', 'deps', 'dev', 'testf', 'test', 'pylint', 'test_cov', 'analyse', None, 'build', 'wheel', None, 'docserve', 'sphinx', 'autosphinx', None, 'clean', 'clean_env', 'clean_test', 'clean_build', 'clean_sphinx', None, 'jython_test', None, 'clean_jenv', 'clean_jtest', None, ] #docs = '\n'.join([" %s - %s" % (t, LOCALS[t].__doc__) for t in targets]) #print(docs) for t in targets: if t is not None: print(" %s - %s" % (t, LOCALS[t].__doc__)) else: print("") if len(targets) < (len(LOCALS) - len(NON_TARGETS)): missed = set(LOCALS.keys()).difference(NON_TARGETS, targets) print("Unordered targets: " + ', '.join(sorted(missed))) sys.exit() LOCALS = dict(locals()) NON_TARGETS = [ 'main', 'autoclean', 'run', 'shell' ] NON_TARGETS += list(x for x in LOCALS if x.startswith('_') or not callable(LOCALS[x] )) main( default='show_targets' , ignoreprefix="python" # workaround for gh190 )
def main(): fabricate.main()
for includeDir in cfg.includeDirs ]) def run(): cfg = getConfig(fabricate_helpers.getCurrentBuildConfigurationName()) print("run") import platform if platform.system() == 'Linux': url = "http://localhost:8080" + os.path.splitdrive( os.getcwd())[1].replace("\\", "/") + "/" + cfg.htmlSrcFile.replace( "_src.html", ".html") fabricate_helpers.directStartArgs("chromium", "--remote-debugging-port=9222", url) elif platform.system() == 'Windows' and platform.node().upper() == 'BYRNE': url = "http://localhost:8080" + os.path.splitdrive( os.getcwd())[1].replace("\\", "/") + "/" + cfg.htmlSrcFile.replace( "_src.html", ".html") fabricate_helpers.shellRunArgs("chrome", url) if platform.system() == 'Linux': os.chdir("/") fabricate_helpers.directRunArgs("http-server") elif platform.system() == 'Windows' and platform.node().upper() == 'BYRNE': os.chdir("/") #("E:/") fabricate_helpers.shellRunArgs("start", "http-server") fabricate.main(depsname=fabricate_helpers.depsFileName())
#!/usr/bin/env python if __name__ == '__main__': import sys sys.path.append('../../') import fabricate default='myfab' def myfab(): fabricate.run('touch', 'testfile') def clean(): fabricate.autoclean() if len(sys.argv) > 1: default=sys.argv[1] fabricate.main(command_line=[default])
show_targets (default) - this build_""" + ',\n build_'.join(PLUGINS) + """ - build individual plugin build - build all the plugins release_""" + ',\n release_'.join(PLUGINS) + """ - release individual plugin release - release all plugins dev - make a dev environment in the 'env' directory test - build a test environment and run unit tests clean - remove all build artifacts clean_{build,dev} - clean some build artifacts """) sys.exit() extra_options = [ make_option('--python', action="store", dest="python", default="python"), ] # make a target for each plugin PLUGIN_TARGS = dict([("build_" + plugin, _mkbuild(plugin)) for plugin in PLUGINS]) PLUGIN_TARGS.update( dict([("release_" + plugin, _mkrelease(plugin)) for plugin in PLUGINS])) # add all existing targets locals().update(PLUGIN_TARGS) main(extra_options=extra_options, default='show_targets')
shell('git', 'push', '--tags', silent=False) clean_build() print("Released!") def show_targets(): print("""Valid targets: show_targets (default) - this build - build an egg dev - set up an environment able to run tests in env/ test - run the unit tests pylint - run pylint on the source analyse - run the unit tests with code coverage enabled clean - remove all build artifacts clean_{dev,test} - clean some build artifacts release - requres --version and pypi upload rights """) sys.exit() extra_options = [ make_option('--python', action="store", dest="python", default="python"), make_option('--release', action="store", dest="release", default=None) ] main(extra_options=extra_options, default='show_targets', ignoreprefix="python")
shell('git', 'commit', 'setup.py', '-m', 'Bump to %s-dev' % rel, silent=False) shell('git', 'push', silent=False) shell('git', 'push', '--tags', silent=False) clean_build() print("Released!") def show_targets(): print("""Valid targets: show_targets (default) - this build - build an egg dev - set up an environment able to run tests in env/ test - run the unit tests pylint - run pylint on the source analyse - run the unit tests with code coverage enabled clean - remove all build artifacts clean_{dev,test} - clean some build artifacts release - requres --version and pypi upload rights """) sys.exit() extra_options = [ make_option('--python', action="store", dest="python", default="python") , make_option('--release', action="store", dest="release", default=None) ] main( extra_options=extra_options , default='show_targets' , ignoreprefix="python" )
""" test: env tests/env data ./env/Scripts/swaddle tests/env ./env/Scripts/nosetests ./tests/ tests: test tests/env: echo "Creating a tests/env file ..." echo echo "CANONICAL_HOST=" > tests/env echo "CANONICAL_SCHEME=http" >> tests/env echo "DATABASE_URL=postgres://gittip-test@localhost/gittip-test" >> tests/env echo "STRIPE_SECRET_API_KEY=1" >> tests/env echo "STRIPE_PUBLISHABLE_API_KEY=1" >> tests/env echo "BALANCED_API_SECRET=90bb3648ca0a11e1a977026ba7e239a9" >> tests/env echo "GITHUB_CLIENT_ID=3785a9ac30df99feeef5" >> tests/env echo "GITHUB_CLIENT_SECRET=e69825fafa163a0b0b6d2424c107a49333d46985" >> tests/env echo "GITHUB_CALLBACK=http://localhost:8537/on/github/associate" >> tests/env echo "TWITTER_CONSUMER_KEY=QBB9vEhxO4DFiieRF68zTA" >> tests/env echo "TWITTER_CONSUMER_SECRET=mUymh1hVMiQdMQbduQFYRi79EYYVeOZGrhj27H59H78" >> tests/env echo "TWITTER_CALLBACK=http://127.0.0.1:8537/on/twitter/associate" >> tests/env data: env ./makedb.sh gittip-test gittip-test ./env/Scripts/swaddle tests/env ./env/Scripts/python ./gittip/testing/__init__.py """ main(default='env')
autoclean() clean_build() clean_themes() clean_plugins() clean_pelican() def show_targets(): print("""Valid targets: pelican - install pelican into pelican-base/ themes - check out the themes repo and all submodules into themes/ plugins - check out the plugins repo and all submodules into plugins/ build - build all the ipsum sites into meta-out/ publish - sync from meta-out/ to the dest specified with -O clean_{pelican,themes,plugins,build} - remove individual build artifacts clean - remove all build artifacts """) sys.exit() output_option = optparse.make_option("-O", "--output", action="store", type="string", dest="DESTDIR", help="output directory") extra_options = [output_option] main(default='show_targets', extra_options=extra_options)
'clean_test', 'clean_build', 'clean_sphinx', None, ] #docs = '\n'.join([" %s - %s" % (t, LOCALS[t].__doc__) for t in targets]) #print(docs) for t in targets: if t is not None: print(" %s - %s" % (t, LOCALS[t].__doc__)) else: print("") if len(targets) < (len(LOCALS) - len(NON_TARGETS)): missed = set(LOCALS.keys()).difference(NON_TARGETS, targets) print("Unordered targets: " + ', '.join(sorted(missed))) sys.exit() LOCALS = dict(locals()) NON_TARGETS = ['main', 'autoclean', 'run', 'shell'] NON_TARGETS += list(x for x in LOCALS if x.startswith('_') or not callable(LOCALS[x])) if __name__ == '__main__': main( default='show_targets', ignoreprefix="python" # workaround for gh190 )
debug(lambda: "Cleaning index and blogs") shell("rm", "-rf", BUILD_DIR) def clean(): autoclean() clean_build() clean_themes() clean_plugins() clean_pelican() def show_targets(): print("""Valid targets: pelican - install pelican into pelican-base/ themes - check out the themes repo and all submodules into themes/ plugins - check out the plugins repo and all submodules into plugins/ build - build all the ipsum sites into meta-out/ publish - sync from meta-out/ to the dest specified with -O clean_{pelican,themes,plugins,build} - remove individual build artifacts clean - remove all build artifacts """) sys.exit() output_option = optparse.make_option("-O", "--output", action="store", type="string", dest="DESTDIR", help="output directory") extra_options = [ output_option ] main(default='show_targets', extra_options=extra_options)