예제 #1
0
파일: dist.py 프로젝트: artas360/pythran
    def __init__(self, name, sources, **kwargs):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        cxx_sources = []
        for source in sources:
            base, ext = os.path.splitext(source)
            output_file = base + '.cpp'  # target name

            # stage 0 when we have the .py
            if os.path.exists(source):
                stage = 0
            # stage 1 otherwise. `.cpp' should already be there
            # as generated upon stage 0
            else:
                assert os.path.exists(output_file)
                stage = 1
                ext = '.cpp'
                source = output_file

            # stage-dependant processing
            if stage == 0:
                tc.compile_pythranfile(source, output_file,
                                       module_name=name, cpponly=True)
            cxx_sources.append(output_file)

        extension_args = cfg.make_extension()
        Extension.__init__(self, name, cxx_sources, **extension_args)
예제 #2
0
파일: dist.py 프로젝트: mm1860/pythran
    def __init__(self, name, sources, *args, **kwargs):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        import pythran.toolchain as tc

        cxx_sources = []
        for source in sources:
            base, ext = os.path.splitext(source)
            if ext == ".cpp":
                output_file = source
                stage = 1
            else:
                output_file = base + '.cpp'  # target name
                # stage 0 when we have the .py
                if os.path.exists(source):
                    stage = 0
                # stage 1 otherwise. `.cpp' should already be there
                # as generated upon stage 0
                else:
                    assert os.path.exists(output_file)
                    stage = 1
                    source = output_file

            # stage-dependant processing
            if stage == 0:
                # get the last name in the path
                if '.' in name:
                    module_name = os.path.splitext(name)[-1][1:]
                else:
                    module_name = name
                tc.compile_pythranfile(source,
                                       output_file,
                                       module_name,
                                       cpponly=True)
            cxx_sources.append(output_file)

        cfg_ext = cfg.make_extension(python=True, **kwargs)
        self.cxx = cfg_ext.pop('cxx')
        Extension.__init__(self, name, cxx_sources, *args, **cfg_ext)
예제 #3
0
    def __init__(self, name, sources, **kwargs):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        cxx_sources = []
        for source in sources:
            base, ext = os.path.splitext(source)
            output_file = base + '.cpp'  # target name

            # stage 0 when we have the .py
            if os.path.exists(source):
                stage = 0
            # stage 1 otherwise. `.cpp' should already be there
            # as generated upon stage 0
            else:
                assert os.path.exists(output_file)
                stage = 1
                ext = '.cpp'
                source = output_file

            # stage-dependant processing
            if stage == 0:
                tc.compile_pythranfile(source,
                                       output_file,
                                       module_name=name,
                                       cpponly=True)
            cxx_sources.append(output_file)

        # in both cases, setup the flags in a pythran-compatible way.
        kwargs['language'] = 'c++'
        kwargs.setdefault('extra_compile_args',
                          []).extend(tc.cppflags() + tc.cxxflags())
        # FIXME: force the compiler to be pythran's ones
        # I cannot find a way to do this in a less intrusive manner
        os.environ['CC'] = tc.default_compiler()
        os.environ['CXX'] = tc.default_compiler()
        kwargs.setdefault('extra_link_args', []).extend(tc.ldflags())
        Extension.__init__(self, name, cxx_sources, **kwargs)
예제 #4
0
    def __init__(self, name, sources, **kwargs):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        cxx_sources = []
        for source in sources:
            base, ext = os.path.splitext(source)
            output_file = base + '.cpp'  # target name

            # stage 0 when we have the .py
            if os.path.exists(source):
                stage = 0
            # stage 1 otherwise. `.cpp' should already be there
            # as generated upon stage 0
            else:
                assert os.path.exists(output_file)
                stage = 1
                ext = '.cpp'
                source = output_file

            # stage-dependant processing
            if stage == 0:
                tc.compile_pythranfile(source, output_file,
                                       module_name=name, cpponly=True)
            cxx_sources.append(output_file)

        # in both cases, setup the flags in a pythran-compatible way.
        kwargs['language'] = 'c++'
        kwargs.setdefault('extra_compile_args', []).extend(tc.cppflags() +
                                                           tc.cxxflags())
        # FIXME: force the compiler to be pythran's ones
        # I cannot find a way to do this in a less intrusive manner
        os.environ['CC'] = tc.default_compiler()
        os.environ['CXX'] = tc.default_compiler()
        kwargs.setdefault('extra_link_args', []).extend(tc.ldflags())
        Extension.__init__(self, name, cxx_sources, **kwargs)
예제 #5
0
    def sources(self):
        import pythran.toolchain as tc
        cxx_sources = []
        for source in self._sources:
            base, ext = os.path.splitext(source)
            if ext != '.py':
                cxx_sources.append(source)
                continue
            output_file = base + '.cpp'  # target name

            if os.path.exists(source) and (not os.path.exists(output_file)
               or os.stat(output_file) < os.stat(source)):
                # get the last name in the path
                if '.' in self.name:
                    module_name = os.path.splitext(self.name)[-1][1:]
                else:
                    module_name = self.name
                tc.compile_pythranfile(source, output_file,
                                       module_name, cpponly=True)
            cxx_sources.append(output_file)
        return cxx_sources
예제 #6
0
    def __init__(self, name, sources):
        # the goal is to rely on original Extension
        # to do so we convert the .py to .cpp with pythran
        # and register the .cpp in place of the .py
        # That's stage 0, and it's enough if you get the source
        # from github and `python setup.py install it`
        #
        # *But* if you want to distribute the source through
        # `python setup.py sdist` then the .py no longer exists
        # and only the .cpp is distributed. That's stage 1

        cxx_sources = []
        for source in sources:
            base, _ = os.path.splitext(source)
            output_file = base + '.cpp'  # target name

            # stage 0 when we have the .py
            if os.path.exists(source):
                stage = 0
            # stage 1 otherwise. `.cpp' should already be there
            # as generated upon stage 0
            else:
                assert os.path.exists(output_file)
                stage = 1
                source = output_file

            # stage-dependant processing
            if stage == 0:
                tc.compile_pythranfile(source,
                                       output_file,
                                       module_name=name,
                                       cpponly=True)
            cxx_sources.append(output_file)

        extension_args = cfg.make_extension()
        Extension.__init__(self, name, cxx_sources, **extension_args)