Ejemplo n.º 1
0
def pycairo(options,buildout):
    cwd = os.getcwd()
    if not os.path.isfile(options['configure']):
        options['configure'] = which(options['configure'])
    os.chdir(options['compile-directory'])
    os.environ['PYTHON']=  options['configure']
    os.environ['PYTHON_CONFIG'] = which((os.path.basename(options['configure'])
                                         + '-config'))
    os.environ['PYTHONARCHDIR'] = options['prefix']
    cmds = [
        '%s %s%s %s' % (
            options['configure'],
            options['prefix-option'],
            options['prefix'],
            options['configure-options']
        ),
        '%s waf %s' % (
            options['configure'], 'build'

        ),
        '%s waf %s' % (
            options['configure'], 'install'
        ),
    ]
    for cmd in cmds:
        print "Running %s"  % cmd
        ret = os.system(cmd)
        if ret != 0:
            raise Exception('%s did not run' % cmd)

    os.chdir(cwd)
 def scripts(reqs,
             working_set,
             executable,
             dest,
             scripts=None,
             extra_paths=(),
             arguments='',
             interpreter='',
             initialization='',
             relative_paths=False,
            ):
     if not '/' in executable:
         executable = common.which(executable)
     if os.path.exists(executable):
         executable = os.path.abspath(executable)
     if not scripts:
         scripts = []
     if isinstance(scripts, dict):
         cscripts = deepcopy(scripts)
         scripts = []
         for item in cscripts:
             scripts.append('%s=%s' % (item, cscripts[item]))
     if (not relative_paths) or (relative_paths == 'false'):
         relative_paths = 'false'
     else:
         relative_paths = 'true'
     if not interpreter:
         interpreter = ''
     options = {}
     options['generate_all_scripts'] = True
     options['eggs'] = ''
     options['entry-points'] = ''
     options['executable'] = executable
     if '\n'.join(scripts).strip():
         options['scripts'] = '\n'.join(scripts)
         options['generate_all_scripts'] = False
     options['extra-paths'] = '\n'.join(extra_paths)
     options['arguments'] = arguments
     options['interpreter'] = interpreter
     options['initialization'] = initialization
     options['relative-paths'] = relative_paths
     for req in reqs:
         if isinstance(req, str):
             if parse_entry_point(req):
                 options['entry-points'] += '%s\n' % req
             else:
                 # append it to eggs to be generated
                 try:
                     #if it is really an egg
                     req = pkg_resources.Requirement.parse(req)
                     # append it to eggs
                     options['eggs'] += '\n%s' % req
                 except Exception, e:
                     #other wise, just add the dist to the scripts for later use
                     options['scripts'] += '\n%s' % req
         elif isinstance(req, tuple):
             options['entry-points'] += '%s=%s:%s\n' % req
 def scripts(
     reqs,
     working_set,
     executable,
     dest,
     scripts=None,
     extra_paths=(),
     arguments="",
     interpreter="",
     initialization="",
     relative_paths=False,
 ):
     if not "/" in executable:
         executable = common.which(executable)
     if not scripts:
         scripts = []
     if isinstance(scripts, dict):
         cscripts = deepcopy(scripts)
         scripts = []
         for item in cscripts:
             scripts.append("%s=%s" % (item, cscripts[item]))
     if (not relative_paths) or (relative_paths == "false"):
         relative_paths = "false"
     else:
         relative_paths = "true"
     if not interpreter:
         interpreter = ""
     options = {}
     options["generate_all_scripts"] = True
     options["eggs"] = ""
     options["entry-points"] = ""
     options["executable"] = executable
     if "\n".join(scripts).strip():
         options["scripts"] = "\n".join(scripts)
         options["generate_all_scripts"] = False
     options["extra-paths"] = "\n".join(extra_paths)
     options["arguments"] = arguments
     options["interpreter"] = interpreter
     options["initialization"] = initialization
     options["relative-paths"] = relative_paths
     for req in reqs:
         if isinstance(req, str):
             if parse_entry_point(req):
                 options["entry-points"] += "%s\n" % req
             else:
                 # append it to eggs to be generated
                 try:
                     # if it is really an egg
                     req = pkg_resources.Requirement.parse(req)
                     # append it to eggs
                     options["eggs"] += "\n%s" % req
                 except Exception, e:
                     # other wise, just add the dist to the scripts for later use
                     options["scripts"] += "\n%s" % req
         elif isinstance(req, tuple):
             options["entry-points"] += "%s=%s:%s\n" % req
