Ejemplo n.º 1
0
 def delTearDownClass(cls):
     print('cwd ', os.getcwd())
     if 'Tests' in os.getcwd():
         print('del {}'.format('mock\appname_assembly.json'))
         try:
             os.remove(opabs('mock\appname_assembly.json'))
         except WindowsError:
             pass
     if 'Tests' in os.getcwd():
         print('del {}'.format('mock\appname_config.config'))
         try:
             os.remove(opabs('mock\appname_config.config'))
         except WindowsError:
             pass
Ejemplo n.º 2
0
def _createStdLib():

    if gsBuild.Verbose or not gsBuild.INFO:
        log.info('\nNew StdLib compile: {}'.format(compiler.stdlibsource))

    gb0 = glob.glob(opn(opj(compiler.libpath, '*.py')))
    gb1 = glob.glob(opn(opj(compiler.libpath, '\*.py')))
    gb2 = glob.glob(opn(opj(compiler.libpath, '*\*.py')))
    gb3 = glob.glob(opn(opj(compiler.libpath, '*\*\*.py')))

    gb = list(gb0 + gb1 + gb2 + gb3)

    gb.append("/out:" + compiler.stdlibsource.replace('.dll', ''))
    gb.append("/target:dll")

    ipystr = [compiler.ipath + '/ipy'] + [compiler.pycpath] + gb
    if _subprocPYC(ipystr, opabs(compiler.stdlibsource), dotExt=None):
        if op.isfile(opabs(compiler.stdlibsource)):
            log.FILE('Build Created: {}' \
                     .format(opabs(compiler.stdlibsource)))

    compiler.isStdLib = op.isfile(opabs(compiler.stdlibsource))
