• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python misc_util.appendpath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中numpy.distutils.misc_util.appendpath函数的典型用法代码示例。如果您正苦于以下问题:Python appendpath函数的具体用法?Python appendpath怎么用?Python appendpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了appendpath函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: check_2

 def check_2(self):
     assert_equal(appendpath('prefix/sub','name'),
                  join('prefix','sub','name'))
     assert_equal(appendpath('prefix/sub','sup/name'),
                  join('prefix','sub','sup','name'))
     assert_equal(appendpath('/prefix/sub','/prefix/name'),
                  ajoin('prefix','sub','name'))
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:7,代码来源:test_misc_util.py


示例2: test_3

 def test_3(self):
     assert_equal(appendpath('/prefix/sub','/prefix/sup/name'),
                  ajoin('prefix','sub','sup','name'))
     assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'),
                  ajoin('prefix','sub','sub2','sup','sup2','name'))
     assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'),
                  ajoin('prefix','sub','sub2','sup','name'))
开发者ID:wrbrooks,项目名称:VB3,代码行数:7,代码来源:test_misc_util.py


示例3: test_3

 def test_3(self):
     assert_equal(appendpath("/prefix/sub", "/prefix/sup/name"), ajoin("prefix", "sub", "sup", "name"))
     assert_equal(
         appendpath("/prefix/sub/sub2", "/prefix/sup/sup2/name"),
         ajoin("prefix", "sub", "sub2", "sup", "sup2", "name"),
     )
     assert_equal(
         appendpath("/prefix/sub/sub2", "/prefix/sub/sup/name"), ajoin("prefix", "sub", "sub2", "sup", "name")
     )
开发者ID:sowhatwchen,项目名称:numpy,代码行数:9,代码来源:test_misc_util.py


示例4: generate_a_pyrex_source

    def generate_a_pyrex_source(self, base, ext_name, source, extension):
        if self.inplace or not have_pyrex():
            target_dir = os.path.dirname(base)
        else:
            target_dir = appendpath(self.build_src, os.path.dirname(base))
        target_file = os.path.join(target_dir, ext_name + ".c")
        depends = [source] + extension.depends
        if self.force or newer_group(depends, target_file, "newer"):
            if have_pyrex():
                import Pyrex.Compiler.Main

                log.info("pyrexc:> %s" % (target_file))
                self.mkpath(target_dir)
                options = Pyrex.Compiler.Main.CompilationOptions(
                    defaults=Pyrex.Compiler.Main.default_options,
                    include_path=extension.include_dirs,
                    output_file=target_file,
                )
                pyrex_result = Pyrex.Compiler.Main.compile(source, options=options)
                if pyrex_result.num_errors != 0:
                    raise DistutilsError("%d errors while compiling %r with Pyrex" % (pyrex_result.num_errors, source))
            elif os.path.isfile(target_file):
                log.warn(
                    "Pyrex required for compiling %r but not available," " using old target %r" % (source, target_file)
                )
            else:
                raise DistutilsError("Pyrex required for compiling %r" " but notavailable" % (source,))
        return target_file
开发者ID:themiwi,项目名称:numpy,代码行数:28,代码来源:build_src.py


示例5: template_sources

 def template_sources(self, sources, extension):
     new_sources = []
     if is_sequence(extension):
         depends = extension[1].get('depends')
         include_dirs = extension[1].get('include_dirs')
     else:
         depends = extension.depends
         include_dirs = extension.include_dirs
     for source in sources:
         (base, ext) = os.path.splitext(source)
         if ext == '.src':  # Template file
             if self.inplace:
                 target_dir = os.path.dirname(base)
             else:
                 target_dir = appendpath(self.build_src, os.path.dirname(base))
             self.mkpath(target_dir)
             target_file = os.path.join(target_dir, os.path.basename(base))
             if (self.force or newer_group([source] + depends, target_file)):
                 if _f_pyf_ext_match(base):
                     log.info("from_template:> %s" % (target_file))
                     outstr = process_f_file(source)
                 else:
                     log.info("conv_template:> %s" % (target_file))
                     outstr = process_c_file(source)
                 with open(target_file, 'w') as fid:
                     fid.write(outstr)
             if _header_ext_match(target_file):
                 d = os.path.dirname(target_file)
                 if d not in include_dirs:
                     log.info("  adding '%s' to include_dirs." % (d))
                     include_dirs.append(d)
             new_sources.append(target_file)
         else:
             new_sources.append(source)
     return new_sources
