Пример #1
0
    def __run_sip(self, ext, sip_temp):
        """Run sip.
        """

        # clean
        if os.path.isdir(sip_temp):
            shutil.rmtree(sip_temp, 1)
        self.mkpath(sip_temp)

        # prepare and run sip
        sip_file_dirs = copy.copy(self.sip_file_dirs)
        sip_t_tags = copy.copy(self.sip_t_tags)
        sip_x_features = copy.copy(self.sip_x_features)
        for config in ext.config_jobs:
            for file_dir in get_config(config).get('sip_file_dirs', []):
                if file_dir not in sip_file_dirs:
                    sip_file_dirs.append(file_dir)
            for t_tag in get_config(config).get('sip_t_tags', []):
                if t_tag not in sip_t_tags:
                    sip_t_tags.append(t_tag)
            for x_feature in get_config(config).get('sip_x_features', []):
                if x_feature not in sip_x_features:
                    sip_x_features.append(x_feature)
        # replace '\\' with '/' because MSVC chokes on Windows path separators.
        sip_file_dirs = [item.replace('\\', '/') for item in sip_file_dirs]
        cmd = ([self.sip_program] + self.__flag_list('-t', sip_t_tags) +
               self.__flag_list('-x', sip_x_features) + ['-c', sip_temp] +
               self.__flag_list('-I', sip_file_dirs) + [ext.sip_module])
        self.spawn(cmd)
        # apply an eventual patch
        ext.sip_post_hook(sip_temp, ext.tag)
        if self.sip_version < 0x040000:
            # copy the wrapper
            self.copy_file(os.path.join(sip_temp, '%s.py' % ext.tag),
                           os.path.join(ext.path, '%s.py' % ext.tag))
Пример #2
0
 def run(self):
     tag = '_Qt%s%s%s' % tuple(
         get_config('qt').get('qt_version_str').split('.'))
     name = self.distribution.metadata.name
     if -1 == name.find(tag):
         self.distribution.metadata.name = name + tag
     old_bdist_rpm.run(self)
Пример #3
0
 def run(self):
     tag = '_Qt%s%s%s' % tuple(
         get_config('qt').get('qt_version_str').split('.'))
     name = self.distribution.metadata.name
     if -1 == name.find(tag):
         self.distribution.metadata.name = name + tag
     old_bdist_rpm.run(self)
Пример #4
0
 def finalize_options(self):
     self.set_undefined_options('build', ('build_temp', 'build_temp'),
                                ('force', 'force'))
     self.extensions = self.distribution.ext_modules
     if not self.moc_program:
         self.moc_program = get_config('qt').get('make').get('MOC')
     # FIXME
     assert self.moc_program
Пример #5
0
 def finalize_options(self):
     self.set_undefined_options('build',
                                ('build_temp', 'build_temp'),
                                ('force', 'force'))
     self.extensions = self.distribution.ext_modules
     if not self.moc_program:
         self.moc_program = get_config('qt').get('make').get('MOC')
     # FIXME
     assert self.moc_program
Пример #6
0
    def __run_sip(self, ext, sip_temp):
        """Run sip.
        """

        # clean
        if os.path.isdir(sip_temp):
            shutil.rmtree(sip_temp, 1)
        self.mkpath(sip_temp)

        # prepare and run sip
        sip_file_dirs = copy.copy(self.sip_file_dirs)
        sip_t_tags = copy.copy(self.sip_t_tags)
        sip_x_features = copy.copy(self.sip_x_features)
        for config in ext.config_jobs:
            for file_dir in get_config(config).get('sip_file_dirs', []):
                if file_dir not in sip_file_dirs:
                    sip_file_dirs.append(file_dir)
            for t_tag in get_config(config).get('sip_t_tags', []):
                if t_tag not in sip_t_tags:
                    sip_t_tags.append(t_tag)
            for x_feature in get_config(config).get('sip_x_features', []):
                if x_feature not in sip_x_features:
                    sip_x_features.append(x_feature)
        # replace '\\' with '/' because MSVC chokes on Windows path separators.
        sip_file_dirs = [item.replace('\\', '/') for item in sip_file_dirs] 
        cmd = (
            [self.sip_program]
            + self.__flag_list('-t', sip_t_tags)
            + self.__flag_list('-x', sip_x_features)
            + ['-c', sip_temp]
            + self.__flag_list('-I', sip_file_dirs)
            + [ext.sip_module]
            )
        self.spawn(cmd)
        # apply an eventual patch
        ext.sip_post_hook(sip_temp, ext.tag)
        if self.sip_version < 0x040000:
            # copy the wrapper
            self.copy_file(os.path.join(sip_temp, '%s.py' % ext.tag),
                           os.path.join(ext.path, '%s.py' % ext.tag))
