Exemplo n.º 1
0
 def setup(self):
     mingwbase = self.get_path()
     if not path(mingwbase).exists():
         makedirs(path(mingwbase))
     subd = os.listdir(mingwbase)
     safe_rmdir("EGG-INFO", subd)
     safe_rmdir("bin", subd)
     safe_rmdir("include", subd)
     data = []
     for dir in subd:
         dat = recursive_glob_as_dict(path(mingwbase) / dir,
                                      "*",
                                      strip_keys=True,
                                      prefix_key=dir).items()
         data += [(str(d), [str(f) for f in t if not f.endswith(".dll")])
                  for d, t in dat]
     bindirs = {"bin": str(self.get_bin_path())}
     incdirs = {"include": str(path(mingwbase) / "include")}
     #libdirs = {"lib": str(path(mingwbase/"lib")}
     return dict(
         VERSION=self.version,
         BIN_DIRS=bindirs,
         INC_DIRS=incdirs,
         LIB_DIRS=None,
         DATA_FILES=data,
     )
Exemplo n.º 2
0
    def patch_sip_config(self):
        # Patching sipconfig.py so that its
        # paths point to the qt4 egg path we are building.
        # Feel free to do better
        
        '''
        qt4_ = qt4()
        
        header = """
import re
from pkgit.path_solved import path

# HACK paths
qtdev = os.environ.get('QTDIR') if 'QTDIR' in os.environ else r'%s'
sip_bin     = '%s'
sip_include = '%s'
qt          = '%s'

try:
    from pkg_resources import Environment
    env = Environment()
    if 'qt4' in env:
        qt = env['qt4'][0].location # Warning: 0 is the active one
    if 'qt4-dev' in env:
        qtdev       = env['qt4-dev'][0].location # Warning: 0 is the active one
        sip_bin     = path(qtdev)/'bin'/'sip.exe'
        sip_include = path(qtdev)/'include'
except:
    pass"""%(qt4_.sourcedir.replace("\\", "/"), path(qt4_.install_bin_dir)/"sip".replace("\\", "/"), self.install_inc_dir.replace("\\", "/"), qt4_.sourcedir.replace("\\", "/"))

        txt = ""
        print "sip patching", os.getcwd()
        with open(path(self.sourcedir)/"sipconfig.py") as f:
            txt = f.read()

        # inject our new header
        txt = txt.replace("import re", header)

        prefix = sys.prefix.replace("\\", r"\\\\")
        # Evil massive regexp substitutions. RegExp are self-explanatory! Just kidding...
        txt = re.sub(r"(\s*'default_bin_dir':\s*)'%s'"%prefix,    r"\1sys.prefix", txt)
        txt = re.sub(r"(\s*'default_mod_dir':\s*)'%s.*'"%prefix,  r"\1path(sys.prefix)/'Lib'/'site-packages'", txt)
        txt = re.sub(r"(\s*'default_sip_dir':\s*)'[A-Z]:\\\\.*'", r"\1path(qtdev)/'sip'", txt)
        txt = re.sub(r"(\s*'py_conf_inc_dir':\s*)'%s.*'"%prefix,  r"\1path(sys.prefix)/'include'", txt)
        txt = re.sub(r"(\s*'py_inc_dir':\s*)'%s.*'"%prefix,       r"\1path(sys.prefix)/'include'", txt)
        txt = re.sub(r"(\s*'py_lib_dir':\s*)'%s.*'"%prefix,       r"\1path(sys.prefix)/'libs'", txt)
        txt = re.sub(r"(\s*'sip_bin':\s*)'[A-Z]:\\\\.*'",         r"\1sip_bin", txt)
        txt = re.sub(r"(\s*'sip_inc_dir':\s*)'[A-Z]:\\\\.*'",     r"\1sip_include", txt)
        txt = re.sub(r"(\s*'sip_mod_dir':\s*)'[A-Z]:\\\\.*'",     r"\1qt", txt)

        shutil.copyfile( path(self.sourcedir)/"sipconfig.py", path(self.sourcedir)/"sipconfig.py.old" )
        
        with open( path(self.sourcedir)/"sipconfig.py", "w") as f:
            f.write(txt)
        '''
        try:
            os.makedirs(self.install_site_dir)
        except:
            pass
        shutil.copyfile( path(self.sourcedir)/"sipconfig.py", path(self.install_site_dir)/"sipconfig.py" )
Exemplo n.º 3
0
def generate_pascal_test_install_code(dependencies):
    final = ""
    testVariables = {"python": "PyInstalled"}  #there's always this variable

    for pk, info in dependencies.iteritems():
        mask_ = info[0]
        testVariables[pk] = pk + "Installed"  #always defined
        if bt(mask_, TEST_ME):
            if bt(mask_, NOT_INSTALLABLE):
                template = StrictTemplate(python_package_test_template)
                final += template.substitute(PACKAGE=pk,
                                             PACKAGE_TEST=path(
                                                 info[2]).basename())
            else:
                #"ti" stands for "test and install"
                if bt(mask_, MSI): template = python_package_ti_template_msi
                elif bt(mask_, EXEDIST):
                    template = python_package_ti_template_zipdist
                elif bt(mask_, ZIPDIST):
                    template = python_package_ti_template_zipdist
                elif bt(mask_, TARDIST):
                    template = python_package_ti_template_zipdist
                elif bt(mask_, EGG):
                    template = python_package_ti_template_egg
                elif bt(mask_, EXE):
                    template = python_package_ti_template_exe
                else:
                    raise Exception("Unknown installer type: " + pk + ":" +
                                    str(mask_))
                template = StrictTemplate(template)
                final += template.substitute(
                    PACKAGE=pk,
                    PACKAGE_TEST=path(info[2]).basename(),
                    PACKAGE_INSTALLER=path(info[1]).basename())
        else:

            if bt(mask_, NOT_INSTALLABLE):
                continue
            else:
                if bt(mask_, MSI):
                    template = python_package_install_template_msi
                elif bt(mask_, EXEDIST):
                    template = python_package_install_template_zipdist
                elif bt(mask_, ZIPDIST):
                    template = python_package_install_template_zipdist
                elif bt(mask_, TARDIST):
                    template = python_package_install_template_zipdist
                elif bt(mask_, EGG):
                    template = python_package_install_template_egg
                elif bt(mask_, EXE):
                    template = python_package_install_template_exe
                else:
                    raise Exception("Unknown installer type: " + pk + ":" +
                                    str(mask_))
                template = StrictTemplate(template)
                print pk, info[0], info[1]
                final += template.substitute(PACKAGE=pk,
                                             PACKAGE_INSTALLER=path(
                                                 info[1]).basename())
    return final, testVariables