开发者ID:anntzer,项目名称:numpy,代码行数:35,代码来源:build_src.py


示例6: generate_a_pyrex_source

    def generate_a_pyrex_source(self, base, ext_name, source, extension):
        ''' Monkey patch for numpy build_src.build_src method

        Uses Cython instead of Pyrex, iff source contains 'pymor'

        Assumes Cython is present
        '''
        if 'pymor' not in source:
            return _orig_generate_a_pyrex_source(self, base, ext_name, source, extension)

        if self.inplace:
            target_dir = dirname(base)
        else:
            target_dir = appendpath(self.build_src, dirname(base))
        target_file = pjoin(target_dir, ext_name + '.c')
        depends = [source] + extension.depends
        if self.force or newer_group(depends, target_file, 'newer'):
            import Cython.Compiler.Main
            log.info("cythonc:> %s" % (target_file))
            self.mkpath(target_dir)
            options = Cython.Compiler.Main.CompilationOptions(
                defaults=Cython.Compiler.Main.default_options,
                include_path=extension.include_dirs,
                output_file=target_file)
            cython_result = Cython.Compiler.Main.compile(source, options=options)
            if cython_result.num_errors != 0:
                raise DistutilsError("%d errors while compiling %r with Cython"
                                     % (cython_result.num_errors, source))
        return target_file
开发者ID:pymor,项目名称:pymor,代码行数:29,代码来源:setup.py


示例7: generate_a_cython_source

def generate_a_cython_source(self, base, ext_name, source, extension):
        if self.inplace or not have_cython():
            target_dir = os.path.dirname(base)
        else:
            target_dir = appendpath(self.build_src, os.path.dirname(base))
        target_file = os.path.join(target_dir, ext_name + '.c')
        depends = [source] + extension.depends
        if self.force or newer_group(depends, target_file, 'newer'):
            if have_cython():
                import Cython.Compiler.Main
                log.info("cythonc:> %s: %s " % (target_dir, target_file))
                log.info("cwd %s " % (os.getcwd()))
                self.mkpath(target_dir)
                options = Cython.Compiler.Main.CompilationOptions(
                    defaults=Cython.Compiler.Main.default_options,
                    include_path=extension.include_dirs,
                    output_file=target_file
                    )
                #log.info('\n'.join([s + ' ' + str(getattr(options, s)) for s in dir(options)]))
                # avoid calling compile_single, because it will give wrong module names.
                cython_result = Cython.Compiler.Main.compile([source],
                                                           options=options)
                if cython_result.num_errors != 0:
                    raise DistutilsError("%d errors while compiling %r with Cython" \
                          % (cython_result.num_errors, source))
            elif os.path.isfile(target_file):
                log.warn("Cython required for compiling %r but not available,"\
                         " using old target %r"\
                         % (source, target_file))
            else:
                raise DistutilsError("Cython required for compiling %r"\
                                     " but notavailable" % (source,))
        return target_file
开发者ID:rainwoodman,项目名称:gaepsi,代码行数:33,代码来源:monkey.py


示例8: generate_a_pyrex_source

def generate_a_pyrex_source(self, base, ext_name, source, extension):
    ''' Monkey patch for numpy build_src.build_src method

    Uses Cython instead of Pyrex.

    Assumes Cython is present
    '''
    if self.inplace:
        target_dir = dirname(base)
    else:
        target_dir = appendpath(self.build_src, dirname(base))
    target_file = pjoin(target_dir, ext_name + '.c')
    depends = [source] + extension.depends
    # add distribution (package-wide) include directories, in order to
    # pick up needed .pxd files for cython compilation
    incl_dirs = extension.include_dirs[:]
    dist_incl_dirs = self.distribution.include_dirs
    if not dist_incl_dirs is None:
        incl_dirs += dist_incl_dirs
    if self.force or newer_group(depends, target_file, 'newer'):
        import Cython.Compiler.Main
        log.info("cythonc:> %s" % (target_file))
        self.mkpath(target_dir)
        options = Cython.Compiler.Main.CompilationOptions(
            defaults=Cython.Compiler.Main.default_options,
            include_path=incl_dirs,
            output_file=target_file)
        cython_result = Cython.Compiler.Main.compile(source,
                                                   options=options)
        if cython_result.num_errors != 0:
            raise DistutilsError("%d errors while compiling %r with Cython" \
                  % (cython_result.num_errors, source))
    return target_file