Ejemplo n.º 3
0
def _setCompilerClass(rconfig):

    config = ndcDict(rconfig)
    f_standalone = None
    f_embed = None
    f_libembed = None
    f_parerr = None
    # f_parerr - Stop build on partialError that is Fatal to Compile
    # Let makeBuild finish so that user can fix partialErrs

    with open(config['CONFIGPATH'], 'r') as jbcr:
        config = ndcDict(json.load(jbcr))

    if gsBuild.Verbose or not gsBuild.INFO:
        log.info('\n Building from CONFIG:\n {}\n'.format(
            json.dumps(config, indent=4)))

    if not opex(config['MAINFILE']):
        try:
            raise IOError
        except IOError as ex:
            msg = 'File Filepath does Not exist:\n "{}"' \
                    .format(config['MAINFILE'])
            partialError(ex, msg)
            f_parerr = True

    if not f_parerr:
        log.FILE('Build Loaded: {}'.format(config['MAINFILE']))

    assemInfo = config['ASSEMBLY']
    if isinstance(assemInfo['standalone'], bool) or \
        str(assemInfo['standalone']).upper() in ['TRUE', 'FALSE']:
        f_standalone = True if str(assemInfo['standalone']).upper() == \
                                                            'TRUE' else False
    if isinstance(assemInfo['embed'], bool) or \
        str(assemInfo['embed']).upper() in ['TRUE', 'FALSE']:
        f_embed = True if str(assemInfo['embed']).upper() == 'TRUE' else False

    if isinstance(assemInfo['libembed'], bool) or \
        str(assemInfo['libembed']).upper() in ['TRUE', 'FALSE']:
        f_libembed = True if str(assemInfo['libembed']).upper() \
                        == 'TRUE' else False

    ext = '.dll'
    if config['MAKEEXE'] == True or \
        str(config['MAKEEXE']).upper() == 'TRUE':
        ext = '.exe'

    if f_standalone and not config['MAKEEXE']:
        log.warn('\n** Switching to exe /stanalone == true in Assembly:' + \
                 '\n {}\n   Overrides default or makeEXE input arg == False' \
                 .format(config['JSONPATH']))

    MAINOUT = opn(opj(config['OUTDIR'], ('.').join(opb(config['MAINFILE']) \
                      .split('.')[:-1])) + ext)
    IPATH = gsBuild.IPATH
    STDLIBSOURCE = opabs(opj(IPATH, 'StdLib.dll'))
    LIBPATH = opabs(opj(IPATH, 'Lib'))
    compiler.pycpath = (opn(opd(opabs(gsBuild.IPYBLDPATH)))) + '\pyc.py'
    compiler.stdlibsource = STDLIBSOURCE
    compiler.ipath = IPATH
    compiler.libpath = LIBPATH

    if not op.isfile(STDLIBSOURCE):
        _createStdLib()

    MAINOUTDIR = ('.').join(MAINOUT.split('.')[:-1])
    PYCDIR = opn(opj(os.getcwd(), opb(MAINOUTDIR)) + ext)
    STDLIBRELEASE = opj(opd(MAINOUTDIR), 'StdLib.dll')
    MAINFILE = config['MAINFILE']
    isLib = opex(LIBPATH)
    isStdLib = op.isfile(STDLIBSOURCE)
    haveStdLib = op.isfile(opj(os.getcwd(), 'StdLib.dll'))
    isReleasedStdLib = op.isfile(STDLIBRELEASE)

    lstdll = []
    if config['LISTFILES']['dll']:
        if isinstance(config['LISTFILES']['dll'], list):
            for lfile in config['LISTFILES']['dll']:
                if lfile and '__init__' not in lfile:
                    lstdll.append(lfile)
        else:
            lstdll.append(config['LISTFILES']['dll'])

    lstexe = []
    if config['LISTFILES']['exe']:
        if isinstance(config['LISTFILES']['exe'], list):
            for xfile in config['LISTFILES']['exe']:
                if xfile and '__init__' not in xfile:
                    lstexe.append(xfile)
        else:
            lstexe.append(config['LISTFILES']['exe'])

        lstexe = nullList(lstexe)

    compiler.f_standalone = f_standalone
    compiler.f_embed = f_embed
    compiler.f_libembed = f_libembed
    compiler.f_parerr = f_parerr
    compiler.mainout = MAINOUT
    compiler.ipath = IPATH
    compiler.mainoutdir = MAINOUTDIR
    compiler.pycdir = PYCDIR
    compiler.stdlibrelease = STDLIBRELEASE
    compiler.stdlibsource = STDLIBSOURCE
    compiler.libpath = LIBPATH
    compiler.mainfile = MAINFILE
    compiler.isLib = isLib
    compiler.isStdLib = isStdLib
    compiler.haveStdLib = haveStdLib
    compiler.isReleasedStdLib = isReleasedStdLib
    compiler.lstdll = lstdll
    compiler.lstexe = lstexe
    compiler.ext = ext
    compiler.lstexedlls = None

    if not opex(opd(compiler.pycdir)):
        raise IOError('FilePath {}:\t Use absolute or relative to:\n\t {}' \
                      .format(opd(compiler.pycdir), os.getcwd()))
    if compiler.f_standalone:
        if gsBuild.Verbose or not gsBuild.INFO:
            log.info('\nNew {} compile standalone from:\n {}' \
                            .format(ext.upper().replace('.', ''),
                                    config['MAINFILE']))
    else:
        mfn = 'application/lib'
        if config['MAINFILE']:
            mfn = opb(config['MAINFILE'])
        if gsBuild.Verbose or not gsBuild.INFO:
            log.info(("\nNew {} compile from: \n {}" + \
                      "\n\tAs Required: add your {}, project, and ironpython"+ \
                      "\n\tdll(s) to path:\n\t{}\n\n")
                     .format(ext.upper().replace('.', ''),
                             config['MAINFILE'], mfn,
                             config['OUTDIR']))

    if gsBuild.Verbose or not gsBuild.INFO:
        log.info('\n Lib source path {}'.format(LIBPATH))
        log.info('\n "IF" set "True", f_libembed adds ~23mb to file:' + \
                 'now set as {}'.format(compiler.f_libembed))

    if compiler.f_libembed and compiler.isStdLib:
        if gsBuild.Verbose or not gsBuild.INFO:
            if compiler.isReleasedStdLib:
                log.info('\nOK - "StdLib.dll" exists delete'+ \
                         ' or move to update:\n{}'.format(STDLIBRELEASE))
            else:
                log.info('\nOK - "StdLib.dll" exists delete'+ \
                         ' or move to update:\n{}'.format(STDLIBSOURCE))

    elif not compiler.isStdLib and compiler.f_libembed and \
        not compiler.isReleasedStdLib and compiler.isLib:

        _createStdLib()

    if not compiler.isStdLib:
        raise NotImplementedError('StdLib: Need ironpython2.7 distribution' + \
                                  ' in something like ../ironpython path')