Ejemplo n.º 4
0
def pycairo(options,buildout):
    cwd = os.getcwd()
    if not os.path.isfile(options['configure']):
        options['configure'] = which(options['configure'])
    os.chdir(options['compile-directory'])
    cmd = '%s %s%s %s' % (
        options['configure'],
        options['prefix-option'],
        options['prefix'],
        options['configure-options']
        )
    print "Running %s"  % cmd
    os.system(cmd)
    os.chdir(cwd)
    def install(specs, dest,
                links=(), index=None,
                executable=dexecutable, always_unzip=None,
                path=None, working_set=None, newest=True, versions=None,
                use_dependency_links=None, allow_hosts=('*',),
                include_site_packages=None, allowed_eggs_from_site_packages=None,
                prefer_final=None):
        if not '/' in executable:
            executable = common.which(executable)
        if os.path.exists(executable):
            executable = os.path.abspath(executable)

        if not working_set:
            working_set = pkg_resources.WorkingSet([])

        for i, spec in enumerate(specs[:]):
            if 'setuptools' in spec:
                try:
                    # do we have distribute out there
                    working_set.require('distribute')
                    if isinstance(specs[i], str):
                        specs[i] = specs[i].replace('setuptools', 'distribute')
                    __log__.info('We are using distribute')
                except:
                    __log__.info('We are not using distribute')
        opts = copy(buildout['buildout'])
        opts['executable'] = executable
        opts['buildoutscripts'] = 'true'
        r = Egg(buildout, 'foo', opts)
        r.eggs = specs
        r._dest = dest
        if not r._dest:
            r._dest = buildout['buildout']['eggs-directory']
        if links:
            r.find_links = links
        if index:
            r.index = index
        if always_unzip:
            r.zip_safe = not always_unzip
        caches = r.eggs_caches[:]
        if path:
            if not isinstance(path, str):
                caches.extend([ os.path.abspath(p) for p in path])
            else:
                caches.append(os.path.abspath(path))
        caches = common.uniquify(caches)
        for cache in caches:
            if not (cache in r.eggs_caches):
                r.eggs_caches.append(cache)
        if not versions:
            versions = buildout.get('versions', {})
        ## which python version are we using ?
        #r.executable_version = os.popen(
        #    '%s -c "%s"' % (
        #        executable,
        #        'import sys;print sys.version[:3]'
        #    )
        #).read().replace('\n', '')
        if buildout.offline:
            allow_hosts = 'None'
        try:
            r.inst = easy_install.Installer(
                dest=None,
                index=r.index,
                links=r.find_links,
                executable=r.executable,
                always_unzip=r.zip_safe,
                newest = newest,
                versions = versions,
                use_dependency_links = use_dependency_links,
                path=r.eggs_caches,
                allow_hosts=allow_hosts,
                include_site_packages=None,
                allowed_eggs_from_site_packages=None,
                prefer_final=None,
            )
        except:
            # buildout < 1.5.0
            r.inst = easy_install.Installer(
                dest=None,
                index=r.index,
                links=r.find_links,
                executable=r.executable,
                always_unzip=r.zip_safe,
                newest = newest,
                versions = versions,
                use_dependency_links = use_dependency_links,
                path=r.eggs_caches,
                allow_hosts=allow_hosts,
            )
        r.platform_scan()
        reqs, working_set = r.working_set(working_set=working_set)
        return working_set