开发者ID:151706061,项目名称:connectomeviewer,代码行数:33,代码来源:build_helpers.py


示例9: generate_a_pyrex_source

def generate_a_pyrex_source(self, base, ext_name, source, extension):
    '''
    Monkey patch for numpy build_src.build_src method

    Uses Cython instead of Pyrex.
    '''
    good_cython = have_good_cython()
    if self.inplace or not good_cython:
        target_dir = dirname(base)
    else:
        target_dir = appendpath(self.build_src, dirname(base))
    target_file = pjoin(target_dir, ext_name + '.c')
    depends = [source] + extension.depends
    sources_changed = newer_group(depends, target_file, 'newer')
    if self.force or sources_changed:
        if good_cython:
            # add distribution (package-wide) include directories, in order
            # to pick up needed .pxd files for cython compilation
            incl_dirs = extension.include_dirs[:]
            dist_incl_dirs = self.distribution.include_dirs
            if not dist_incl_dirs is None:
                incl_dirs += dist_incl_dirs
            import Cython.Compiler.Main
            log.info("cythonc:> %s" % (target_file))
            self.mkpath(target_dir)
            options = Cython.Compiler.Main.CompilationOptions(
                defaults=Cython.Compiler.Main.default_options,
                include_path=incl_dirs,
                output_file=target_file)
            cython_result = Cython.Compiler.Main.compile(source,
                                                       options=options)
            if cython_result.num_errors != 0:
                raise DistutilsError("%d errors while compiling "
                                     "%r with Cython"
                                     % (cython_result.num_errors, source))
        elif sources_changed and os.path.isfile(target_file):
            raise DistutilsError("Cython >=%s required for compiling %r"
                                 " because sources (%s) have changed" %
                                 (CYTHON_MIN_VERSION, source,
                                  ','.join(depends)))
        else:
            raise DistutilsError("Cython >=%s required for compiling %r"
                                 " but not available" %
                                 (CYTHON_MIN_VERSION, source))
    return target_file
开发者ID:logansorenson,项目名称:sfepy,代码行数:45,代码来源:build_helpers.py


示例10: pyrex_sources

 def pyrex_sources(self, sources, extension):
     have_pyrex = False
     try:
         import Pyrex
         have_pyrex = True
     except ImportError:
         pass
     new_sources = []
     ext_name = extension.name.split('.')[-1]
     for source in sources:
         (base, ext) = os.path.splitext(source)
         if ext == '.pyx':
             if self.inplace or not have_pyrex:
                 target_dir = os.path.dirname(base)
             else:
                 target_dir = appendpath(self.build_src, os.path.dirname(base))
             target_file = os.path.join(target_dir, ext_name + '.c')
             depends = [source] + extension.depends
             if (self.force or newer_group(depends, target_file, 'newer')):
                 if have_pyrex:
                     log.info("pyrexc:> %s" % (target_file))
                     self.mkpath(target_dir)
                     from Pyrex.Compiler import Main
                     options = Main.CompilationOptions(
                         defaults=Main.default_options,
                         output_file=target_file)
                     pyrex_result = Main.compile(source, options=options)
                     if pyrex_result.num_errors != 0:
                         raise DistutilsError,"%d errors while compiling %r with Pyrex" \
                               % (pyrex_result.num_errors, source)
                 elif os.path.isfile(target_file):
                     log.warn("Pyrex required for compiling %r but not available,"\
                              " using old target %r"\
                              % (source, target_file))
                 else:
                     raise DistutilsError,"Pyrex required for compiling %r but not available" % (source)
             new_sources.append(target_file)
         else:
             new_sources.append(source)
     return new_sources
开发者ID:radical-software,项目名称:radicalspam,代码行数:40,代码来源:build_src.py


