示例#1
0
    def finalize_options(self):
        # Generate files
        from autogen import rebuild
        rebuild()

        import sys

        # Check dependencies
        try:
            from Cython.Build.Dependencies import cythonize
        except ImportError as E:
            sys.stderr.write("Error: {0}\n".format(E))
            sys.stderr.write("The installation of ppl requires Cython\n")
            sys.exit(1)


# cysignals not yet integrated
#        try:
#            # We need the header files for cysignals at compile-time
#            import cysignals
#        except ImportError as E:
#            sys.stderr.write("Error: {0}\n".format(E))
#            sys.stderr.write("The installation of ppl requires cysignals\n")
#            sys.exit(1)

        self.distribution.ext_modules[:] = cythonize(
            self.distribution.ext_modules, include_path=sys.path)
        _build_ext.finalize_options(self)
示例#2
0
文件: setup.py 项目: timokau/cypari2
    def finalize_options(self):
        # Check dependencies
        try:
            from Cython.Build.Dependencies import cythonize
        except ImportError as E:
            sys.stderr.write("Error: {0}\n".format(E))
            sys.stderr.write("The installation of cypari2 requires Cython\n")
            sys.exit(1)

        try:
            # We need the header files for cysignals at compile-time
            import cysignals
        except ImportError as E:
            sys.stderr.write("Error: {0}\n".format(E))
            sys.stderr.write("The installation of cypari2 requires cysignals\n")
            sys.exit(1)

        # Generate auto-generated sources from pari.desc
        rebuild()

        self.directives = {
            "autotestdict.cdef": True,
            "binding": True,
        }

        self.distribution.ext_modules[:] = cythonize(
            self.distribution.ext_modules,
            compiler_directives=self.directives)

        _build_ext.finalize_options(self)
示例#3
0
文件: setup.py 项目: culler/cypari2
    def finalize_options(self):
        # Generate auto-generated sources from pari.desc
        rebuild()

        self.directives = {
            "autotestdict.cdef": True,
            "binding": True,
            "cdivision": True,
            "language_level": 2,
        }

        _build_ext.finalize_options(self)
示例#4
0
    def finalize_options(self):
        # Generate files
        from autogen import rebuild
        rebuild()

        import sys

        # Check dependencies
        try:
            from Cython.Build.Dependencies import cythonize
        except ImportError as E:
            sys.stderr.write("Error: {0}\n".format(E))
            sys.stderr.write("The installation of ppl requires Cython\n")
            sys.exit(1)


# cysignals not yet integrated
#        try:
#            # We need the header files for cysignals at compile-time
#            import cysignals
#        except ImportError as E:
#            sys.stderr.write("Error: {0}\n".format(E))
#            sys.stderr.write("The installation of ppl requires cysignals\n")
#            sys.exit(1)

        compile_time_env = {}
        if compile_from_sage:

            version = sage.env.SAGE_VERSION.split('.')
            major = int(version[0])
            minor = int(version[1])
            if len(version) == 3:
                beta = int(version[2][4:])
            else:
                beta = -1
            sage_version = (major, minor, beta)

            # trac ticket #22970 changes datastructure of rational matrices
            # merged in 8.0.beta9
            compile_time_env['SAGE_RAT_MAT_ARE_FMPQ_T_MAT'] = (sage_version >=
                                                               (8, 0, 9))

        self.distribution.ext_modules[:] = cythonize(
            self.distribution.ext_modules,
            compile_time_env=compile_time_env,
            include_path=sys.path)
        _build_ext.finalize_options(self)
示例#5
0
    def finalize_options(self):
        # Generate files
        from autogen import rebuild
        rebuild()


        import sys

        # Check dependencies
        try:
            from Cython.Build.Dependencies import cythonize
        except ImportError as E:
            sys.stderr.write("Error: {0}\n".format(E))
            sys.stderr.write("The installation of ppl requires Cython\n")
            sys.exit(1)