Exemplo n.º 4
0
    def make_install(self):
        print "Make install"
    
        # it is possible to bootstrap boost if no bjam.exe is found:
        if not (path(self.sourcedir)/"bjam.exe").exists() :
            print "Call bootstrap.bat"
            #mingw_path = r"c:/Python27/Lib/site-packages/mingw-5.2-py2.7-win32.egg/" 
            #mingw_path = r"c:/MinGW/" 
            #if sh("bootstrap.bat mingw --toolset-root=%s"%(mingw_path)) != 0:
            mingw_path = r"C:\Python27\Lib\site-packages\Mingw-5.1.4_4c-py2.7-win32.egg"
            if sh("bootstrap.bat mingw --toolset-root=%s"%(mingw_path)) != 0:
                return False
            else:
                # The Bootstrapper top-level script ignores that gcc
                # was used and by default says it's msvc, even though
                # the lower level scripts used gcc.
                ascii_file_replace( "project-config.jam",
                                    "using msvc",
                                    "using gcc")
        # try to fix a bug in python discovery which prevents
        # bjam from finding python on Windows NT and old versions.
        pyjam_pth = path("tools")/"build"/"v2"/"tools"/"python.jam"
        ascii_file_replace(pyjam_pth,
                           "[ version.check-jam-version 3 1 17 ] || ( [ os.name ] != NT )",
                           "[ version.check-jam-version 3 1 17 ] && ( [ os.name ] != NT )")

        paths = str(self.installdir), str(path(sys.prefix)/"include"), str(path(sys.prefix)/"libs")
        cmd = "bjam --prefix=%s --without-test --layout=system"
        cmd += " variant=release link=shared threading=multi runtime-link=shared toolset=gcc"
        cmd += " include=%s library-path=%s install"
        cmd %= paths
        print
        print cmd
        print
        return sh(cmd) == 0
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(Pyqglviewer, self).__init__(*args, **kwargs)
     qglbuilder = qglviewer()
     self.qglbuilderbase = qglbuilder.sourcedir,
     self.install_sip_dir = path(qglbuilder.installdir) / "sip"
     self.install_site_dir = qglbuilder.installdir
     self.install_exa_dir = path(qglbuilder.installdir) / "examples"
Exemplo n.º 6
0
 def post_install(self):
     """
     Try to install egg, exe or msi after packaging.
     
     Search an egg, then an exe, then a msi.
     
     If it is an egg, use command alea_install -H None -f . mypackage.egg
     
     Can be overloaded.
     
     :return: True if success, else False
     """
     
     egg_search = self.egg_name() + "*"
     egg = glob.glob( path(".")/egg_search )
     if egg:
         egg = egg[0]
         cmd = "alea_install -H None -f . %s" %egg
         return sh(cmd) == 0
     else: 
         #
         name_search = "*" + self.name + "*.exe"
         name = glob.glob( path(".")/name_search )
         if not name:
             name_search = "*" + self.name + "*.msi"
             name = glob.glob( path(".")/name_search )
         
         if name:
             name = name[0]
             return util_install(name)
             
     return False
Exemplo n.º 7
0
 def _unpack(self):
     if self.UNPACK:
         logger.debug("==UNPACK==")
         # a formula with a none url implicitely means
         # the sources are already here because some
         # other formula installed it.
         # If not downloadable : do nothing
         if self.download_url is None:
             logger.debug("No url")
             ret = True
         if path(self.sourcedir).exists():
             # If already unpacked and size > 0 : do nothing
             if (path(self.sourcedir).getsize() > 0) and (not self.force):
                 message = 'already unpacked in %s' % repr(self.sourcedir)
                 logger.debug(message)
                 ret = True
             # If already unpacked but size = 0 : unpack
             else:
                 ret = self.unpack()
         # Else: unpack
         else:
             ret = self.unpack()
         logger.debug("Unpack %s" % ret)
         return ret
     return True
Exemplo n.º 8
0
    def post_install(self):
        """
        Try to install egg, exe or msi after packaging.
        
        Search an egg, then an exe, then a msi.
        
        If it is an egg, use command alea_install -H None -f . mypackage.egg
        
        Can be overloaded.
        
        :return: True if success, else False
        """

        egg_search = self.egg_name() + "*"
        egg = glob.glob(path(".") / egg_search)
        if egg:
            egg = egg[0]
            cmd = "alea_install -H None -f . %s" % egg
            return sh(cmd) == 0
        else:
            #
            name_search = "*" + self.name + "*.exe"
            name = glob.glob(path(".") / name_search)
            if not name:
                name_search = "*" + self.name + "*.msi"
                name = glob.glob(path(".") / name_search)

            if name:
                name = name[0]
                return util_install(name)

        return False
