1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
# When building with readthedocs, install the requirements too
if "READTHEDOCS" in os.environ:
reqs = "requirements.txt"
if os.path.isfile(reqs):
from subprocess import check_call
check_call([sys.executable, "-m", "pip", "install", "-r", reqs])
from setuptools import setup
from distutils.command.build import build as _build
from distutils.command.build_py import build_py as _build_py
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
from setuptools.extension import Extension
import warnings
warnings.simplefilter("always")
from glob import glob
opj = os.path.join
macros = [
# Disable .c line numbers in exception tracebacks
("CYTHON_CLINE_IN_TRACEBACK", 0),
]
depends = glob(opj("src", "cysignals", "*.h"))
ac_configure_flags = os.environ.get("PYSETUP_CONFIGURE_FLAGS","--without-pari")
if "--without-pari" in sys.argv:
ac_configure_flags = "--without-pari"
sys.argv.remove("--without-pari")
if "--with-pari" in sys.argv:
ac_configure_flags = "--with-pari"
sys.argv.remove("--with-pari")
cythonize_subdir = "XXXX"
if "--without-pari" in ac_configure_flags:
cythonize_subdir = "bare"
elif "--with-pari" in ac_configure_flags:
cythonize_subdir = "pari"
cythonize_dir = opj("build", cythonize_subdir)
# Disable sanity checking in GNU libc. This is required because of
# false positives in the longjmp() check.
undef_macros = ["_FORTIFY_SOURCE"]
kwds = dict(include_dirs=[opj("build", cythonize_subdir, "src"),
opj("build", cythonize_subdir, "src", "cysignals"),
opj("src"),
opj("src", "cysignals")],
depends=depends,
define_macros=macros,
undef_macros=undef_macros,
extra_compile_args=["-pthread"],
extra_link_args=["-pthread"],)
extensions = [
Extension("cysignals.signals", ["src/cysignals/signals.pyx"], **kwds),
Extension("cysignals.pysignals", ["src/cysignals/pysignals.pyx"], **kwds),
Extension("cysignals.alarm", ["src/cysignals/alarm.pyx"], **kwds),
Extension("cysignals.pselect", ["src/cysignals/pselect.pyx"], **kwds),
Extension("cysignals.tests", ["src/cysignals/tests.pyx"], **kwds),
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
('License :: OSI Approved :: '
'GNU Lesser General Public License v3 or later (LGPLv3+)'),
'Operating System :: POSIX',
'Programming Language :: C',
'Programming Language :: Cython',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: System',
'Topic :: Software Development :: Debuggers',
]
# Run Distutils
class build(_build):
def run(self):
"""
Run ``./configure`` and Cython first.
"""
config_h = opj("src", "cysignals", "cysignals_config.h")
if not os.path.isfile(config_h):
import subprocess
subprocess.check_call(["make", "configure"])
subprocess.check_call(
"make configure && mkdir -p " + cythonize_dir +
" && " +
"{ cd " + cythonize_dir + " ; ../../configure " + ac_configure_flags + " ; }" ,
shell=True)
dist = self.distribution
ext_modules = dist.ext_modules
if ext_modules:
dist.ext_modules[:] = self.cythonize(ext_modules)
_build.run(self)
def cythonize(self, extensions):
# Run Cython with -Werror on continuous integration services
# with Python 3.6 or later
if "CI" in os.environ and sys.version_info >= (3, 6):
from Cython.Compiler import Options
Options.warning_errors = True
from Cython.Build.Dependencies import cythonize
return cythonize(extensions,
build_dir=cythonize_dir,
include_path=["src", os.path.join(cythonize_dir, "src")],
compiler_directives=dict(binding=True, language_level=2))
class no_egg(_bdist_egg):
def run(self):
from distutils.errors import DistutilsOptionError
raise DistutilsOptionError("The package cysignals will not function correctly when built as egg. Therefore, it cannot be installed using 'python setup.py install' or 'easy_install'. Instead, use 'pip install' to install cysignals.")
with open("VERSION") as f:
VERSION = f.read().strip()
with open('README.rst') as f:
README = f.read()
setup(
name="cysignals",
author=u"Martin R. Albrecht, François Bissey, Volker Braun, Jeroen Demeyer",
author_email="sage-devel@googlegroups.com",
version=VERSION,
url="https://github.com/sagemath/cysignals",
license="GNU Lesser General Public License, version 3 or later",
description="Interrupt and signal handling for Cython",
long_description=README,
classifiers=classifiers,
install_requires=["Cython>=0.28"],
setup_requires=["Cython>=0.28"],
ext_modules=extensions,
packages=["cysignals"],
package_dir={"cysignals": opj("src", "cysignals")},
package_data={"cysignals": ["*.pxi", "*.pxd", "*.h"]},
data_files=[(opj("share", "cysignals"), [opj("src", "scripts", "cysignals-CSI-helper.py")])],
scripts=glob(opj("src", "scripts", "cysignals-CSI")),
cmdclass=dict(build=build, bdist_egg=no_egg),
)
|