# cysignals not yet integrated
#        try:
#            # We need the header files for cysignals at compile-time
#            import cysignals
#        except ImportError as E:
#            sys.stderr.write("Error: {0}\n".format(E))
#            sys.stderr.write("The installation of ppl requires cysignals\n")
#            sys.exit(1)


        compile_time_env = {}
        if compile_from_sage:

            version = sage.env.SAGE_VERSION.split('.')
            major = int(version[0])
            minor = int(version[1])
            if len(version) == 3:
                beta = int(version[2][4:])
            else:
                beta = -1
            sage_version = (major,minor,beta)

            # trac ticket #22970 changes datastructure of rational matrices
            # merged in 8.0.beta9
            compile_time_env['SAGE_RAT_MAT_ARE_FMPQ_T_MAT'] = (sage_version >= (8,0,9))

        self.distribution.ext_modules[:] = cythonize(
            self.distribution.ext_modules,
            compile_time_env=compile_time_env,
            include_path=sys.path)
        _build_ext.finalize_options(self)
示例#6
0
文件: setup.py 项目: slel/CyPari
    def run(self):
        building_sdist = False

        if os.path.exists('pari_src'):
            # We are building an sdist.  Move the Pari source code into build.
            if not os.path.exists('build'):
                os.mkdir('build')
            os.rename('pari_src', os.path.join('build', 'pari_src'))
            os.rename('gmp_src', os.path.join('build', 'gmp_src'))
            # Find the correct _pari.c for our version of Python.
            _pari_c_name = '_pari_py%d.c' % sys.version_info.major
            os.rename(os.path.join('cypari', _pari_c_name),
                      os.path.join('cypari', '_pari.c'))
            building_sdist = True

        if (not os.path.exists(os.path.join('libcache', PARIDIR))
                or not os.path.exists(os.path.join('libcache', GMPDIR))):
            if sys.platform == 'win32':
                # This is meant to work even in a Windows Command Prompt
                if cpu_width == 64:
                    cmd = r'export PATH="%s" ; export MSYSTEM=MINGW64 ; bash build_pari.sh %s %s' % (
                        BASHPATH, PARIDIR, GMPDIR)
                else:
                    cmd = r'export PATH="%s" ; export MSYSTEM=MINGW32 ; bash build_pari.sh %s %s' % (
                        BASHPATH, PARIDIR, GMPDIR)
            elif sys.platform == 'darwin':
                cmd = r'export PATH="%s" ; bash build_pari.sh' % BASHPATH
            else:
                cmd = r'export PATH="%s" ; bash build_pari.sh %s %s' % (
                    BASHPATH, PARIDIR, GMPDIR)
            # print([BASH, '-c', cmd])
            if subprocess.call([BASH, '-c', cmd]):
                sys.exit("***Failed to build PARI library***")

        if building_sdist:
            build_ext.run(self)
            return

        if (not os.path.exists(os.path.join('cypari', 'auto_gen.pxi'))
                or not os.path.exists(
                    os.path.join('cypari', 'auto_instance.pxi'))):
            import autogen
            autogen.rebuild()

        # Provide declarations in an included .pxi file which indicate
        # whether we are building for 64 bit Python on Windows, and
        # which version of Python we are using.  We need to handle 64
        # bit Windows differently because (a) it is the only 64 bit
        # system with 32 bit longs and (b) Pari deals with this by:
        # #define long long long thereby breaking lots of stuff in the
        # Python headers.
        long_include = os.path.join('cypari', 'pari_long.pxi')
        if sys.platform == 'win32' and cpu_width == '64bit':
            if sys.version_info.major == 2:
                include_file = os.path.join('cypari', 'long_win64py2.pxi')
            else:
                include_file = os.path.join('cypari', 'long_win64py3.pxi')
        else:
            include_file = os.path.join('cypari', 'long_generic.pxi')
        with open(include_file, 'rb') as input:
            code = input.read()
        # Don't touch the long_include file unless it has changed, to avoid
        # unnecessary compilation.
        if os.path.exists(long_include):
            with open(long_include, 'rb') as input:
                old_code = input.read()
        else:
            old_code = b''
        if old_code != code:
            with open(long_include, 'wb') as output:
                output.write(code)

        # If we have Cython, check that .c files are up to date
        try:
            from Cython.Build import cythonize
            cythonize([os.path.join('cypari', '_pari.pyx')],
                      compiler_directives={'language_level': 2})
        except ImportError:
            if not os.path.exists(os.path.join('cypari', '_pari.c')):
                sys.exit(no_cython_message)

        build_ext.run(self)