Exemplo n.º 9
0
    def _extend_python_path(self):
        # Use PYTHONPATH instead PYTHON_PATH

        exp = self.extra_python_paths()
        if exp is not None:
            if isinstance(exp, tuple):
                for e in exp:
                    e = path(e).normpath()
                    sys.path.extend(e)
                exp = sj(exp)
            elif isinstance(exp, str):
                exp = path(exp).normpath()
                sys.path.extend(exp.split(os.pathsep))

            path_splited = os.environ.get("PYTHONPATH","").split(";")
            # Check if not already set
            if not exp in path_splited:
                os.environ["PYTHONPATH"] = sj([exp,os.environ.get("PYTHONPATH","")])
                
                cmd = " PYTHONPATH "
                for e in exp.split(";"):
                    cmd = cmd + "\"" + e + "\";"
                cmd = cmd + "%PYTHONPATH%"
                
                # set temp PYTHON_PATH
                cmd1 = "SET" + cmd
                logger.debug( cmd1 )
                sh(cmd1)
                
                # set permanent PYTHONPATH
                cmd2 = "SETX" + cmd
                logger.debug( cmd2 )
                sh(cmd2)

        return True
Exemplo n.º 10
0
 def _unpack(self):
     if self.UNPACK:
         logger.debug("==UNPACK==") 
         # a formula with a none url implicitely means
         # the sources are already here because some
         # other formula installed it.
         # If not downloadable : do nothing
         if self.download_url is None:
             logger.debug("No url")
             ret = True
         if path(self.sourcedir).exists():
             # If already unpacked and size > 0 : do nothing
             if (path(self.sourcedir).getsize() > 0) and (not self.force):
                 message =  'already unpacked in %s' %repr(self.sourcedir)
                 logger.debug(message)
                 ret = True
             # If already unpacked but size = 0 : unpack
             else:
                 ret = self.unpack()
         # Else: unpack
         else:
             ret = self.unpack()
         logger.debug("Unpack %s" %ret)
         return ret 
     return True
Exemplo n.º 11
0
def unpack(arch, where):
    """ Unpack a ZIP, TGZ or TAR file from 'where'
    """
    arch = arch
    base, ext = path( arch ).splitext()
    logger.info("Unpacking %s in %s" %(arch,where))
    # TODO : verify that there is no absolute path inside zip.
    if ext == ".zip":
        zipf = zipfile.ZipFile( arch, "r" )
        zipf.extractall( path=where )
    elif ext == ".tgz":
        tarf = tarfile.open( arch, "r:gz")
        tarf.extractall( path=where )
    elif ext == ".tar":
        tarf = tarfile.open( arch, "r")
        tarf.extractall( path=where )
    logger.info("Unpack done.")
    
    # If ZIP contained only one directory, unpack move everything.
    # ex:
    # ./ann_src.zip/ann_1.1.2/... will begin after unpack ./ann_src/...
    where = path(where).abspath()
    listdirs = os.listdir(where)
    if len(listdirs) == 1:
        from_dirs = where/listdirs[0]
        move(from_dirs, where)
    return True
Exemplo n.º 12
0
 def configure(self):
     if (path(self.sourcedir)/"configure.py").exists():
         # The -S flag is needed or else configure.py
         # sees any existing sip installation and can fail.
         cmd = sys.executable + " -S configure.py --platform win32-g++ -b %s -d %s -e %s -v %s"%self.inst_paths
         print
         print cmd
         print
         ret = sh(cmd) == 0
     else:
         #if configure.py doesn't exist then we might
         #be using a zipball retreived directly from
         #sip's mercurial repository. This type of source
         #needs a step before actually calling configure.py
         if path("build.py").exists():
             print "Will try to build sip from mercurial source zipball"
             try:
                 #We need bison and flex
                 sh("bison.exe")
             except:
                 print "Could not find bison flex, use --bisonflex"
                 return False
             apply_patch_from_string( PATCH )
             sh(sys.executable + " -S build.py prepare")
             ret = self.configure()
         else:
             #we don't have a clue of what type of source we're in
             #so dying cleanly can seem like a good option:
             return False
     self.patch_sip_config()
     return ret
Exemplo n.º 13
0
 def setup(self):
     return dict(
         VERSION=self.version,
         LIB_DIRS={'lib': str(path(self.sourcedir) / 'lib')},
         INC_DIRS={'include': str(path(self.sourcedir) / 'include')},
         BIN_DIRS={'bin': str(path(self.sourcedir) / 'bin')},
         INSTALL_REQUIRES=["cmake"],
     )
Exemplo n.º 14
0
 def make(self):
     ret = sh(sys.executable + " setup.py build") == 0
     os.chdir("engine")
     self._packages=[pkg.replace('.','/') for pkg in find_packages('.')]
     self._package_dir = dict([(pkg, str(path(pkg).abspath())) for pkg in self._packages])
     os.chdir("..")
     self._bin_dir = {'EGG-INFO/scripts': str(path('script').abspath())}
     return ret
Exemplo n.º 15
0
 def setup(self):
     return dict( 
                 VERSION          = self.version,
                 LIB_DIRS         = {'lib' : str(path(self.sourcedir)/'lib') },
                 INC_DIRS         = {'include' : str(path(self.sourcedir)/'include') },
                 BIN_DIRS         = {'bin' : str(path(self.sourcedir)/'bin') },
                 INSTALL_REQUIRES = ["cmake"],
                 ) 