示例11: test_1

 def test_1(self):
     assert_equal(appendpath('prefix','name'),join('prefix','name'))
     assert_equal(appendpath('/prefix','name'),ajoin('prefix','name'))
     assert_equal(appendpath('/prefix','/name'),ajoin('prefix','name'))
     assert_equal(appendpath('prefix','/name'),join('prefix','name'))
开发者ID:wrbrooks,项目名称:VB3,代码行数:5,代码来源:test_misc_util.py


示例12: test_2

 def test_2(self):
     assert_equal(appendpath("prefix/sub", "name"), join("prefix", "sub", "name"))
     assert_equal(appendpath("prefix/sub", "sup/name"), join("prefix", "sub", "sup", "name"))
     assert_equal(appendpath("/prefix/sub", "/prefix/name"), ajoin("prefix", "sub", "name"))
开发者ID:sowhatwchen,项目名称:numpy,代码行数:4,代码来源:test_misc_util.py


示例13: swig_sources

    def swig_sources(self, sources, extension):
        # Assuming SWIG 1.3.14 or later. See compatibility note in
        #   http://www.swig.org/Doc1.3/Python.html#Python_nn6

        new_sources = []
        swig_sources = []
        swig_targets = {}
        target_dirs = []
        py_files = []     # swig generated .py files
        target_ext = '.c'
        if self.swig_cpp:
            typ = 'c++'
            is_cpp = True
        else:
            typ = None
            is_cpp = False
        skip_swig = 0
        ext_name = extension.name.split('.')[-1]

        for source in sources:
            (base, ext) = os.path.splitext(source)
            if ext == '.i': # SWIG interface file
                if self.inplace:
                    target_dir = os.path.dirname(base)
                    py_target_dir = self.ext_target_dir
                else:
                    target_dir = appendpath(self.build_src, os.path.dirname(base))
                    py_target_dir = target_dir
                if os.path.isfile(source):
                    name = get_swig_modulename(source)
                    if name != ext_name[1:]:
                        raise DistutilsSetupError(
                            'mismatch of extension names: %s provides %r'
                            ' but expected %r' % (source, name, ext_name[1:]))
                    if typ is None:
                        typ = get_swig_target(source)
                        is_cpp = typ=='c++'
                        if is_cpp: target_ext = '.cpp'
                    else:
                        typ2 = get_swig_target(source)
                        if typ!=typ2:
                            log.warn('expected %r but source %r defines %r swig target' \
                                     % (typ, source, typ2))
                            if typ2=='c++':
                                log.warn('resetting swig target to c++ (some targets may have .c extension)')
                                is_cpp = True
                                target_ext = '.cpp'
                            else:
                                log.warn('assuming that %r has c++ swig target' % (source))
                    target_file = os.path.join(target_dir,'%s_wrap%s' \
                                               % (name, target_ext))
                else:
                    log.warn('  source %s does not exist: skipping swig\'ing.' \
                             % (source))
                    name = ext_name[1:]
                    skip_swig = 1
                    target_file = _find_swig_target(target_dir, name)
                    if not os.path.isfile(target_file):
                        log.warn('  target %s does not exist:\n   '\
                                 'Assuming %s_wrap.{c,cpp} was generated with '\
                                 '"build_src --inplace" command.' \
                                 % (target_file, name))
                        target_dir = os.path.dirname(base)
                        target_file = _find_swig_target(target_dir, name)
                        if not os.path.isfile(target_file):
                            raise DistutilsSetupError("%r missing" % (target_file,))
                        log.warn('   Yes! Using %r as up-to-date target.' \
                                 % (target_file))
                target_dirs.append(target_dir)
                new_sources.append(target_file)
                py_files.append(os.path.join(py_target_dir, name+'.py'))
                swig_sources.append(source)
                swig_targets[source] = new_sources[-1]
            else:
                new_sources.append(source)

        if not swig_sources:
            return new_sources

        if skip_swig:
            return new_sources + py_files

        for d in target_dirs:
            self.mkpath(d)

        swig = self.swig or self.find_swig()
        swig_cmd = [swig, "-python"]
        if is_cpp:
            swig_cmd.append('-c++')
        for d in extension.include_dirs:
            swig_cmd.append('-I'+d)
        for source in swig_sources:
            target = swig_targets[source]
            depends = [source] + extension.depends
            if self.force or newer_group(depends, target, 'newer'):
                log.info("%s: %s" % (os.path.basename(swig) \
                                     + (is_cpp and '++' or ''), source))
                self.spawn(swig_cmd + self.swig_opts \
                           + ["-o", target, '-outdir', py_target_dir, source])
            else:
#.........这里部分代码省略.........
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:101,代码来源:build_src.py


示例14: f2py_sources

    def f2py_sources(self, sources, extension):
        new_sources = []
        f2py_sources = []
        f_sources = []
        f2py_targets = {}
        target_dirs = []
        ext_name = extension.name.split('.')[-1]
        skip_f2py = 0

        for source in sources:
            (base, ext) = os.path.splitext(source)
            if ext == '.pyf': # F2PY interface file
                if self.inplace:
                    target_dir = os.path.dirname(base)
                else:
                    target_dir = appendpath(self.build_src, os.path.dirname(base))
                if os.path.isfile(source):
                    name = get_f2py_modulename(source)
                    if name != ext_name:
                        raise DistutilsSetupError('mismatch of extension names: %s '
                                                  'provides %r but expected %r' % (
                            source, name, ext_name))
                    target_file = os.path.join(target_dir,name+'module.c')
                else:
                    log.debug('  source %s does not exist: skipping f2py\'ing.' \
                              % (source))
                    name = ext_name
                    skip_f2py = 1
                    target_file = os.path.join(target_dir,name+'module.c')
                    if not os.path.isfile(target_file):
                        log.warn('  target %s does not exist:\n   '\
                                 'Assuming %smodule.c was generated with '\
                                 '"build_src --inplace" command.' \
                                 % (target_file, name))
                        target_dir = os.path.dirname(base)
                        target_file = os.path.join(target_dir,name+'module.c')
                        if not os.path.isfile(target_file):
                            raise DistutilsSetupError("%r missing" % (target_file,))
                        log.info('   Yes! Using %r as up-to-date target.' \
                                 % (target_file))
                target_dirs.append(target_dir)
                f2py_sources.append(source)
                f2py_targets[source] = target_file
                new_sources.append(target_file)
            elif fortran_ext_match(ext):
                f_sources.append(source)
            else:
                new_sources.append(source)

        if not (f2py_sources or f_sources):
            return new_sources

        map(self.mkpath, target_dirs)

        f2py_options = extension.f2py_options + self.f2py_opts

        if self.distribution.libraries:
            for name,build_info in self.distribution.libraries:
                if name in extension.libraries:
                    f2py_options.extend(build_info.get('f2py_options',[]))

        log.info("f2py options: %s" % (f2py_options))

        if f2py_sources:
            if len(f2py_sources) != 1:
                raise DistutilsSetupError(
                    'only one .pyf file is allowed per extension module but got'\
                    ' more: %r' % (f2py_sources,))
            source = f2py_sources[0]
            target_file = f2py_targets[source]
            target_dir = os.path.dirname(target_file) or '.'
            depends = [source] + extension.depends
            if (self.force or newer_group(depends, target_file,'newer')) \
                   and not skip_f2py:
                log.info("f2py: %s" % (source))
                import numpy.f2py as f2py2e
                f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])
            else:
                log.debug("  skipping '%s' f2py interface (up-to-date)" % (source))
        else:
            #XXX TODO: --inplace support for sdist command
            if is_sequence(extension):
                name = extension[0]
            else: name = extension.name
            target_dir = os.path.join(*([self.build_src]\
                                        +name.split('.')[:-1]))
            target_file = os.path.join(target_dir,ext_name + 'module.c')
            new_sources.append(target_file)
            depends = f_sources + extension.depends
            if (self.force or newer_group(depends, target_file, 'newer')) \
                   and not skip_f2py:
                import numpy.f2py as f2py2e
                log.info("f2py:> %s" % (target_file))
                self.mkpath(target_dir)
                f2py2e.run_main(f2py_options + ['--lower',
                                                '--build-dir',target_dir]+\
                                ['-m',ext_name]+f_sources)
            else:
                log.debug("  skipping f2py fortran files for '%s' (up-to-date)"\
                          % (target_file))
