Example #1
0
def _install_deps():
    """ Pre-install required Python packages. """

    print "Installing required Python packages ..."

    run = execSubproc( [['sudo', 'easy_install-2.7', 'pypng',],], shell=False )
    if not run:
        return False

    run = execSubproc( [['sudo', 'easy_install-2.7', 'gmpy2',],], shell=False )
    if not run:
        return False

    return True
Example #2
0
def _install_shared_libs(install_path):
    """ Pre-install required extension module shared object files into source directories. """

    build_path = path.join(install_path, 'build')
    print "Building MandelBrat library objects ...\n  -> {}".format(build_path)

    # execute 'python setup.py build_ext' in subprocess
    if not path.isdir(MBRAT_LIB_SRCD):
        return False
        
    libd = path.join(build_path, 'lib')
    run = execSubproc( [[MBRAT_PYVER, 'setup.py', 'build_ext', '--build-lib', libd],], 
                       shell=False )
    if not run:
        return False

    # copy shared library object into corresponding python package
    for objn in MBRAT_LIB_OBJN_L:
        objf = "_{0}.{1}".format(objn, MBRAT_LIB_OBJEXT)
        srcf = path.join(libd, objf)
        dstf = path.join( MBRAT_PYD, 'lib', objn, objf )

        print "==> Copying shared object {}".format(srcf)
        print "  -> {}".format(dstf)
        copy2(srcf, dstf)
        if not path.isfile( dstf ):
            print "==> ERROR: unable to copy {}".format(objf)
            return False

    # made it here? then we're good...
    return True
Example #3
0
def _install_exec():

    print "Installing '{0}' command at\n  -> {1}".format(MBRAT_PROG, MBRAT_CMDF)

    if path.isfile(MBRAT_CMDF):
        print "==> ERROR: Executable already exists."
        return False

    pyf = path.join(MBRAT_CONFD, "{}.py".format(MBRAT_PROG))
    tmp_cmd = path.join(MBRAT_ETCD, MBRAT_PROG)
    cmd_str = "#!/usr/bin/env bash\n" + \
              "exec \"{}\" \"$@\"\n".format(pyf)

    try:
        cmd_f = open(tmp_cmd, 'wb')
    except IOError as e:
        print "==> ERROR: {}".format(e.strerror)
        return False
    else:
        cmd_f.write(cmd_str)
        cmd_f.close()
        os.chmod(tmp_cmd, 0755)

    # copy temp command file into /usr/local/bin or elsewhere on $PATH
    run = execSubproc( [['sudo', 'cp', tmp_cmd, MBRAT_CMDF],], 
                       shell=False )
    if not run:
        return False

    if not path.isfile(MBRAT_CMDF):
        print "==> ERROR: Unable to create command executable script."
        return False

    return True
Example #4
0
def _uninstall():
    """ Uninstall everything. """

    print "Uninstalling resources ..."

    if not path.exists(MBRAT_CONFD):
        print "==> ERROR: MandelBrat is not installed."
        return False

    rmtree(MBRAT_CONFD, ignore_errors=True)
    if path.exists(MBRAT_CONFD):
        return False

    if path.isfile(MBRAT_CMDF):
        run = execSubproc( [['sudo', 'rm', MBRAT_CMDF],], 
                           shell=False )
        if not run:
            return False

    return True