Exemplo n.º 16
0
def configure_inno_setup_without_args(appname, appversion, dependencies, runtime, pyMaj, pyMin, setup, outDir, funcs, egg_pths):
    print "Configuring inno script...",
    f = open( path(__path__)/"template_win_inst.iss.in")
    s = f.read()
    f.close()

    template = StrictTemplate(s)
    eggnum = len(egg_pths)

    eggArrayInit = ""
    for i, e in enumerate(egg_pths):
        eggArrayInit+="Eggs[%i] := '%s';\n"%(i, e) 
    
    s='\n'+"#"*80+'\n'
    print s+eggArrayInit+s
    
    step = int(100./(eggnum+len(dependencies)))    
    detect, testVars = funcs["generate_pascal_test_install_code"](dependencies)
    testingBody, reportingBody = funcs["generate_pascal_detect_env_body"](dependencies, testVars, appname)
    installationBody = funcs["generate_pascal_deploy_body"](dependencies, testVars, step)

    modeStr = "" if runtime else "dev"
    s = template.substitute(APPNAME=appname,
                            APPVERSION=appversion,
                            INSTTYPE=modeStr.upper(),
                            SETUP_CONF=funcs["generate_inno_installer_setup_group"](setup),
                            #configure Python Major and Minor
                            PYTHONMAJOR=pyMaj,
                            PYTHONMINOR=pyMin,
                            #the pascal booleans that store if this or that package is installed or not.
                            TEST_VARIABLES=reduce(lambda x,y: x+", "+y, testVars.itervalues(), "dummy"),
                            #the files that will be packed by the installer.
                            INSTALLER_FILES=funcs["generate_inno_installer_files_group"](dependencies, egg_pths),
                            #configure number of eggs
                            EGGMAXID=str(eggnum-1),
                            #configure the initialisation of egg array
                            EGGINIT=eggArrayInit,
                            #configure other pascal code
                            STEP=step,
                            #configure the functions that detect and install packages
                            INSTALL_AND_DETECTION_CODE=detect,
                            #configure the body of DetectEnv that tests
                            TEST_VAR_RESULTS=testingBody,
                            #configure the body of DetectEnv that reports
                            REPORT_VAR_RESULTS=reportingBody,
                            INSTALL_APP_BODY=funcs["generate_pascal_install_code"](str(eggnum-1)),
                            #configure the body of Deploy that installs the dependencies
                            DEPLOY_BODY=installationBody,
                            #Code to run on post install
                            POSTINSTALLCODE=funcs["generate_pascal_post_install_code"](egg_pths),                            
                            )

    fpath = path(outDir)/appname+"_installer_"+modeStr+".iss"
    f = open( fpath, "w" )
    f.write(s.encode(local_enc))
    f.close()
    print "ok"
    return fpath
Exemplo n.º 17
0
def generate_inno_installer_setup_group(setup):    
    final = ""
    for k, v in setup.iteritems():
        src = path(v).basename()
        if "file" in k.lower():
            src = path(v).abspath()
            print "\t"+src
        final += k + "=" + src + "\n"
    return final
Exemplo n.º 18
0
 def make(self):
     ret = sh(sys.executable + " setup.py build") == 0
     os.chdir("engine")
     self._packages = [pkg.replace('.', '/') for pkg in find_packages('.')]
     self._package_dir = dict([(pkg, str(path(pkg).abspath()))
                               for pkg in self._packages])
     os.chdir("..")
     self._bin_dir = {'EGG-INFO/scripts': str(path('script').abspath())}
     return ret
Exemplo n.º 19
0
def generate_inno_installer_setup_group(setup):
    final = ""
    for k, v in setup.iteritems():
        src = path(v).basename()
        if "file" in k.lower():
            src = path(v).abspath()
            print "\t" + src
        final += k + "=" + src + "\n"
    return final
Exemplo n.º 20
0
 def make_install(self):
     # The install procedure will install qscintilla in qt's directories
     recursive_copy(self.sourcedir, self.install_inc_dir, Pattern.include)
     recursive_copy(
         path(self.sourcedir) / "release", self.install_lib_dir,
         Pattern.qtstalib)
     recursive_copy(
         path(self.sourcedir) / "release", self.install_dll_dir,
         Pattern.dynlib)
     return True
Exemplo n.º 21
0
def recursive_copy(sourcedir, destdir, patterns=None, levels=-1, flat=False):
    """Like shutil.copytree except that it accepts a filepattern or a file regexp."""
    src = recursive_glob( sourcedir, patterns, levels=levels )
    dests = [destdir]*len(src) if flat else \
            [ path(destdir)/f[len(sourcedir)+1:] for f in src]
    # bases = set([ split(f)[0] for f in dests])
    bases = set([ path(f).splitpath()[0] for f in dests])
    for pth in bases:
        makedirs(pth)
    for src, dst in zip(src, dests):
        shutil.copy(src, dst)
Exemplo n.º 22
0
 def __init__(self, *args, **kwargs):
     super(Pyqt4, self).__init__(*args, **kwargs)
     # we install pyqt4 binaries in the qt bin installation directory to easily recover it
     # for the egg. The eggs are built in the historical layout used by openalea packagers.
     # This doesn't mean it's good. It doesn't mean it's bad though it does look a bit messy.
     qt4_    = qt4()
     sip     = sip_()
     self.install_bin_dir  = qt4_.install_bin_dir
     self.install_site_dir = path(self.installdir)/"site"
     self.install_sip_dir  = path(self.installdir)/"sip"
     self.inst_paths       = self.install_bin_dir, self.install_site_dir, self.install_sip_dir  
     self.sipsite          = sip.install_site_dir
     self.siphome          = sip.install_sip_dir
