示例#1
0
文件: setup.py 项目: octwanna/pyCGNS
new_args = []
for arg in sys.argv:
    if (not ('-I=' in arg or '--includes=' in arg)
            and not ('-U' in arg or '--update' in arg)
            and not ('-g' in arg or '--generate' in arg)
            and not ('-L=' in arg or '--libraries=' in arg)):
        new_args += [arg]
sys.argv = new_args

if args.update:
    #os.system('hg parents --template="{rev}\n" > %s/revision.tmp' \
    #          % CONFIG.PRODUCTION_DIR)
    # Quick and dirty revision, should use git describe --always instead
    os.system('git rev-list --reverse HEAD | awk "{ print NR }" | tail -n 1 > %s/revision.tmp' \
              % CONFIG.PRODUCTION_DIR)
    setuputils.updateVersionInFile('./lib/pyCGNSconfig_default.py',
                                   CONFIG.PRODUCTION_DIR)


def hasToGenerate(source, destination, force):
    if PLATFORM_WINDOWS:
        return True
    return (force or not os.path.exists(destination)
            or os.path.getmtime(source) > os.path.getmtime(destination))


def resolveVars(filename, conf, force):
    if hasToGenerate(filename + '.in', filename, args.generate):
        with open('%s.in' % filename, 'r') as fg1:
            l1 = fg1.readlines()
        l2 = [ll % conf for ll in l1]
        with open(filename, 'w') as fg2:
示例#2
0
for arg in sys.argv:
    if (not ('-I=' in arg or '--includes=' in arg)
            and not ('-U' in arg or '--update' in arg)
            and not ('-A' in arg or '--alternate' in arg)
            and not ('-F' in arg or '--force' in arg)
            and not ('-L=' in arg or '--libraries=' in arg)):
        new_args += [arg]
sys.argv = new_args

if args.update:
    #os.system('hg parents --template="{rev}\n" > %s/revision.tmp' \
    #          % CONFIG.PRODUCTION_DIR)
    # Quick and dirty revision, should use git describe --always instead
    os.system(r'git rev-list --count HEAD> {}/revision.tmp'.format(
        CONFIG.PRODUCTION_DIR))
    updateVersionInFile(fix_path('./lib/pyCGNSconfig_default.py'), CONFIG)


def hasToGenerate(source, destination, force):
    return (force or not os.path.exists(destination)
            or os.path.getmtime(source) > os.path.getmtime(destination))


def resolveVars(filename, confvalues, force):
    if hasToGenerate(filename + '.in', filename, force):
        with open('{}.in'.format(filename), 'r') as fg1:
            l1 = fg1.readlines()
        l2 = [ll.format(**confvalues) for ll in l1]
        with open(filename, 'w') as fg2:
            fg2.writelines(l2)