예제 #1
0
파일: make.py 프로젝트: westernx/vee
    def factory(cls, step, pkg):
        
        if step not in ('build', 'install'):
            return

        makefile = find_in_tree(pkg.build_path, 'Makefile')
        configure = find_in_tree(pkg.build_path, 'configure') if step == 'build' else None
        configure_ac = find_in_tree(pkg.build_path, 'configure.ac') if step == 'build' else None

        # We generally provide 'install' via get_next, but if you specify   
        # --build-sh it will come looking here, and so we must redo that
        # logic.
        if step == 'install':
            if makefile:
                # HACK: I was too lazy too refactor the logic for --make-install,
                # so I just use this API.
                return cls(pkg, (None, None, makefile)).get_next(step)
            else:
                return

        # Warn about both autoconf conflict states.
        if configure_ac and not pkg.autoconf:
            log.warning('autoconf detected, but --autoconf flag is not set on package')
        if configure and pkg.autoconf:
            log.warning('--autoconf flag is set on package but ./configure was found')

        # Only return with configure.ac iff the user set --autoconf
        if (configure_ac and pkg.autoconf) or configure or makefile:
            return cls(pkg, (configure_ac, configure, makefile))
예제 #2
0
    def factory(cls, step, pkg):

        if step != 'inspect':
            return

        setup_path = find_in_tree(pkg.build_path, 'setup.py')
        dist_path = find_in_tree(pkg.build_path, '*.dist-info', 'dir')

        if setup_path or dist_path:
            return cls((setup_path, dist_path))
예제 #3
0
    def factory(cls, step, pkg):

        if step != 'inspect':
            return

        setup_path = find_in_tree(pkg.build_path, 'setup.py')
        egg_path = find_in_tree(pkg.build_path,
                                'EGG-INFO', 'dir') or find_in_tree(
                                    pkg.build_path, '*.egg-info', 'dir')
        dist_path = find_in_tree(pkg.build_path, '*.dist-info', 'dir')

        if setup_path or egg_path or dist_path:
            return cls(pkg, (setup_path, egg_path, dist_path))
예제 #4
0
    def factory(cls, step, pkg):

        for file_step, file_name, attr_name in [
            ('inspect', 'vee-requirements.txt', 'requirements_txt'),
            ('build', 'vee-build.sh', 'build_sh'),
            ('install', 'vee-install.sh', 'install_sh'),
            ('develop', 'vee-develop.sh', 'develop_sh'),
        ]:
            if step == file_step:

                # Look for the attribute on the package:
                url = getattr(pkg, attr_name, None)
                if url:

                    # Allow these scripts to be relative to the repository
                    if url.startswith('repo:'):
                        rel_path = url[5:].lstrip('/')
                        try:
                            root = pkg.set.env.repo.work_tree
                        except AttributeError:
                            raise RuntimeError(
                                'relative %s outside of environment' %
                                attr_name)
                        path = os.path.join(root, rel_path)

                    # ... or be searched for
                    elif '/' not in url:
                        path = find_in_tree(pkg.build_path, url)

                    # ... or just be relative (which can be forced via './something')
                    else:
                        path = os.path.abspath(pkg.build_path, url)

                    if not path:
                        raise ValueError('%s cannot be found for %s' %
                                         (attr_name, url))
                    if not os.path.exists(path):
                        raise ValueError('%s does not exist at %s' %
                                         (attr_name, path or url))

                # Search the package tree for the generic name.
                else:
                    path = find_in_tree(pkg.build_path, file_name)

                # Build the step.
                if path:
                    self = cls(pkg)
                    setattr(self, attr_name, path)
                    return self
예제 #5
0
    def develop(self, pkg):

        log.info(style_note('Building scripts'))
        cmd = ['vee_develop']
        if call_setup_py(self.setup_path, cmd):
            raise RuntimeError('Could not build scripts')

        egg_info = find_in_tree(os.path.dirname(self.setup_path), '*.egg-info',
                                'dir')
        if not egg_info:
            raise RuntimeError('Could not find built egg-info')

        dirs_to_link = set()
        for line in open(os.path.join(egg_info, 'top_level.txt')):
            dirs_to_link.add(os.path.dirname(line.strip()))
        for name in sorted(dirs_to_link):
            log.info(style_note("Adding ./%s to $PYTHONPATH" % name))
            pkg.environ['PYTHONPATH'] = join_env_path(
                './' + name, pkg.environ.get('PYTHONPATH', '@'))

        scripts = os.path.join(os.path.dirname(self.setup_path), 'build',
                               'scripts')
        if os.path.exists(scripts):
            log.info(style_note("Adding ./build/scripts to $PATH"))
            pkg.environ['PATH'] = join_env_path('./build/scripts',
                                                pkg.environ.get('PATH', '@'))
