Esempio n. 1
0
    from distutils.msvc9compiler import MSVCCompiler as MSVC9Compiler
except ImportError:
    MSVC9Compiler = None
try:
    from distutils._msvccompiler import MSVCCompiler as MSVC14Compiler
except ImportError:
    MSVC14Compiler = None

try:
    from Cython import __version__ as cython_version
    from Cython.Build import cythonize
except ImportError:
    cythonize = None
else:
    # We depend upon some features in Cython 0.27; reject older ones.
    if tuple(map(int, cython_version.split('.'))) < (0, 27):
        print("Cython {} is too old for PyAV; ignoring it.".format(cython_version))
        cythonize = None


# We will embed this metadata into the package so it can be recalled for debugging.
version = open('VERSION.txt').read().strip()
try:
    git_commit, _ = Popen(['git', 'describe', '--tags'], stdout=PIPE, stderr=PIPE).communicate()
except OSError:
    git_commit = None
else:
    git_commit = git_commit.decode().strip()


_cflag_parser = argparse.ArgumentParser(add_help=False)
Esempio n. 2
0
    from distutils.msvc9compiler import MSVCCompiler as MSVC9Compiler
except ImportError:
    MSVC9Compiler = None
try:
    from distutils._msvccompiler import MSVCCompiler as MSVC14Compiler
except ImportError:
    MSVC14Compiler = None

try:
    from Cython import __version__ as cython_version
    from Cython.Build import cythonize
except ImportError:
    cythonize = None
else:
    # We depend upon some features in Cython 0.27; reject older ones.
    if tuple(map(int, cython_version.split('.'))) < (0, 27):
        print("Cython {} is too old for PyAV; ignoring it.".format(cython_version))
        cythonize = None


# We will embed this metadata into the package so it can be recalled for debugging.
version = open('VERSION.txt').read().strip()
try:
    git_commit, _ = Popen(['git', 'describe', '--tags'], stdout=PIPE, stderr=PIPE).communicate()
except OSError:
    git_commit = None
else:
    git_commit = git_commit.decode().strip()


_cflag_parser = argparse.ArgumentParser(add_help=False)
Esempio n. 3
0
cython_sources = ['cython/SnapPy.pyx', 'opengl/CyOpenGL.pyx']
cython_cpp_sources = ['cython/SnapPyHP.pyx']

# This is the complete list of Cython files, including those included
# by the above.

all_cython_files = cython_sources + cython_cpp_sources
all_cython_files += ['cython/SnapPycore.pxi', 'cython/SnapPy.pxi']
all_cython_files += glob(os.path.join('cython','core', '*.pyx'))

# If we have Cython, regenerate .c files as needed:
try:
    from Cython.Build import cythonize
    from Cython import __version__ as cython_version
    if [int(x) for x in cython_version.split('.')] < [0, 28]:
        raise ImportError

    if 'clean' not in sys.argv:
        cython_sources = [file for file in cython_sources if exists(file)]
        cythonize(cython_sources,
                  compiler_directives={'embedsignature': True})
        cython_cpp_sources = [file for file in cython_cpp_sources if exists(file)]
        cythonize(cython_cpp_sources,
                  compiler_directives={'embedsignature': True})
except ImportError:
    for file in cython_sources:
        base = os.path.splitext(file)[0]
        if not exists(base + '.c'):
            raise ImportError(no_cython_message)
    for file in cython_cpp_sources:
Esempio n. 4
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------

import setuptools
from Cython import __version__
from Cython.Build import cythonize

from setup import kwargs

if int(__version__.split(".", 1)[0]) < 3:
    # Cython < 3.0 has problems with __init_subclass__().
    raise SystemExit("cython >= 3.0 required")


def extension(name, sources):
    return setuptools.Extension(
        name, sources, extra_compile_args=["-DCYTHON_WITHOUT_ASSERTIONS"])


kwargs["packages"] = ["ff"]
kwargs["ext_modules"] = cythonize([
    extension("libff.*", ["libff/[!_]*.py"]),
    extension("libff.builtin.*", ["libff/builtin/*.py"])
],
                                  language_level=3)