Пример #7
0
    def finalize_options(self):
        self.set_undefined_options('build', ('build_temp', 'build_temp'),
                                   ('force', 'force'))

        self.extensions = self.distribution.ext_modules

        if not self.sip_program:
            self.sip_program = get_config('sip').get('sip_program')
        assert self.sip_program

        self.sip_version = get_config('sip').get('sip_version')
        assert self.sip_version

        self.sip_file_dirs = self.sip_file_dirs or []
        if self.sip_file_dirs:
            self.sip_file_dirs = self.sip_file_dirs.split(os.pathsep)

        self.ensure_string_list('sip_t_tags')
        self.sip_t_tags = self.sip_t_tags or []

        self.ensure_string_list('sip_x_features')
        self.sip_x_features = self.sip_x_features or []
Пример #8
0
    def finalize_options(self):
        self.set_undefined_options('build',
                                   ('build_temp', 'build_temp'),
                                   ('force', 'force'))

        self.extensions = self.distribution.ext_modules
        
        if not self.sip_program:
            self.sip_program = get_config('sip').get('sip_program')
        assert self.sip_program

        self.sip_version = get_config('sip').get('sip_version')
        assert self.sip_version

        self.sip_file_dirs = self.sip_file_dirs or []
        if self.sip_file_dirs:
            self.sip_file_dirs = self.sip_file_dirs.split(os.pathsep)

        self.ensure_string_list('sip_t_tags')
        self.sip_t_tags = self.sip_t_tags or []

        self.ensure_string_list('sip_x_features')
        self.sip_x_features = self.sip_x_features or []
Пример #9
0
    def build_extensions(self):

        # First, sanity-check the 'extensions' list
        self.check_extensions_list(self.extensions)

        self.qt_compiler = new_compiler(verbose=self.verbose, dry_run=self.dry_run, force=self.force)

        customize_qt_compiler(
            self.qt_compiler,
            get_config("qt").get("make"),
            get_config("qt").get("type"),
            get_config("ccache").get("ccache_program"),
        )

        if self.include_dirs is not None:
            self.qt_compiler.set_include_dirs(self.include_dirs)
        if self.define is not None:
            # 'define' option is a list of (name,value) tuples
            for (name, value) in self.define:
                self.qt_compiler.define_macro(name, value)
        if self.undef is not None:
            for macro in self.undef:
                self.qt_compiler.undefine_macro(macro)
        if self.libraries is not None:
            self.qt_compiler.set_libraries(self.libraries)
        if self.library_dirs is not None:
            self.qt_compiler.set_library_dirs(self.library_dirs)
        if self.rpath is not None:
            self.qt_compiler.set_runtime_library_dirs(self.rpath)
        if self.link_objects is not None:
            self.qt_compiler.set_link_objects(self.link_objects)

        for ext in self.extensions:
            if "qt" in ext.config_jobs:
                self.build_pyqt_extension(ext)
            else:
                self.build_extension(ext)