Exemplo n.º 23
0
def move(from_src, to_src):
    """ Move a tree from from_src to to_src.
    """
    # If 'from' inside 'to' move in a temp repo and works well
    if to_src in from_src:
        temp_src = path(to_src)/".."/".temp"
        shutil.move(from_src, temp_src)
        from_src = temp_src
    # If 'to' already exists, erase it... Careful!
    if path(to_src).exists():
        shutil.rmtree(to_src)
    shutil.move(from_src, to_src)
    return True
Exemplo n.º 24
0
 def find_packages_and_directories(self):
     """
     Find packages thanks to setuptools and then fix corresponding directories names.
     
     :return: list(packages, dict(packages:directories))
     """
     pkgs = self._find_packages()
     dirs = {}
     install_dir = path(self.package.__file__).abspath().dirname()
     base = (path(install_dir)/os.pardir).abspath()
     for pk in pkgs:
         dirs[pk] =  path(base)/pk.replace(".", os.sep)
     return pkgs, dirs          
Exemplo n.º 25
0
 def find_packages_and_directories(self):
     """
     Find packages thanks to setuptools and then fix corresponding directories names.
     
     :return: list(packages, dict(packages:directories))
     """
     pkgs = self._find_packages()
     dirs = {}
     install_dir = path(self.package.__file__).abspath().dirname()
     base = (path(install_dir) / os.pardir).abspath()
     for pk in pkgs:
         dirs[pk] = path(base) / pk.replace(".", os.sep)
     return pkgs, dirs
Exemplo n.º 26
0
 def make_install(self):
     """ pyqglviewer installs itself into the same directory as qglviewer """
     recursive_copy(path(self.sourcedir) / "build",
                    self.install_site_dir,
                    Pattern.pyext,
                    levels=1)
     recursive_copy(path(self.sourcedir) / "src" / "sip",
                    self.install_sip_dir,
                    Pattern.sipfiles,
                    levels=1)
     recursive_copy(
         path(self.sourcedir) / "examples", self.install_exa_dir,
         Pattern.any)
     return True
Exemplo n.º 27
0
def eggify_formula(formula_name, dest_dir=None, dry_run=False, force=False):
    """
    Eggify only one formula
    :param formula_name: string name of the formula
    :param dest_dir: directory where to put the egg when it is created
    :return: (instance of the eggified formula), (True if success else False)
    """    
    formula = instanciate_formula(formula_name)
    print("Formula %s instantiated." %formula_name)

    if not dry_run:    
        logger.debug("Formula %s" %(formula_name))
        if dest_dir is not None:
            formula.dist_dir = path(dest_dir).abspath()
        if force:
            formula.force = True
        
        ret = True
        ret = ret & formula._download()
        ret = ret & formula._unpack()
        ret = ret & formula._install()
        ret = ret & formula._configure()
        ret = ret & formula._make()
        ret = ret & formula._make_install()
        ret = ret & formula._bdist_egg()
        ret = ret & formula._copy_installer()
        ret = ret & formula._post_install()
        
        print ""
        print "Formula %s success : %s ==============================" %(formula_name,ret)
        print ""
        
        logger.debug("Formula %s success : %s" %(formula_name,ret))
        return formula, ret
Exemplo n.º 28
0
def url(name, dir=None, dl_name=None):
    """ Download from url into dir and renamed it into dl_name. 
    
    TODO : percentage download thanks to http://stackoverflow.com/questions/13909900/progress-of-python-requests-post
    """
    logger.info("Download %s in %s" %(dl_name,dir))
    ret = True
    
    if dir is None:
        dir = '.'
    dir = path(dir).abspath()
    if not dir.exists():
        makedirs(dir)
    
    filename = name.split('/')[-1]
    filename = filename.split('#')[0]
    complete_fn = dir/filename
    if dl_name:
        complete_fn = dir/dl_name

    try:
        reponse = requests.get(name)
        with open(complete_fn, "wb") as code:
            code.write(reponse.content)
            logger.info("%s downloaded." %filename)
            ret = complete_fn
    except:
        ret = False
        
    return ret
Exemplo n.º 29
0
 def get_version(self):
     pop = subprocess.Popen( path(self.get_bin_path())/"gcc --version",
                                        stdout=subprocess.PIPE)
     time.sleep(1)
     output = pop.stdout.read()
     reg = re_compile(r"(\d\.\d.\d)")
     return reg.search(output).group(1)
Exemplo n.º 30
0
def generate_pascal_post_install_code(egg_pths):
    s = ""
    s += """
        RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
                'PATH', str1);
        if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\R-core\R', 'InstallPath', str2) then
                RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
                'R_HOME', str2);
                        
        if (Pos('%R_HOME%', str1) = 0) then
            RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
                'PATH', str1+';%R_HOME%');  
    """

    egg_post_inst = StrictTemplate("""
    Exec(GetPythonDirectory()+'python.exe', '-c "import sys;sys.path.append(\\"'+ GetPythonDirectory()+'Lib\\site-packages\\'+Eggs[$EGGID]+'\\");import $EGGNAME' + '_postinstall as pi;pi.install()', '',
     SW_HIDE, ewWaitUntilTerminated, ResultCode);""")

    names = ["lpygui"]

    for i, e in enumerate(egg_pths):
        e = path(e).basename()
        for p in names:
            if p in e.lower():
                s += egg_post_inst.substitute(EGGID=str(i), EGGNAME=p)
    return s