#.........这里部分代码省略.........
开发者ID:radical-software,项目名称:radicalspam,代码行数:101,代码来源:build_src.py


示例15: f2py_sources

    def f2py_sources(self, sources, extension):
        new_sources = []
        f2py_sources = []
        f_sources = []
        f2py_targets = {}
        target_dirs = []
        ext_name = extension.name.split(".")[-1]
        skip_f2py = 0

        for source in sources:
            (base, ext) = os.path.splitext(source)
            if ext == ".pyf":  # F2PY interface file
                if self.inplace:
                    target_dir = os.path.dirname(base)
                else:
                    target_dir = appendpath(self.build_src, os.path.dirname(base))
                if os.path.isfile(source):
                    name = get_f2py_modulename(source)
                    if name != ext_name:
                        raise DistutilsSetupError(
                            "mismatch of extension names: %s " "provides %r but expected %r" % (source, name, ext_name)
                        )
                    target_file = os.path.join(target_dir, name + "module.c")
                else:
                    log.debug("  source %s does not exist: skipping f2py'ing." % (source))
                    name = ext_name
                    skip_f2py = 1
                    target_file = os.path.join(target_dir, name + "module.c")
                    if not os.path.isfile(target_file):
                        log.warn(
                            "  target %s does not exist:\n   "
                            "Assuming %smodule.c was generated with "
                            '"build_src --inplace" command.' % (target_file, name)
                        )
                        target_dir = os.path.dirname(base)
                        target_file = os.path.join(target_dir, name + "module.c")
                        if not os.path.isfile(target_file):
                            raise DistutilsSetupError("%r missing" % (target_file,))
                        log.info("   Yes! Using %r as up-to-date target." % (target_file))
                target_dirs.append(target_dir)
                f2py_sources.append(source)
                f2py_targets[source] = target_file
                new_sources.append(target_file)
            elif fortran_ext_match(ext):
                f_sources.append(source)
            else:
                new_sources.append(source)

        if not (f2py_sources or f_sources):
            return new_sources

        for d in target_dirs:
            self.mkpath(d)

        f2py_options = extension.f2py_options + self.f2py_opts

        if self.distribution.libraries:
            for name, build_info in self.distribution.libraries:
                if name in extension.libraries:
                    f2py_options.extend(build_info.get("f2py_options", []))

        log.info("f2py options: %s" % (f2py_options))

        if f2py_sources:
            if len(f2py_sources) != 1:
                raise DistutilsSetupError(
                    "only one .pyf file is allowed per extension module but got" " more: %r" % (f2py_sources,)
                )
            source = f2py_sources[0]
            target_file = f2py_targets[source]
            target_dir = os.path.dirname(target_file) or "."
            depends = [source] + extension.depends
            if (self.force or newer_group(depends, target_file, "newer")) and not skip_f2py:
                log.info("f2py: %s" % (source))
                import numpy.f2py

                numpy.f2py.run_main(f2py_options + ["--build-dir", target_dir, source])
            else:
                log.debug("  skipping '%s' f2py interface (up-to-date)" % (source))
        else:
            # XXX TODO: --inplace support for sdist command
            if is_sequence(extension):
                name = extension[0]
            else:
                name = extension.name
            target_dir = os.path.join(*([self.build_src] + name.split(".")[:-1]))
            target_file = os.path.join(target_dir, ext_name + "module.c")
            new_sources.append(target_file)
            depends = f_sources + extension.depends
            if (self.force or newer_group(depends, target_file, "newer")) and not skip_f2py:
                log.info("f2py:> %s" % (target_file))
                self.mkpath(target_dir)
                import numpy.f2py

                numpy.f2py.run_main(
                    f2py_options + ["--lower", "--build-dir", target_dir] + ["-m", ext_name] + f_sources
                )
            else:
                log.debug("  skipping f2py fortran files for '%s' (up-to-date)" % (target_file))

#.........这里部分代码省略.........
开发者ID:themiwi,项目名称:numpy,代码行数:101,代码来源:build_src.py