Пример #10
0
    def build_extensions(self):

        # First, sanity-check the 'extensions' list
        self.check_extensions_list(self.extensions)

        self.qt_compiler = new_compiler(verbose=self.verbose,
                                        dry_run=self.dry_run,
                                        force=self.force)

        customize_qt_compiler(self.qt_compiler,
                              get_config('qt').get('make'),
                              get_config('qt').get('type'),
                              get_config('ccache').get('ccache_program'))

        if self.include_dirs is not None:
            self.qt_compiler.set_include_dirs(self.include_dirs)
        if self.define is not None:
            # 'define' option is a list of (name,value) tuples
            for (name, value) in self.define:
                self.qt_compiler.define_macro(name, value)
        if self.undef is not None:
            for macro in self.undef:
                self.qt_compiler.undefine_macro(macro)
        if self.libraries is not None:
            self.qt_compiler.set_libraries(self.libraries)
        if self.library_dirs is not None:
            self.qt_compiler.set_library_dirs(self.library_dirs)
        if self.rpath is not None:
            self.qt_compiler.set_runtime_library_dirs(self.rpath)
        if self.link_objects is not None:
            self.qt_compiler.set_link_objects(self.link_objects)

        for ext in self.extensions:
            if 'qt' in ext.config_jobs:
                self.build_pyqt_extension(ext)
            else:
                self.build_extension(ext)
Пример #11
0
 def configure(self, ext):
     for config_job in ext.config_jobs:
         info = get_config(config_job)
         for key in [
             "include_dirs",
             "define_macros",
             "undef_macros",
             "library_dirs",
             "libraries",
             "runtime_library_dirs",
             "extra_objects",
             "extra_compile_args",
             "extra_link_args",
             "export_symbols",
         ]:
             for item in info.get(key, []):
                 if item not in getattr(ext, key):
                     getattr(ext, key).append(item)
Пример #12
0
 def configure(self, ext):
     for config_job in ext.config_jobs:
         info = get_config(config_job)
         for key in [
                 'include_dirs',
                 'define_macros',
                 'undef_macros',
                 'library_dirs',
                 'libraries',
                 'runtime_library_dirs',
                 'extra_objects',
                 'extra_compile_args',
                 'extra_link_args',
                 'export_symbols',
         ]:
             for item in info.get(key, []):
                 if item not in getattr(ext, key):
                     getattr(ext, key).append(item)
Пример #13
0
    def __init__(
        self,
        name,
        sources,
        ## the new sip and moc related stuff
        sip_module=None,
        sip_file_dirs=None,
        sip_post_hook=None,
        moc_sources=None,
        config_jobs=None,
        ## old stuff
        include_dirs=None,
        define_macros=None,
        undef_macros=None,
        library_dirs=None,
        libraries=None,
        runtime_library_dirs=None,
        extra_objects=None,
        extra_compile_args=None,
        extra_link_args=None,
        export_symbols=None,
    ):

        OldExtension.__init__(self, name, sources, include_dirs, define_macros,
                              undef_macros, library_dirs, libraries,
                              runtime_library_dirs, extra_objects,
                              extra_compile_args, extra_link_args,
                              export_symbols)

        self.sip_module = sip_module or ''
        self.sip_file_dirs = sip_file_dirs or []
        self.sip_post_hook = sip_post_hook or (lambda directory, name: None)
        self.moc_sources = moc_sources or []
        self.config_jobs = config_jobs or []

        if self.sip_module:
            self.sip_sources = [self.sip_module]
            sip_file_dir = os.path.dirname(self.sip_module)
            if sip_file_dir and not sip_file_dir in self.sip_file_dirs:
                self.sip_file_dirs.insert(0, sip_file_dir)
            # hack to make the old style sip modules work as libraries on Posix
            if get_config('sip').get('sip_version') < 0x040000:
                make_info = get_config('qt').get('make')
                lflags_soname = make_info.get('LFLAGS_SONAME')
                if lflags_soname:
                    extension_shlib = make_info.get('EXTENSION_SHLIB', '.so')
                    self.extra_link_args.append(lflags_soname +
                                                self.name.split('.')[-1] +
                                                extension_shlib)
        else:
            self.sip_sources = []

        # + check if all hand written C/C++ sources exist
        for source in self.sources:
            if not os.path.exists(source):
                raise DistutilsFileError, (
                    "<sources> contains a missing file '%s'." % source)

        # + check if all header files to be processed by moc exist
        for source in self.moc_sources:
            if not os.path.exists(source):
                raise DistutilsFileError, (
                    "<moc_sources> contains a missing file '%s'." % source)

        # pyqt_distutils.core.setup plugs "package info" into Distribution
        self.path = self.name.split('.')
        assert len(self.path) >= 2  # FIXME: accept only *real* packages
        package = '.'.join(self.path[0:-1])
        self.path = apply(os.path.join, self.path[0:-1])
        self.packages = [package]
        self.package_dir = {package: package}

        # parse information from the sip module file
        # + find the sip module name
        # + find all sip sources: the sip module and files included by it
        self.tag = ''
        if self.sip_module:
            self.tag = get_sip_module_tag(self.sip_module)
            self.sip_sources = get_sip_includes(self.sip_module,
                                                self.sip_sources)