Exemplo n.º 31
0
 def make_install(self):
     ret = super(Qscintilla, self).make_install()
     qt4_ = qt4()
     try:
         shutil.move( path(qt4_.install_dll_dir)/"libqscintilla2.a", qt4_.install_lib_dir)
     except Exception, e :
         print e
Exemplo n.º 32
0
    def _bdist_egg(self):
        if self.BDIST_EGG:
            logger.debug("==BDIST_EGG==") 
            ret = self._configure_script()     
            ret = ret & self.bdist_egg()
            
            if not ret:
                # If bdist_egg create an empty egg, remove empty egg
                egg = self._glob_egg()
                if egg is not None:
                    path(egg).removedirs()
                    logger.warnings("Can't eggify. Remove %s"%egg) 

            logger.debug("Bdist_egg %s" %ret)
            return ret
        return True
Exemplo n.º 33
0
 def make_qt_conf(self, where=None):
     """ Patch qt *.exes and *.dlls so that they do not contain hard coded paths anymore. """
     print "Make qt conf"
     config = ConfigParser.RawConfigParser()
     sec = "Paths"
     config.add_section(sec)
     if where == None:
         config.set(sec, "Headers", "../include")
         config.set(sec, "Libraries", "../lib")
         config.set(sec, "Binaries", "../bin")
         config.set(sec, "Plugins", "../dll")
         #config.set(sec, "Imports"	"no idea")
         config.set(sec, "Data", "..")
         config.set(sec, "Translations", "../translations")
     else:
         unix_installdir = self.installdir.replace("\\", "/")
         config.set(sec, "Headers", uj(unix_installdir, "include"))
         config.set(sec, "Libraries", uj(unix_installdir, "lib"))
         config.set(sec, "Binaries", uj(unix_installdir, "bin"))
         config.set(sec, "Plugins", uj(unix_installdir, "dll"))
         #config.set(sec, "Imports"	"no idea")
         config.set(sec, "Data", unix_installdir)
         config.set(sec, "Translations", uj(unix_installdir,
                                            "translations"))
     # Writing our configuration file
     if where is None:
         where = self.install_bin_dir
     with open(path(where) / 'qt.conf', 'w') as configfile:
         config.write(configfile)
     return True
Exemplo n.º 34
0
 def is_installed(self):
     compiler = path(self.get_bin_path())/"gcc.exe"
     try:
         sh(compiler+" --version")
         return True
     except OSError:
         return False  
Exemplo n.º 35
0
def remove_temp(formula_name,download_too=False):
    """
    Remove files created by "easy_pkg package formula_name".
    """
    try:
        formula_name_cap = formula_name[0].capitalize() + formula_name[1:]
        cmd_import = "from pkgit.formulas.%s import %s" %(formula_name,formula_name_cap)
        exec(cmd_import, globals(), locals())
    except ImportError:
        print
        print("Cannot find formula %s. Maybe it is misspelled" %formula_name)
        print
        raise
    
    # instanciate formula
    cmd_instanciate = "%s()" %formula_name_cap
    formula = eval(cmd_instanciate)    
    
    dirs = [formula.sourcedir,formula.eggdir,formula.installdir]
    if download_too:
        dirs.append(formula.archname)
    print "Will remove %s" %str(dirs)
    
    # Remove
    for f in dirs:
        f = path(f)
        if f.exists():
            if f.isdir():
                f.rmtree()
            else:
                f.remove()
        else:
            logger.debug( "Can't remove %s" %f)
Exemplo n.º 36
0
 def get_version(self):
     pop = subprocess.Popen(path(self.get_bin_path()) / "gcc --version",
                            stdout=subprocess.PIPE)
     time.sleep(1)
     output = pop.stdout.read()
     reg = re_compile(r"(\d\.\d.\d)")
     return reg.search(output).group(1)
Exemplo n.º 37
0
 def is_installed(self):
     compiler = path(self.get_bin_path()) / "gcc.exe"
     try:
         sh(compiler + " --version")
         return True
     except OSError:
         return False
Exemplo n.º 38
0
    def _bdist_egg(self):
        if self.BDIST_EGG:
            logger.debug("==BDIST_EGG==")
            ret = self._configure_script()
            ret = ret & self.bdist_egg()

            if not ret:
                # If bdist_egg create an empty egg, remove empty egg
                egg = self._glob_egg()
                if egg is not None:
                    path(egg).removedirs()
                    logger.warnings("Can't eggify. Remove %s" % egg)

            logger.debug("Bdist_egg %s" % ret)
            return ret
        return True
Exemplo n.º 39
0
def prepare_working_dir(instDir, no_del=False):
    if path(instDir).exists():
        if no_del:
            return
        print instDir, "will be deleted"
        shutil.rmtree(instDir, ignore_errors=False)
    print instDir, "will be created"
    os.makedirs(instDir)
Exemplo n.º 40
0
 def setup(self):
     inc = str(path(self.sourcedir)/"eigen")
     return dict( 
                 VERSION  = self.version,
                 INC_DIRS = {'include' : inc },
                 LIB_DIRS = None,
                 BIN_DIRS = None,
                 )
Exemplo n.º 41
0
def prepare_working_dir(instDir, no_del=False):
    if path(instDir).exists():
        if no_del:
            return
        print instDir, "will be deleted"
        shutil.rmtree(instDir, ignore_errors=False)
    print instDir, "will be created"
    os.makedirs(instDir)
