Example #1
0
def get_qmake():
    qmake = ''
    try:
        qmake = which('qmake-qt4')
    except:
        qmake = which('qmake')
    return qmake
def h(options,buildout):
    make = "gmake"
    try:
        make = which("gmake")
    except:
        make = "make"
    os.environ['MAKE'] = make
def libtoolize(options, buildout):
    """relibtoolize if you can do it, stolen from gentoo jpeg ebuild"""
    cwd = os.getcwd()
    os.chdir(options['compile-directory'])
    l = None
    try:
        l = which('libtoolize')
    except Exception, e:
        pass
Example #4
0
def get_otool():
    if sys.platform.lower() == 'darwin':
        return which('otool')
Example #5
0
def get_install_name_tool():
    if sys.platform.lower() == 'darwin':
        return which('install_name_tool')
Example #6
0
    def pre(self, command, output_dir, vars):
        common.Template.pre(self, command, output_dir, vars)
        vars["sharp"] = "#"
        vars["linux"] = "linux" in sys.platform
        if not "opt_deps" in vars:
            vars["opt_deps"] = ""
        if vars["inside_minitage"]:
            if not self.special_output_dir:
                vars["path"] = os.path.join(self.output_dir, vars["category"], vars["project"])
            else:
                vars["path"] = self.output_dir
        else:
            vars["category"] = ""
            if not self.special_output_dir:
                vars["path"] = os.path.join(self.output_dir, vars["project"])
            else:
                vars["path"] = self.output_dir
        if not self.special_output_dir:
            vars["project_dir"] = vars["project"]
            vars["category_dir"] = vars["category"]
        else:
            vars["project_dir"] = ""
            vars["category_dir"] = ""
        interpreter, pyver = None, None
        pythons = {
            "python2.4": "2.4",
            "python2.5": "2.5",
            "python2.6": "2.6",
            "python2.7": "2.7",
            "python3.0": "3.0",
            "python3.1": "3.1",
            "python3.2": "3.2",
        }
        python = getattr(self, "python", None)
        if vars["inside_minitage"]:
            latest_python = None
            dsearch_latest = {"py-libxslt.*": "xslt", "py-libxml2.*": "xml2", "python-\d.\d": "latest_python"}
            vars["minilays"] = minilays = os.path.join(vars["mt"], "minilays")
            xml2, xslt = [
                search_latest(a, minilays)
                for a in (
                    "py-libxml2-.",
                    "py-libxslt-.*",
                    #'py-mapnik-.*'
                )
            ]
            for regex in dsearch_latest.keys():
                minibuild = search_latest(regex, minilays)
                stmt = "%s='%s'" % (dsearch_latest[regex], minibuild)
                exec stmt
                del dsearch_latest[regex]
            if (not python) and latest_python:
                python = latest_python
            pyver = pythons[python.replace("-", "")]
        else:
            if not python:
                python = vars["python"]
            else:
                python = python.replace("-", "")
                pyver = pythons[python]
            interpreter = which(python)
            executable_version = (
                os.popen('%s -c "%s"' % (interpreter, "import sys;print sys.version[:3]")).read().replace("\n", "")
            )
            executable_prefix = os.path.abspath(
                subprocess.Popen(
                    [interpreter, "-c", "import sys;print sys.prefix"],
                    stdin=subprocess.PIPE,
                    stdout=subprocess.PIPE,
                    close_fds=True,
                )
                .stdout.read()
                .replace("\n", "")
            )
            if pyver and (executable_version != pyver):
                try:
                    interpreter = which("python%s" % pyver)
                    executable_version = (
                        os.popen('%s -c "%s"' % (interpreter, "import sys;print sys.version[:3]"))
                        .read()
                        .replace("\n", "")
                    )
                    executable_prefix = os.path.abspath(
                        subprocess.Popen(
                            [interpreter, "-c", "import sys;print sys.prefix"],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            close_fds=True,
                        )
                        .stdout.read()
                        .replace("\n", "")
                    )
                except:
                    print "Cant find a python %s installation, you didnt give a %s python to paster" % (pyver, pyver)
                    raise
            if pyver and (executable_version != pyver):
                print "Cant find a python %s installation, you didnt give a %s python to paster" % (pyver, pyver)
                raise Exception("Incompatible python")

        if vars["inside_minitage"]:
            interpreter = os.path.join(
                "${buildout:directory}", "..", "..", "dependencies", python, "parts", "part", "bin", "python"
            )
            executable_prefix = os.path.join(vars["mt"], "dependencies", "python-%s" % pyver, "parts", "part")
            executable_version = pyver
            vars["opt_deps"] = "%s %s  %s" % (xml2, xslt, "python-%s" % pyver)
            vars["xml2"] = os.path.join("${minitage:location}", "eggs", xml2, "parts", "site-packages-%s" % pyver)
            # vars['mapnik'] = os.path.join('${minitage:location}',
            #                        'eggs', mapnik,
            #                        'parts', 'site-packages-%s' % pyver,
            #                             'lib', 'python%s' % pyver, 'site-packages')
            vars["xslt"] = os.path.join("${minitage:location}", "eggs", xslt, "parts", "site-packages-%s" % pyver)
            vars["mt"] = "${buildout:directory}/../.."
        else:
            vars["xml2"] = os.path.join(executable_prefix, "lib", "python%s" % executable_version, "site-packages")
            vars["xslt"] = os.path.join(executable_prefix, "lib", "python%s" % executable_version, "site-packages")
            # vars['mapnik'] = os.path.join(executable_prefix, 'lib', 'python%s' % executable_version, 'site-packages')
            vars["opt_deps"] = ""

        # minitage needs python.
        if not interpreter and (not vars["inside_minitage"]):
            raise Exception("Python interpreter not found")

        vars["python"] = interpreter
        vars["python26"] = re.sub("(2|3)\..", "2.6", interpreter)
        vars["python_minibuild"] = "python-%s" % pyver
        vars["python_minibuild"] = "python-%s" % pyver
        vars["pyver"] = pyver
        vars["libpyver"] = pyver.replace(".", "")
        vars["python_version"] = executable_version
        vars["executable_site_packages"] = os.path.join(
            executable_prefix, "lib", "python%s" % executable_version, "site-packages"
        )
        vars["executable_prefix"] = executable_prefix