예제 #6
0
    def inspect(self):

        pkg = self.package

        if self.setup_path and not self.egg_path:

            log.info(style_note('Building Python egg-info'))
            res = call_setup_py(self.setup_path, ['egg_info'],
                                env=pkg.fresh_environ(),
                                indent=True,
                                verbosity=1)
            if res:
                raise RuntimeError('Could not build Python package')

            self.egg_path = find_in_tree(pkg.build_path, '*.egg-info', 'dir')
            if not self.egg_path:
                log.warning('Could not find newly created *.egg-info')

        if self.egg_path:
            requires_path = os.path.join(self.egg_path, 'requires.txt')
            if os.path.exists(requires_path):
                for line in open(requires_path, 'rb'):
                    line = line.strip()
                    if not line:
                        continue
                    if line.startswith('['):
                        break
                    name = re.split('\W', line)[0].lower()
                    log.debug('%s depends on %s' % (pkg.name, name))
                    pkg.dependencies.append(
                        Package(name=name, url='pypi:%s' % name))
예제 #7
0
    def develop(self):
        pkg = self.package

        log.info(style_note('Building scripts'))
        cmd = [
            'build_scripts',
            '-e',
            '/usr/bin/env VEE=%s VEE_PYTHON=%s dev python' %
            (os.environ.get("VEE", ''), os.environ.get('VEE_PYTHON', '')),
            'install_scripts',
            '-d',
            'build/scripts',
        ]
        if call_setup_py(self.setup_path, cmd):
            raise RuntimeError('Could not build scripts')

        egg_info = find_in_tree(os.path.dirname(self.setup_path), '*.egg-info',
                                'dir')
        if not egg_info:
            raise RuntimeError('Could not find built egg-info')

        dirs_to_link = set()
        for line in open(os.path.join(egg_info, 'top_level.txt')):
            dirs_to_link.add(os.path.dirname(line.strip()))
        for name in sorted(dirs_to_link):
            log.info(style_note("Adding ./%s to $PYTHONPATH" % name))
            pkg.environ['PYTHONPATH'] = join_env_path(
                './' + name, pkg.environ.get('PYTHONPATH', '@'))

        scripts = os.path.join(os.path.dirname(self.setup_path), 'build',
                               'scripts')
        if os.path.exists(scripts):
            log.info(style_note("Adding ./build/scripts to $PATH"))
            pkg.environ['PATH'] = join_env_path('./build/scripts',
                                                pkg.environ.get('PATH', '@'))
예제 #8
0
파일: make.py 프로젝트: westernx/vee
    def build(self):

        pkg = self.package
        env = None

        if self.configure_ac_path and not self.configure_path:

            bootstrap = os.path.join(os.path.dirname(self.configure_ac_path), 'bootstrap')
            if os.path.exists(bootstrap):
                log.info(style_note('./bootstrap', '(autoreconf)'))
                cmd = ['./bootstrap']
            else:
                log.info(style_note('autoreconf'))
                cmd = ['autoreconf', '--install', '--force']

            env = env or pkg.fresh_environ()
            call(cmd, cwd=os.path.dirname(self.configure_ac_path), env=env)
            pkg.build_subdir = os.path.dirname(self.configure_ac_path)

            # Need to look for it again.
            self.configure_path = self.configure_path or find_in_tree(pkg.build_path, 'configure')

        if self.configure_path:

            log.info(style_note('./configure'))
            pkg._assert_paths(install=True)

            cmd = ['./configure', '--prefix', pkg.install_path]
            cmd.extend(pkg.config)
            env = env or pkg.fresh_environ()
            call(cmd, cwd=os.path.dirname(self.configure_path), env=env)

            pkg.build_subdir = os.path.dirname(self.configure_path)

        # Need to look for it again.
        self.makefile_path = self.makefile_path or find_in_tree(pkg.build_path, 'Makefile')

        if self.makefile_path:

            log.info(style_note('make'))

            env = env or pkg.fresh_environ()
            call(['make', '-j4'], cwd=os.path.dirname(self.makefile_path), env=env)

            pkg.build_subdir = os.path.dirname(self.makefile_path)