Exemplo n.º 42
0
    def unpack(self):
        ret = super(Ann, self).unpack()
        root = str(self.sourcedir)
        if str(self.sourcedir).endswith('ann_%s' % self.version):
            root = str(path(self.sourcedir) / '..')
            # self.sourcedir = path(self.sourcedir)/'ann_%s'%self.version
        print(root)

        print "Apply PATCH part1"
        apply_patch_from_string(PATCH, root=root)
        print "Apply PATCH part2"
        apply_patch_from_string(PATCH2, root=root)

        if not str(self.sourcedir).endswith('ann_%s' % self.version):
            self.sourcedir = path(self.sourcedir) / 'ann_%s' % self.version

        return ret
Exemplo n.º 43
0
 def configure(self):
     compiler = mingw().get_path()
     boost_ = boost()
     db_quote = lambda x: '"'+x+'"'
     options = " ".join(['-DCMAKE_INSTALL_PREFIX='+db_quote(self.installdir),
                         '-DCMAKE_CXX_COMPILER:FILEPATH='+db_quote(path(compiler)/"bin"/"g++.exe"),
                         '-DBOOST_ROOT='+db_quote(boost_.installdir),
                         '-DGMP_INCLUDE_DIR='+db_quote( path(compiler)/"include" ),
                         '-DMPFR_INCLUDE_DIR='+db_quote( path(compiler)/"include"),
                         '-DZLIB_INCLUDE_DIR='+db_quote(path(compiler)/"include"),
                         '-DZLIB_LIBRARY='+db_quote(path(compiler)/"lib"/"libz.a"),
                         #'-DOPENGL_LIBRARIES='+db_quote(path(compiler)/".."/"lib"/"libglu32.a"),
                         ])
     options=options.replace("\\", "/") #avoid "escape sequence" errors with cmake
     cmd = 'cmake -G"MinGW Makefiles" '+options+' . '
     print cmd
     return sh(cmd) == 0   
Exemplo n.º 44
0
def formulas():
    """
    Return the list of formula available.
    """
    path_ = path(__file__).abspath().dirname()
    formula_list = glob.glob(path(path_)/"formulas"/"*.py")

    short_list = list()
    for formu in formula_list:
        formu = path(formu).splitpath()[-1]
        formu = path(formu).splitext()[0]
        short_list.append(str(formu))
        
    if short_list.count("__init__") > 0:
        short_list.remove("__init__")
        
    return short_list
Exemplo n.º 45
0
def checkout(url, dir=None):
    """ Checkout (SVN) url into dir
    """
    if dir is None:
        dir = '.'
    dir = path(dir)
    cmd = "svn co %s %s " %(url, dir)
    return sh(cmd) == 0
Exemplo n.º 46
0
    def setup(self):
        mingw_path = mingw().get_path()
        bison_path = path(mingw_path)/"msys"/"1.0"

        bindirs = {"bin": str(path(bison_path)/"bin")}
        incdirs = {"include": str(path(bison_path)/"include")}
        libdirs = {"lib": str(path(bison_path)/"lib")}

        # GET DATA FILES (share directory and subdirs)
        OLDDIR = os.getcwd()
        BISFLEXDIR = (path(bison_path)/"share").abspath()
        BISFLEXDIR = str(BISFLEXDIR).replace("\\", "/")
        os.chdir(BISFLEXDIR)
        raw_files = os.walk(BISFLEXDIR)
        data_files = []
        for i,j,k in raw_files:
            for f in k:
                # we want to reproduce the same hierarchy inside the egg.
                # as inside the BISFLEXDIR.
                rel_direc = path(i).relpath(BISFLEXDIR).replace("\\","/")
                file_ = unix_style_join( rel_direc, f)        
                data_files.append( ("share" if rel_direc == "." else str(path("share")/rel_direc),[str(path(file_).abspath())]) )
        os.chdir(OLDDIR)
        
        return dict( 
                    VERSION  = self.version,
                    BIN_DIRS = bindirs,
                    INC_DIRS = incdirs,
                    LIB_DIRS = libdirs,
                    DATA_FILES = data_files
                    )
Exemplo n.º 47
0
 def packaged(self):
     """
     :return: True if not yet packaged in dist repo. Else False
     """
     name_search = "*" + self.name + "*"
     name = glob.glob(path(self.dist_dir) / name_search)
     if name:
         return True, name
     return False, ""
Exemplo n.º 48
0
def git_clone(url, dir=None):
    """
    Clone a Git directory from *url* into directory *dir*.
    """
    if dir is None:
        dir = '.'
    dir = path(dir)
    cmd = "git clone %s %s " %(url, dir)
    return sh(cmd) == 0
Exemplo n.º 49
0
    def unpack(self):
        ret = super(Ann, self).unpack()
        root = str(self.sourcedir)
        if str(self.sourcedir).endswith('ann_%s'%self.version):
            root = str(path(self.sourcedir)/'..')
            # self.sourcedir = path(self.sourcedir)/'ann_%s'%self.version
        print(root)

        print "Apply PATCH part1"
        apply_patch_from_string(PATCH, root=root)
        print "Apply PATCH part2"
        apply_patch_from_string(PATCH2, root=root)
        
        
        if not str(self.sourcedir).endswith('ann_%s'%self.version):
            self.sourcedir = path(self.sourcedir)/'ann_%s'%self.version

        return ret