Example #7
0
    def pre(self, command, output_dir, vars):
        common.Template.pre(self, command, output_dir, vars)
        vars['sharp'] = '#'
        vars['linux'] = 'linux' in sys.platform
        if not 'opt_deps' in vars:
            vars['opt_deps'] = ''
        if vars['inside_minitage']:
            if not self.special_output_dir:
                vars['path'] = os.path.join(
                    self.output_dir,
                    vars['category'],
                    vars['project'],
                )
            else:
                vars['path'] = self.output_dir
        else:
            vars['category'] = ''
            if not self.special_output_dir:
                vars['path'] = os.path.join(self.output_dir, vars['project'])
            else:
                vars['path'] = self.output_dir
        if not self.special_output_dir:
            vars['project_dir'] = vars['project']
            vars['category_dir'] = vars['category']
        else:
             vars['project_dir'] = ''
             vars['category_dir'] = ''
        interpreter, pyver = None, None
        pythons = {
            'python2.4': '2.4',
            'python2.5': '2.5',
            'python2.6': '2.6',
            'python2.7': '2.7',
            'python3.0': '3.0',
            'python3.1': '3.1',
            'python3.2': '3.2',
        }
        python = getattr(self, 'python', None)
        if vars['inside_minitage']:
            latest_python = None
            dsearch_latest = {'py-libxslt.*': 'xslt',
                             'py-libxml2.*': 'xml2',
                             'python-\d.\d': 'latest_python'}
            vars['minilays'] = minilays = os.path.join(vars['mt'], 'minilays')
            xml2, xslt = [search_latest(a, minilays)
                                  for a in (
                                      'py-libxml2-.', 
                                      'py-libxslt-.*', 
                                      #'py-mapnik-.*'
                                  )]
            for regex in dsearch_latest.keys():
                minibuild = search_latest(regex, minilays)
                stmt = '%s=\'%s\'' % (dsearch_latest[regex], minibuild)
                exec  stmt
                del dsearch_latest[regex]
            if (not python) and latest_python:
                python = latest_python
            pyver = pythons[python.replace('-', '')]
        else:
            if not python:
                python = vars['python']
            else:
                python = python.replace('-', '')
                pyver = pythons[python]
            interpreter = which(python)
            executable_version = os.popen(
                '%s -c "%s"' % (
                    interpreter,
                    'import sys;print sys.version[:3]'
                )
            ).read().replace('\n', '')
            executable_prefix = os.path.abspath(
                subprocess.Popen(
                    [interpreter, '-c', 'import sys;print sys.prefix'],
                    stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                    close_fds=True).stdout.read().replace('\n', '')
            )
            if pyver and (executable_version != pyver):
                try:
                    interpreter = which('python%s' % pyver)
                    executable_version = os.popen(
                        '%s -c "%s"' % (
                            interpreter,
                            'import sys;print sys.version[:3]'
                        )
                    ).read().replace('\n', '')
                    executable_prefix = os.path.abspath(
                        subprocess.Popen(
                            [interpreter, '-c', 'import sys;print sys.prefix'],
                            stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                            close_fds=True).stdout.read().replace('\n', '')
                    )
                except:
                    print 'Cant find a python %s installation, you didnt give a %s python to paster' % (pyver, pyver)
                    raise
            if pyver and (executable_version != pyver):
                print 'Cant find a python %s installation, you didnt give a %s python to paster' % (pyver, pyver)
                raise Exception('Incompatible python')

        if vars['inside_minitage']:
            interpreter = os.path.join(
                '${buildout:directory}', '..', '..',
                'dependencies', python, 'parts', 'part', 'bin', 'python')
            executable_prefix = os.path.join(
                vars['mt'], 'dependencies',
                'python-%s' %  pyver, 'parts', 'part')
            executable_version = pyver
            vars['opt_deps'] = '%s %s  %s' % (xml2, xslt, 'python-%s' %  pyver)
            vars['xml2'] = os.path.join('${minitage:location}',
                                        'eggs', xml2,
                                    'parts', 'site-packages-%s' % pyver)
            #vars['mapnik'] = os.path.join('${minitage:location}',
            #                        'eggs', mapnik,
            #                        'parts', 'site-packages-%s' % pyver,
            #                             'lib', 'python%s' % pyver, 'site-packages') 
            vars['xslt'] = os.path.join('${minitage:location}',
                                    'eggs', xslt,
                                    'parts', 'site-packages-%s' % pyver)
            vars['mt'] = '${buildout:directory}/../..'
        else:
            vars['xml2'] = os.path.join(executable_prefix, 'lib', 'python%s' % executable_version, 'site-packages')
            vars['xslt'] = os.path.join(executable_prefix, 'lib', 'python%s' % executable_version, 'site-packages')
            #vars['mapnik'] = os.path.join(executable_prefix, 'lib', 'python%s' % executable_version, 'site-packages')
            vars['opt_deps'] = ''

        # minitage needs python.
        if not interpreter and (not vars['inside_minitage']):
            raise Exception('Python interpreter not found')

        vars['python'] = interpreter
        vars['python26'] = re.sub('(2|3)\..', '2.6', interpreter)
        vars['python_minibuild'] = 'python-%s' % pyver
        vars['python_minibuild'] = 'python-%s' % pyver
        vars['pyver'] = pyver
        vars['libpyver'] = pyver.replace('.', '')
        vars['python_version'] = executable_version
        vars['executable_site_packages'] = os.path.join(
            executable_prefix, 'lib', 'python%s'%executable_version, 'site-packages')
        vars['executable_prefix'] = executable_prefix