コード例 #1
0
ファイル: dist.py プロジェクト: jmavila/python
    def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands',command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
コード例 #2
0
ファイル: dist.py プロジェクト: goltzbertold/bertoldgoltz
    def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands', command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
コード例 #3
0
    def get_command_class(self, command):
        """
        Extends Distribution.get_command_class() to search 'command_mapping'
        for modules that implement that requested command.
        """
        # Try user defined classes first (and already loaded classes)
        klass = self.cmdclass.get(command)
        if klass:
            return klass

        if command in self.command_aliases:
            command = self.command_aliases[command]

        base_name = self.command_mapping.get(command)
        if base_name is None:
            return Distribution.get_command_class(self, command)

        command_package = 'Ft.Lib.DistExt'
        module_name = command_package + '.' + base_name
        klass_name = base_name
        try:
            module = __import__(module_name, {}, {}, [klass_name])
        except ImportError:
            # If the module exists but is just broken, re-raise the existing
            # exception as this is (most likely) a developer error.
            if sys.exc_info()[-1].tb_next is not None:
                raise
            raise DistutilsModuleError(
                "invalid command '%s' (no module named '%s')" %
                (command, module_name))

        try:
            klass = getattr(module, klass_name)
        except AttributeError:
            raise DistutilsModuleError(
                "invalid command '%s' (no class '%s' in module '%s')" %
                (command, klass_name, module_name))

        # Make sure that the command provides the proper command name
        try:
            if command != klass.command_name:
                raise AttributeError('command_name')
        except AttributeError:
            raise DistutilsClassError(
                "command class %s must define 'command_name' as %r" %
                (klass, command))

        self.cmdclass[command] = klass
        return klass
コード例 #4
0
ファイル: Dist.py プロジェクト: H1d3r/binary_blobs
    def get_command_class(self, command):
        """
        Extends Distribution.get_command_class() to search 'command_mapping'
        for modules that implement that requested command.
        """
        # Try user defined classes first (and already loaded classes)
        klass = self.cmdclass.get(command)
        if klass:
            return klass

        if command in self.command_aliases:
            command = self.command_aliases[command]

        base_name = self.command_mapping.get(command)
        if base_name is None:
            return Distribution.get_command_class(self, command)

        command_package = 'Ft.Lib.DistExt'
        module_name = command_package + '.' + base_name
        klass_name = base_name
        try:
            module = __import__(module_name, {}, {}, [klass_name])
        except ImportError:
            # If the module exists but is just broken, re-raise the existing
            # exception as this is (most likely) a developer error.
            if sys.exc_info()[-1].tb_next is not None:
                raise
            raise DistutilsModuleError(
                "invalid command '%s' (no module named '%s')" %
                (command, module_name))

        try:
            klass = getattr(module, klass_name)
        except AttributeError:
            raise DistutilsModuleError(
                "invalid command '%s' (no class '%s' in module '%s')" %
                (command, klass_name, module_name))

        # Make sure that the command provides the proper command name
        try:
            if command != klass.command_name:
                raise AttributeError('command_name')
        except AttributeError:
            raise DistutilsClassError(
                "command class %s must define 'command_name' as %r" %
                (klass, command))

        self.cmdclass[command] = klass
        return klass
コード例 #5
0
        for name,feature in self.features.items():
            if not self.feature_is_included(name):
                feature.exclude_from(self)
                self._set_feature(name,0)

    def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands',command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)

    def print_commands(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
<<<<<<< HEAD
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
=======
                cmdclass = ep.load(False) # don't require extras, we're not running
>>>>>>> e4baf504ede925f4f1e07d823c9b20b3d0dbe14c
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.print_commands(self)

    def _set_feature(self,name,status):
        """Set feature's inclusion status"""