Exemplo n.º 50
0
def into_subdir(base, pattern):
    if pattern is not None:
        pths = glob.glob(path(base)/pattern)
        if len(pths):
            return pths[0]
        else:
            return None
    else:
        return base
Exemplo n.º 51
0
    def globInstaller(pk, mask_):
        dir_ = srcDir
        identifier = "*" + pk + "*"
        if bt(mask_, PY_DEP):
            identifier += pyMaj + "." + pyMin + "*"
        if bt(mask_, MSI): identifier += ".msi"
        elif bt(mask_, EXE): identifier += ".exe"
        elif bt(mask_, EXEDIST):
            identifier += ".exe"
            dir_ = tpp_eggDir
        elif bt(mask_, ZIPDIST):
            identifier += ".zip"
            dir_ = tpp_eggDir
        elif bt(mask_, TARDIST):
            identifier += ".tar.gz"
            dir_ = tpp_eggDir
        elif bt(mask_, EGG):
            identifier += ".egg"
            dir_ = tpp_eggDir
        elif bt(mask_, NOFLAG):
            return None
        else:
            raise Exception("Unknown installer type: " + pk + ":" + str(mask_))

        try:
            if bt(mask_, ARCH):  #WE CARE ABOUT THE ARCH
                if arch == "win32":  #either it has 32 or nothing but not 64
                    files = [
                        f for f in glob.iglob(path(dir_) / identifier)
                        if arch in f or ("win32" not in f and "64" not in f)
                    ]
                else:
                    files = [
                        f for f in glob.iglob(path(dir_) / identifier)
                        if arch in f
                    ]
                return sorted(files, lambda x, y: cmp(len(x), len(y)))[0]
            else:
                return glob.glob(path(dir_) / identifier)[0]
        except:
            #traceback.print_exc()
            err(u"\tNo installer found for %s for %s : %s\n" %
                (pk, dir_, identifier))
            return None
Exemplo n.º 52
0
 def get_bin_path(self):
     # works well ?
     if "win32" not in sys.platform:
         return "/usr/bin"
     if self.options.get("compiler"):
         v = self.options["compiler"]
         if path(v).exists():
             return v
     else:
         return self.get_path() / "bin"
Exemplo n.º 53
0
def default():
    """ Return default url and path for download projects from url to path.
    Projects are "OpenAlea", "VPlants" and "Alinea".
    Struct is: OrderedDict(namedtuple('Project', 'url dir'))
    """
    URL_OA = "https://scm.gforge.inria.fr/svn/openalea/branches/release_1_0"
    URL_VP = "https://scm.gforge.inria.fr/svn/vplants/vplants/branches/release_1_0"
    URL_AL = "https://scm.gforge.inria.fr/svn/openaleapkg/branches/release_1_0"

    DIR_OA = path(os.getcwd()) / "src" / "openalea"
    DIR_VP = path(os.getcwd()) / "src" / "vplants"
    DIR_AL = path(os.getcwd()) / "src" / "alinea"

    Project = namedtuple('Project', 'url dir')
    projects = OrderedDict()
    projects['openalea'] = Project(URL_OA, DIR_OA)
    projects['vplants'] = Project(URL_VP, DIR_VP)
    projects['alinea'] = Project(URL_AL, DIR_AL)
    return projects
Exemplo n.º 54
0
    def get_path(self):
        from pkg_resources import get_distribution
        location = "c:\\MinGW"
        try:
            result = get_distribution('mingw')
            location = result.location
        except:
            location = "c:\\MinGW"

        return path(location)
Exemplo n.º 55
0
 def copy_installer(self):
     """
     Copy a previously downloaded installer file in dist repository.
     
     Can be overloaded.
     
     :return:  True
     """
     shutil.copy(self.download_name,
                 path(self.dist_dir) / self.download_name)
     return True
Exemplo n.º 56
0
 def setup(self):
     from setuptools import find_packages
     return dict(URL          = self.homepage,
                 PACKAGES     = find_packages(self.installdir,"rpy2"),
                 PACKAGE_DIRS = { "rpy2": str(path(self.installdir)/"rpy2") },
                 VERSION      = self.version+".rev"+self.revision,
                 PACKAGE_DATA = {'' : [Pattern.pyext]},
                 LIB_DIRS     = None,
                 INC_DIRS     = None,
                 BIN_DIRS     = None,
                 )
Exemplo n.º 57
0
 def configure(self):
     compiler = mingw().get_path()
     boost_ = boost()
     db_quote = lambda x: '"' + x + '"'
     options = " ".join([
         '-DCMAKE_INSTALL_PREFIX=' + db_quote(self.installdir),
         '-DCMAKE_CXX_COMPILER:FILEPATH=' +
         db_quote(path(compiler) / "bin" / "g++.exe"),
         '-DBOOST_ROOT=' + db_quote(boost_.installdir),
         '-DGMP_INCLUDE_DIR=' + db_quote(path(compiler) / "include"),
         '-DMPFR_INCLUDE_DIR=' + db_quote(path(compiler) / "include"),
         '-DZLIB_INCLUDE_DIR=' + db_quote(path(compiler) / "include"),
         '-DZLIB_LIBRARY=' + db_quote(path(compiler) / "lib" / "libz.a"),
         #'-DOPENGL_LIBRARIES='+db_quote(path(compiler)/".."/"lib"/"libglu32.a"),
     ])
     options = options.replace(
         "\\", "/")  #avoid "escape sequence" errors with cmake
     cmd = 'cmake -G"MinGW Makefiles" ' + options + ' . '
     print cmd
     return sh(cmd) == 0