Пример #14
0
    def __init__(
        self,
        name,
        sources,
        ## the new sip and moc related stuff
        sip_module=None,
        sip_file_dirs=None,
        sip_post_hook=None,
        moc_sources=None,
        config_jobs=None,
        ## old stuff
        include_dirs=None,
        define_macros=None,
        undef_macros=None,
        library_dirs=None,
        libraries=None,
        runtime_library_dirs=None,
        extra_objects=None,
        extra_compile_args=None,
        extra_link_args=None,
        export_symbols=None,
        ):

        OldExtension.__init__(
            self,
            name,
            sources,
            include_dirs,
            define_macros,
            undef_macros,
            library_dirs,
            libraries,
            runtime_library_dirs,
            extra_objects,
            extra_compile_args,
            extra_link_args,
            export_symbols
            )

        self.sip_module = sip_module or ''
        self.sip_file_dirs = sip_file_dirs or []
        self.sip_post_hook = sip_post_hook or (lambda directory, name: None)
        self.moc_sources = moc_sources or []
        self.config_jobs = config_jobs or []

        if self.sip_module:
            self.sip_sources = [self.sip_module]
            sip_file_dir = os.path.dirname(self.sip_module)
            if sip_file_dir and not sip_file_dir in self.sip_file_dirs:
                self.sip_file_dirs.insert(0, sip_file_dir)
            # hack to make the old style sip modules work as libraries on Posix
            if get_config('sip').get('sip_version') < 0x040000:
                make_info = get_config('qt').get('make')
                lflags_soname = make_info.get('LFLAGS_SONAME')
                if lflags_soname:
                    extension_shlib = make_info.get('EXTENSION_SHLIB', '.so')
                    self.extra_link_args.append(lflags_soname
                                                + self.name.split('.')[-1]
                                                + extension_shlib)
        else:
            self.sip_sources = []
            
        # + check if all hand written C/C++ sources exist
        for source in self.sources:
            if not os.path.exists(source):
                raise DistutilsFileError, (
                    "<sources> contains a missing file '%s'." % source
                    )

        # + check if all header files to be processed by moc exist
        for source in self.moc_sources:
            if not os.path.exists(source):
                raise DistutilsFileError, (
                    "<moc_sources> contains a missing file '%s'." % source
                    )

        # pyqt_distutils.core.setup plugs "package info" into Distribution 
        self.path = self.name.split('.')
        assert len(self.path) >= 2 # FIXME: accept only *real* packages
        package = '.'.join(self.path[0:-1])
        self.path = apply(os.path.join, self.path[0:-1])
        self.packages = [package]
        self.package_dir = {package: package}

        # parse information from the sip module file
        # + find the sip module name
        # + find all sip sources: the sip module and files included by it
        self.tag = ''
        if self.sip_module:
            self.tag = get_sip_module_tag(self.sip_module)
            self.sip_sources = get_sip_includes(
                self.sip_module, self.sip_sources)