def compileplugin(): print " - building UI files..." for source in ui_sources: pyuic = 'pyuic4' if iswindows: pyuic += '.bat' source = join(srcopyFilesath, source) run(pyuic, '-o', source + '.py', source + '.ui') print " - building resource files..." run('pyrcc4', '-o', join(srcopyFilesath,'qtcontrols','images_rc.py'), join(srcopyFilesath,'qtcontrols','images.qrc')) run('pyrcc4', '-o', join(srcopyFilesath,'resources_rc.py'), join(srcopyFilesath,'resources.qrc')) run('pyrcc4', '-o', join(srcopyFilesath,'syncing/resources_rc.py'), join(srcopyFilesath,'syncing/resources.qrc')) if iswindows: try: projects = ['libsyncing/libsyncing.csproj', 'provisioner/provisioner.csproj', 'syncer/syncer.csproj'] print " - building syncing tools..." for project in projects: run('MSBuild', '/property:Configuration=Release', '/verbosity:m', \ join(dotnetpath, project), shell=False, env=env) mssyncpath = os.path.join(dotnetpath, "bin") lib = os.path.join(mssyncpath, "libsyncing.dll") bin = os.path.join(mssyncpath, "provisioner.exe") clientsetuppath = os.path.join(curpath,"qmap-admin","client-setup") copy_tree(lib, clientsetuppath) copy_tree(bin, clientsetuppath) except ExecutionError: pass except WindowsError: pass
def _sub_repo(name, url): debug(lambda: "Updating themes") if not os.path.exists(name): run("git", "clone", url, name) with chdir(name): shell("git", "pull") shell("git", "submodule", "update", "--init", "--recursive")
def do_execute(self): self.init() outfile = os.path.join(self.outdir, self.name + '.a') objfiles = [] tasks = [] for source in self.sources: self.compile(source) if self.static: libfile = os.path.join(self.outdir, self.name + '.a') archive = [self.ar, 'rc', os.path.join(self.outdir, self.name + '.a')] archive.extend(self.objfiles) fabricate.run([archive]) self.add_output([libfile]) else: libfile = os.path.join(self.outdir, 'lib' + self.name + '.so') sharedlib = [self.cc, '-shared', '-o', libfile] sharedlib.extend(self.objfiles) fabricate.run([sharedlib]) self.add_output(libfile) for deps in self.deprules.values(): for dep in deps: if isinstance(dep, CcLibraryRule): self.add_outputs(dep.outputs) else: raise ValueError("Unsupported dependency type %s" % (type(dep)))
def build(): build_dir = BUILD_DIR pelican() themes() plugins() debug(lambda: "Building index and blogs") if not os.path.isdir(build_dir): os.mkdir(build_dir) indexfilename = os.path.join(build_dir, "index.html") with open(indexfilename, "w") as indexfile: for name in os.listdir(THEMES): if name in [ ".git" ]: continue path = os.path.join(THEMES, name) if not os.path.isdir(path): continue dest_theme = os.path.join(build_dir, name) if os.path.isdir(dest_theme): continue conf_file = os.path.join(THEMES, "configure-theme-" + name + ".py") shutil.copyfile("ipsumconf.py", conf_file) with open(conf_file, "a") as conf: conf.write('SITEURL="' + SITEURL + name + '"\n') if name == 'syte': conf.write('PLUGIN_PATH="plugins"\n') conf.write('PLUGINS=["assets"]\n') os.mkdir(dest_theme) print(_pelcmd('pelican'), '-t', path, '-o', dest_theme, '-s', conf_file, 'content') shell(_pelcmd('pelican'), '-t', path, '-o', dest_theme, '-s', conf_file, 'content', ignore_status=True, shell=True) indexfile.write('<h1><a href="' + name + '">' + name + '</a>') indexfile.write(' - <a href="' + THEMELINKBASE + name + '">source</a></h1>\n') theme_screenshot = os.path.join(THEMES, name, "screenshot.png") if os.path.exists(theme_screenshot): indexfile.write('<img src="' + name + '/screenshot.png">\n') run('cp', theme_screenshot, dest_theme) indexfile.write('<hr />\n')
def aspen(): if os.path.exists(_virt('aspen')): return _env() for dep in ASPEN_DEPS: run(_virt('pip'), 'install', '--no-index', '--find-links=' + INSTALL_DIR, dep) run(_virt('python'), 'setup.py', 'develop')
def dev(): _env() # pytest will need argparse if its running under 2.6 if _virt_version() < (2, 7): TEST_DEPS.insert(0, 'argparse') for dep in TEST_DEPS: run(_virt('pip'), 'install', '--no-index', '--find-links=' + TEST_DIR, dep)
def _dev_deps(envdir='env'): envdir = _deps(envdir) # pytest will need argparse if it's running under 2.6 if _virt_version(envdir) < (2, 7): TEST_DEPS.insert(0, 'argparse') for dep in TEST_DEPS: run(_virt('pip', envdir), 'install', '--no-index', '--find-links=' + TEST_DIR, dep) return envdir
def aspen(): _env() v = shell(_virt('python'), '-c', 'import aspen; print("found")', ignore_status=True) if "found" in v: return for dep in ASPEN_DEPS: run(_virt('pip'), 'install', '--no-index', '--find-links=' + INSTALL_DIR, dep) run(_virt('python'), 'setup.py', 'develop')
def analyse(envdir='./env'): dev(envdir=envdir) run(_virt('py.test'), '--junitxml=testresults.xml', '--cov-report', 'term', '--cov-report', 'xml', '--cov', 'aspen', 'tests/', ignore_status=False)
def analyse(): pylint() dev() aspen() run(_virt('nosetests'), '--with-xcoverage', '--with-xunit', 'tests', '--cover-package', 'aspen', ignore_status=True) print('done!')
def analyse(): dev() run(_virt('py.test'), '--junitxml=testresults.xml', '--cov-report', 'term', '--cov-report', 'xml', '--cov', name, 'tests/', ignore_status=False) print('done!')
def _deps(envdir='env'): envdir = _env(envdir) v = shell(_virt('python', envdir), '-c', 'import aspen; print("found")', ignore_status=True) if b"found" in v: return envdir for dep in ASPEN_DEPS: run(_virt('pip', envdir), 'install', '--no-index', '--find-links=' + INSTALL_DIR, dep) run(_virt('python', envdir), 'setup.py', 'develop') return envdir
def test_cov(): """run code coverage""" run(_virt('py.test', _dev_deps()), '--junitxml=testresults.xml', '--cov-report', 'term', '--cov-report', 'xml', '--cov-report', 'html', '--cov', 'aspen', 'tests/', ignore_status=False)
def buildqtfiles(): for root, dirs, files in os.walk(appsrcopyFilesath): for file in files: filepath = os.path.join(root, file) file, ext = os.path.splitext(filepath) if ext == '.ui': newfile = file + ".py" run('pyuic4.bat', '-o', newfile, filepath, shell=True) elif ext == '.qrc': newfile = file + "_rc.py" run('pyrcc4', '-o', newfile, filepath)
def buildqtfiles(): for folder in [appsrcopyFilesath, projectinstallerpath, configmangerpath]: for root, dirs, files in os.walk(folder): for file in files: filepath = os.path.join(root, file) file, ext = os.path.splitext(filepath) if ext == '.ui': newfile = file + ".py" run('pyuic4.bat', '-o', newfile, filepath, shell=True) elif ext == '.qrc': newfile = file + "_rc.py" run('pyrcc4', '-o', newfile, filepath)
def compile(self, source): compile = [self.cc] compile.extend(["-I" + self.module.root]) compile.extend(self.cflags) srcfile = os.path.join(self.indir, source) objfile = os.path.join(self.outdir, replace_ext(source, 'o')) if not self.static: compile.append('-fpic') compile.extend(['-c', srcfile]) compile.extend(['-o', objfile]) self.objfiles.append(objfile) fabricate.run([compile])
def _env(envdir='env'): # http://stackoverflow.com/a/1883251 if hasattr(sys, 'real_prefix'): # We're already inside someone else's virtualenv. return sys.prefix elif hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix: # We're already inside someone else's pyvenv. return sys.prefix elif os.path.exists(envdir): # We've already built our own virtualenv. return envdir args = [sys.executable] + ENV_ARGS + [envdir] run(*args) return envdir
def build(): if not shell('python', '--version').startswith('Python 2.7'): raise SystemExit('Error: Python 2.7 required') run( 'python', './vendor/virtualenv-1.7.1.2.py' , '--unzip-setuptools' , '--prompt="[gittip] "' , '--never-download' , '--extra-search-dir=' + p('./vendor/') , '--distribute' , p('./env/') ) pip_install('-r', p('./requirements.txt')) pip_install(p('./vendor/nose-1.1.2.tar.gz')) pip_install('-e', p('./'))
def link(self, target, ldflags, objfiles=[]): link = [self.cc] link.extend(ldflags) link.extend(['-o', target]) link.extend(self.objfiles) for deps_key in self.deprules.keys(): deps = self.deprules[deps_key] for dep in deps: if isinstance(dep, CcLibraryRule): if dep.static == True: link.extend(dep.outputs) else: dirs = {} for out in dep.outputs: dirs[os.path.dirname(out)] = 1 for d in dirs.keys(): link.extend(['-L' + d]) link.extend(['-l' + dep.name]) else: raise ValueError("Unsupported link dependency ('%s') of type %s" % (deps_key, type(dep).__name__)) fabricate.run([link])
def _sphinx_cmd(cmd, extra_pkgs=[]): envdir = _env() _deps() run('pip', 'install', *(['sphinx', 'sphinx-rtd-theme'] + extra_pkgs)) builddir = 'docs/_build' run('mkdir', '-p', builddir) args = ['-b', 'html', '-d', builddir + '/doctrees', 'docs', builddir + '/html'] run(cmd, args)
def link(self, target, ldflags, objfiles=[]): full_ldflags = copy.copy(DEFAULT_LDFLAGS) full_ldflags.append("-mmcu=%s" % self.mcu) full_ldflags.append("-Wl,-Map,%s.map" % target) full_ldflags.extend(ldflags) elf = target + '.elf' super(AvrBinaryRule, self).link(elf, full_ldflags, objfiles) # hex image for flashing fabricate.run([["avr-objcopy", "-j", ".text", "-j", ".data", "-O", "ihex", elf, target + ".hex"]]) # eeprom image fabricate.run([["avr-objcopy", "-j", ".eeprom", "--change-section-lma", ".eeprom=0", "-O", "ihex", elf, target + ".eeprom"]]) # dump assembly listing fabricate.run([["avr-objdump", "-S", elf, ">", target + ".lst"]], shell=True) # show sizes fabricate.run([["avr-size", "-C", "--mcu=%s" % self.mcu, elf]])
def dev(): if os.path.exists('env'): return args = ENV_ARGS + [ 'env' ] run(*args) for dep in RUN_DEPS + TEST_DEPS: run(_virt('pip'), 'install', dep) run(_virt('python'), 'setup.py', 'develop')
def jython_test(): _jenv() for dep in ASPEN_DEPS + TEST_DEPS: run(_virt('pip', 'jenv'), 'install', os.path.join('vendor', dep)) run(_virt('jython', 'jenv'), 'setup.py', 'develop') run(_virt('jython', 'jenv'), _virt('nosetests', 'jenv'), '--with-xunit', 'tests', '--xunit-file=jython-nosetests.xml', '--cover-package', 'aspen', ignore_status=True)
def release(): if main.options.release is None: print("Must specify a version to release with --release <version>") sys.exit(1) rel = main.options.release if rel in check_output(['git', 'tag', '-l'],universal_newlines=True).split('\n'): print("Version %s is already git tagged." % rel) sys.exit(1) _require_y("Release version %s ?" % rel) _set_version(rel) run(main.options.python, 'setup.py', 'sdist', '--formats=zip,gztar,bztar', 'upload') run(main.options.python, 'setup.py', 'bdist_wheel', 'upload') shell('git', 'commit', 'setup.py', '-m', 'Release %s' % rel, silent=False) shell('git', 'tag', rel, silent=False) _set_version(rel + '-dev') 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 jython_test(): _jenv() for dep in ASPEN_DEPS + TEST_DEPS: run(_virt('pip', 'jenv'), 'install', os.path.join('vendor', dep)) run(_virt('jython', 'jenv'), 'setup.py', 'develop') run(_virt('jython', 'jenv'), _virt('py.test', 'jenv'), '--junitxml=jython-testresults.xml', 'tests', '--cov-report', 'term', '--cov-report', 'xml', '--cov', 'aspen', ignore_status=True)
def jython_test(): """install jython and run tests with coverage (requires java)""" _jenv() for dep in TEST_DEPS: run(_virt('pip', 'jenv'), 'install', os.path.join('vendor', dep)) run(_virt('jython', 'jenv'), 'setup.py', 'develop') run(_virt('jython', 'jenv'), _virt('py.test', 'jenv'), '--junitxml=jython-testresults.xml', 'tests', '--cov-report', 'term', '--cov-report', 'xml', '--cov', 'aspen', ignore_status=True)
def _sphinx_cmd(packages, cmd): envdir = _deps(envdir='denv') for p in packages: run(_virt('pip', envdir='denv'), 'install', p) sphinxopts = [] builddir = 'docs/_build' run('mkdir', '-p', builddir) newenv = os.environ newenv.update({'PYTHONPATH': 'denv/lib/python2.7/site-packages'}) args = ['-b', 'html', '-d', builddir + '/doctrees', sphinxopts, 'docs', builddir + '/html'] run(_virt(cmd, envdir=envdir), args, env=newenv)
def buildqtfiles(): pyuic4 = 'pyuic4' if platform == 'win32': pyuic4 += '.bat' for folder in [appsrcopyFilesath, projectinstallerpath, configmangerpath]: for root, dirs, files in os.walk(folder): for file in files: filepath = os.path.join(root, file) file, ext = os.path.splitext(filepath) if ext == '.ui': newfile = file + ".py" run(pyuic4, '-o', newfile, filepath, shell=True) elif ext == '.qrc': newfile = file + "_rc.py" run('pyrcc4', '-o', newfile, filepath) elif ext == '.ts': newfile = file + '.qm' if os.name is 'nt': run('lrelease', filepath, '-qm', newfile) else: run('lrelease-qt4', filepath, '-qm', newfile)
def __env(envdir): # http://stackoverflow.com/a/1883251 if hasattr(sys, 'real_prefix'): # We're already inside someone else's virtualenv. return sys.prefix elif hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix: # We're already inside someone else's pyvenv. return sys.prefix elif os.path.exists(envdir): # We've already built our own virtualenv. return envdir if USE_PY_VENV: # use built-in venv module run(sys.executable, '-m', 'venv', envdir) else: # use virtualenv instead try: import virtualenv except ImportError: # install it when missing run(sys.executable, '-m', 'pip', 'install', '--user', 'virtualenv') run(sys.executable, '-m', 'virtualenv', envdir) return envdir
def wheel(): """build a wheel""" run(sys.executable, 'setup.py', 'bdist_wheel')
def _jenv(): _jython_home() jenv = dict(os.environ) jenv['PATH'] = os.path.join('.', 'jython_home', 'bin') + ':' + jenv['PATH'] args = [ 'jython' ] + ENV_ARGS + [ '--python=jython', 'jenv' ] run(*args, env=jenv)
def build(): """build an egg""" run(sys.executable, 'setup.py', 'bdist_egg')