示例16: swig_sources

    def swig_sources(self, sources, extension):
        # Assuming SWIG 1.3.14 or later. See compatibility note in
        #   http://www.swig.org/Doc1.3/Python.html#Python_nn6

        new_sources = []
        swig_sources = []
        swig_targets = {}
        target_dirs = []
        py_files = []  # swig generated .py files
        target_ext = ".c"
        if "-c++" in extension.swig_opts:
            typ = "c++"
            is_cpp = True
            extension.swig_opts.remove("-c++")
        elif self.swig_cpp:
            typ = "c++"
            is_cpp = True
        else:
            typ = None
            is_cpp = False
        skip_swig = 0
        ext_name = extension.name.split(".")[-1]

        for source in sources:
            (base, ext) = os.path.splitext(source)
            if ext == ".i":  # SWIG interface file
                # the code below assumes that the sources list
                # contains not more than one .i SWIG interface file
                if self.inplace:
                    target_dir = os.path.dirname(base)
                    py_target_dir = self.ext_target_dir
                else:
                    target_dir = appendpath(self.build_src, os.path.dirname(base))
                    py_target_dir = target_dir
                if os.path.isfile(source):
                    name = get_swig_modulename(source)
                    if name != ext_name[1:]:
                        raise DistutilsSetupError(
                            "mismatch of extension names: %s provides %r"
                            " but expected %r" % (source, name, ext_name[1:])
                        )
                    if typ is None:
                        typ = get_swig_target(source)
                        is_cpp = typ == "c++"
                        if is_cpp:
                            target_ext = ".cpp"
                    else:
                        typ2 = get_swig_target(source)
                        if typ2 is None:
                            log.warn("source %r does not define swig target, assuming %s swig target" % (source, typ))
                            if is_cpp:
                                target_ext = ".cpp"
                        elif typ != typ2:
                            log.warn("expected %r but source %r defines %r swig target" % (typ, source, typ2))
                            if typ2 == "c++":
                                log.warn("resetting swig target to c++ (some targets may have .c extension)")
                                is_cpp = True
                                target_ext = ".cpp"
                            else:
                                log.warn("assuming that %r has c++ swig target" % (source))
                    target_file = os.path.join(target_dir, "%s_wrap%s" % (name, target_ext))
                else:
                    log.warn("  source %s does not exist: skipping swig'ing." % (source))
                    name = ext_name[1:]
                    skip_swig = 1
                    target_file = _find_swig_target(target_dir, name)
                    if not os.path.isfile(target_file):
                        log.warn(
                            "  target %s does not exist:\n   "
                            "Assuming %s_wrap.{c,cpp} was generated with "
                            '"build_src --inplace" command.' % (target_file, name)
                        )
                        target_dir = os.path.dirname(base)
                        target_file = _find_swig_target(target_dir, name)
                        if not os.path.isfile(target_file):
                            raise DistutilsSetupError("%r missing" % (target_file,))
                        log.warn("   Yes! Using %r as up-to-date target." % (target_file))
                target_dirs.append(target_dir)
                new_sources.append(target_file)
                py_files.append(os.path.join(py_target_dir, name + ".py"))
                swig_sources.append(source)
                swig_targets[source] = new_sources[-1]
            else:
                new_sources.append(source)

        if not swig_sources:
            return new_sources

        if skip_swig:
            return new_sources + py_files

        for d in target_dirs:
            self.mkpath(d)

        swig = self.swig or self.find_swig()
        swig_cmd = [swig, "-python"] + extension.swig_opts
        if is_cpp:
            swig_cmd.append("-c++")
        for d in extension.include_dirs:
            swig_cmd.append("-I" + d)
#.........这里部分代码省略.........
开发者ID:themiwi,项目名称:numpy,代码行数:101,代码来源:build_src.py


示例17: test_1

 def test_1(self):
     assert_equal(appendpath("prefix", "name"), join("prefix", "name"))
     assert_equal(appendpath("/prefix", "name"), ajoin("prefix", "name"))
     assert_equal(appendpath("/prefix", "/name"), ajoin("prefix", "name"))
     assert_equal(appendpath("prefix", "/name"), join("prefix", "name"))
开发者ID:sowhatwchen,项目名称:numpy,代码行数:5,代码来源:test_misc_util.py



注:本文中的numpy.distutils.misc_util.appendpath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python misc_util.dict_append函数代码示例发布时间:2022-05-27
下一篇:
Python log.warn函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap