[Python-modules-commits] [cysignals] 01/03: import cysignals_1.1.1+ds.orig.tar.xz
Jerome Benoit
calculus-guest at moszumanska.debian.org
Fri Sep 23 14:19:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
calculus-guest pushed a commit to branch experimental-sage
in repository cysignals.
commit 379a27a1e352b8ae4972a4084df6127836cd9960
Author: Jerome Benoit <calculus at rezozer.net>
Date: Sat Sep 17 02:22:34 2016 +0100
import cysignals_1.1.1+ds.orig.tar.xz
---
LICENSE | 165 +++++++
Makefile | 54 +++
PKG-INFO | 32 ++
README.rst | 22 +
VERSION | 1 +
configure.ac | 46 ++
docs/Makefile | 177 +++++++
docs/source/conf.py | 267 ++++++++++
docs/source/index.rst | 445 +++++++++++++++++
example/README | 1 +
example/cysignals_example.pyx | 24 +
example/setup.py | 16 +
setup.py | 139 ++++++
src/cysignals/__init__.py | 3 +
src/cysignals/alarm.pyx | 89 ++++
src/cysignals/debug.h | 6 +
src/cysignals/implementation.c | 444 +++++++++++++++++
src/cysignals/macros.h | 283 +++++++++++
src/cysignals/memory.pxd | 149 ++++++
src/cysignals/memory.pxi | 6 +
src/cysignals/pxi.h | 12 +
src/cysignals/signals.pxd | 50 ++
src/cysignals/signals.pxi | 24 +
src/cysignals/signals.pyx | 225 +++++++++
src/cysignals/struct_signals.h | 90 ++++
src/cysignals/tests.pyx | 939 ++++++++++++++++++++++++++++++++++++
src/cysignals/tests_helper.c | 116 +++++
src/scripts/cysignals-CSI | 217 +++++++++
src/scripts/cysignals-CSI-helper.py | 134 +++++
29 files changed, 4176 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b7421a4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+# Optional Makefile for easier development
+
+PYTHON=python
+
+all: build doc
+
+build: configure
+ $(PYTHON) setup.py build
+
+install: build
+ $(PYTHON) setup.py install
+
+dist: configure
+ chmod go+rX-w -R .
+ umask 0022 && $(PYTHON) setup.py sdist --formats=bztar
+
+distcheck: dist
+ mkdir -p dist/check
+ VERSION=`cat VERSION`; cd dist/check && tar xjf ../cysignals-$$VERSION.tar.bz2
+ VERSION=`cat VERSION`; cd dist/check/cysignals-$$VERSION && ./configure && $(MAKE) all check
+ rm -rf dist/check
+
+doc:
+ cd docs && $(MAKE) html
+
+clean: clean-doc clean-build
+
+clean-build:
+ rm -rf build example/build example/*.c
+
+clean-doc:
+ cd docs && $(MAKE) clean
+
+distclean: clean
+ rm -rf autom4te.cache
+ rm -f config.log config.status
+
+check: check-doctest check-example
+
+check-doctest: install
+ $(PYTHON) -m doctest src/cysignals/*.pyx
+
+check-example: install
+ cd example && $(PYTHON) setup.py build
+
+test: check
+
+configure: configure.ac
+ autoconf
+ autoheader
+ @rm -f src/config.h.in~
+
+.PHONY: all build doc install dist doc clean clean-build clean-doc \
+ distclean check check-doctest check-example test
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..946e50e
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,32 @@
+Metadata-Version: 1.0
+Name: cysignals
+Version: 1.1.1
+Summary: Interrupt and signal handling for Cython
+Home-page: https://github.com/sagemath/cysignals
+Author: Martin R. Albrecht, François Bissey, Volker Braun, Jeroen Demeyer
+Author-email: sage-devel at googlegroups.com
+License: GNU Lesser General Public License, version 3 or later
+Description: cysignals: interrupt and signal handling for Cython
+ ===================================================
+
+ .. image:: https://travis-ci.org/sagemath/cysignals.svg?branch=master
+ :target: https://travis-ci.org/sagemath/cysignals
+
+ .. image:: https://readthedocs.org/projects/cysignals/badge/?version=latest
+ :target: http://cysignals.readthedocs.org
+
+ When writing `Cython <http://cython.org/>`_ code, special care must be
+ taken to ensure that the code can be interrupted with ``CTRL-C``.
+ Since Cython optimizes for speed, Cython normally does not check for
+ interrupts. For example, code like the following cannot be interrupted
+ in Cython::
+
+ while True:
+ pass
+
+ The ``cysignals`` package provides mechanisms to handle interrupts (and other
+ signals and errors) in Cython code.
+
+ See http://cysignals.readthedocs.org/ for the full documentation.
+
+Platform: POSIX
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..1c93f76
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,22 @@
+cysignals: interrupt and signal handling for Cython
+===================================================
+
+.. image:: https://travis-ci.org/sagemath/cysignals.svg?branch=master
+ :target: https://travis-ci.org/sagemath/cysignals
+
+.. image:: https://readthedocs.org/projects/cysignals/badge/?version=latest
+ :target: http://cysignals.readthedocs.org
+
+When writing `Cython <http://cython.org/>`_ code, special care must be
+taken to ensure that the code can be interrupted with ``CTRL-C``.
+Since Cython optimizes for speed, Cython normally does not check for
+interrupts. For example, code like the following cannot be interrupted
+in Cython::
+
+ while True:
+ pass
+
+The ``cysignals`` package provides mechanisms to handle interrupts (and other
+signals and errors) in Cython code.
+
+See http://cysignals.readthedocs.org/ for the full documentation.
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..524cb55
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.1.1
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..6cfaa0f
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,46 @@
+dnl Not sure which autoconf version we need, but 2.69 (from 2012)
+dnl is widely available.
+AC_PREREQ([2.69])
+
+AC_DEFUN([VERSION], m4_esyscmd_s(cat VERSION))
+
+AC_INIT([cysignals], VERSION, [https://github.com/sagemath/cysignals/issues])
+AC_COPYRIGHT([GPL version 2 or later])
+AC_CONFIG_SRCDIR([configure.ac])
+AC_CONFIG_HEADERS([build/src/config.h:src/config.h.in])
+
+AC_LANG(C)
+
+AC_SEARCH_LIBS([pari_init], [pari])
+
+AC_CHECK_HEADERS([execinfo.h sys/prctl.h])
+AC_CHECK_FUNCS([backtrace])
+
+AC_CHECK_DECL([PARI_SIGINT_block],
+ [AC_DEFINE(HAVE_PARI, 1, [Define to 1 if PARI is fully supported.])],
+ [], [[#include <pari/pari.h>]])
+
+AC_MSG_CHECKING([for emms instruction])
+# We add the "leal" instruction to reduce false positives in case some
+# non-x86 architecture also has an "emms" instruction.
+AC_RUN_IFELSE([AC_LANG_PROGRAM([], [asm("leal (%eax), %eax; emms");])],
+ dnl YES
+ [AC_MSG_RESULT([yes])]
+ AC_DEFINE(HAVE_EMMS, 1, [Define to 1 if your processor understands the "emms" instruction.])
+ ,
+ dnl NO
+ [AC_MSG_RESULT([no])]
+)
+
+
+AC_CONFIG_COMMANDS([build/src/config.pxd],
+ # Generate a file config.pxd whose contents will be copied to
+ # __init__.pxd to set correct compiler options.
+ # The -Ddummy works around https://github.com/cython/cython/pull/485
+ [[echo "# distutils: extra_link_args = $LIBS -Ddummy" >build/src/config.pxd]],
+ [LIBS=$LIBS])
+
+
+AC_OUTPUT()
+
+dnl vim:syntax=m4
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..127c5da
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,177 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/cysignals.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/cysignals.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/cysignals"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/cysignals"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/source/conf.py b/docs/source/conf.py
new file mode 100644
index 0000000..b2bf184
--- /dev/null
+++ b/docs/source/conf.py
@@ -0,0 +1,267 @@
+# -*- coding: utf-8 -*-
+#
+# cysignals documentation build configuration file, created by
+# sphinx-quickstart on Mon Feb 8 09:56:12 2016.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.intersphinx',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'cysignals'
+copyright = u'2016, Martin Albrecht, Jeroen Demeyer'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = open("../../VERSION").read().strip()
+# The full version, including alpha/beta/rc tags.
+release = version
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# Use Cython syntax highlighting
+highlight_language = "cython"
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'cysignalsdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ ('index', 'cysignals.tex', u'cysignals Documentation',
+ u'Martin Albrecht, Jeroen Demeyer', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'cysignals', u'cysignals Documentation',
+ [u'Martin Albrecht, Jeroen Demeyer'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'cysignals', u'cysignals Documentation',
+ u'Martin Albrecht, Jeroen Demeyer', 'cysignals', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# Intersphinx reference to Python
+intersphinx_mapping = {'python': ('https://docs.python.org/2.7', None)}
diff --git a/docs/source/index.rst b/docs/source/index.rst
new file mode 100644
index 0000000..4577d61
--- /dev/null
+++ b/docs/source/index.rst
@@ -0,0 +1,445 @@
+cysignals
+=========
+
+When writing `Cython <http://cython.org/>`_ code, special care must be
+taken to ensure that the code can be interrupted with ``CTRL-C``.
+Since Cython optimizes for speed, Cython normally does not check for
+interrupts. For example, code like the following cannot be interrupted
+in Cython::
+
+ while True:
+ pass
+
+While this is running, pressing ``CTRL-C`` has no effect. The only way
+out is to kill the Python process. On certain systems, you can still
+quit Python by typing ``CTRL-\`` (sending a Quit signal) instead of
+``CTRL-C``.
+
+This module provides two related mechanisms to deal with interrupts:
+
+* :ref:`Use sig_check() <section_sig_check>` if you are writing mixed
+ Cython/Python code. Typically this is code with (nested) loops where every
+ individual statement takes little time.
+
+* :ref:`Use sig_on() and sig_off() <section_sig_on>` if you are calling external
+ C libraries or inside pure Cython code (without any Python functions) where
+ even an individual statement, like a library call, can take a long time.
+
+The functions ``sig_check()``, ``sig_on()`` and ``sig_off()`` can be put in all
+kinds of Cython functions: ``def``, ``cdef`` or ``cpdef``. You cannot put them
+in pure Python code (files with extension ``.py``).
+
+Basic example
+-------------
+
+The ``sig_check()`` in the loop below ensures that the loop can be
+interrupted by ``CTRL-C``::
+
+ include "cysignals/signals.pxi"
+
+ from libc.math cimport sin
+
+ def sine_sum(double x, long count):
+ cdef double s = 0
+ for i in range(count):
+ sig_check()
+ s += sin(i*x)
+ return s
+
+The line ``include "cysignals/signals.pxi"`` must be put in every
+``.pyx`` file using cysignals.
+You must not put this in a ``.pxd`` file; a ``.pxi`` file included only
+in ``.pyx`` files also works.
+
+Because of `cython/cython#483 <https://github.com/cython/cython/pull/483>`_,
+you should add ``include_path=sys.path`` to your ``cythonize()`` call in
+``setup.py`` (otherwise Cython will not find :file:`cysignals/signals.pxi`).
+See the `example <https://github.com/sagemath/cysignals/tree/master/example>`_
+directory for this complete working example.
+
+.. NOTE::
+
+ Cython ``cdef`` or ``cpdef`` functions with a return type (like ``cdef int
+ myfunc():``) need to have an `except value
+ <http://docs.cython.org/src/userguide/language_basics.html#error-return-values>`_
+ to propagate exceptions. Remember this whenever you write ``sig_check()`` or
+ ``sig_on()`` inside such a function, otherwise you will see a message like
+ ``Exception KeyboardInterrupt: KeyboardInterrupt() in <function name>
+ ignored``.
+
+.. _section_sig_check:
+
+Using ``sig_check()``
+---------------------
+
+``sig_check()`` can be used to check for pending interrupts. If an interrupt
+happens during the execution of C or Cython code, it will be caught by the next
+``sig_check()``, the next ``sig_on()`` or possibly the next Python statement.
+With the latter we mean that certain Python statements also check for
+interrupts, an example of this is the ``print`` statement. The following loop
+*can* be interrupted::
+
+ >>> while True:
+ ... print("Hello")
+
+The typical use case for ``sig_check()`` is within tight loops doing complicated
+stuff (mixed Python and Cython code, potentially raising exceptions). It is
+reasonably safe to use and gives a lot of control, because in your Cython code,
+a ``KeyboardInterrupt`` can *only* be raised during ``sig_check()``::
+
+ def sig_check_example():
+ for x in foo:
+ # (one loop iteration which does not take a long time)
+ sig_check()
+
+This ``KeyboardInterrupt`` is treated like any other Python exception and can be
+handled as usual::
+
+ def catch_interrupts():
+ try:
+ while some_condition():
+ sig_check()
+ do_something()
+ except KeyboardInterrupt:
+ # (handle interrupt)
+
+Of course, you can also put the ``try``/``except`` inside the loop in the
+example above.
+
+The function ``sig_check()`` is an extremely fast inline function which should
+have no measurable effect on performance.
+
+.. _section_sig_on:
+
+Using ``sig_on()`` and ``sig_off()``
+------------------------------------
+
+Another mechanism for interrupt handling is the pair of functions ``sig_on()``
+and ``sig_off()``. It is more powerful than ``sig_check()`` but also a lot more
+dangerous. You should put ``sig_on()`` *before* and ``sig_off()`` *after* any
+Cython code which could potentially take a long time. These two *must always* be
+called in **pairs**, i.e. every ``sig_on()`` must be matched by a closing
+``sig_off()``.
+
+In practice your function will probably look like::
+
+ def sig_example():
+ # (some harmless initialization)
+ sig_on()
+ # (a long computation here, potentially calling a C library)
+ sig_off()
+ # (some harmless post-processing)
+ return something
+
+It is possible to put ``sig_on()`` and ``sig_off()`` in different functions,
+provided that ``sig_off()`` is called before the function which calls
+``sig_on()`` returns. The following code is *invalid*::
+
+ # INVALID code because we return from function foo()
+ # without calling sig_off() first.
+ cdef foo():
+ sig_on()
+
+ def f1():
+ foo()
+ sig_off()
... 3387 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/cysignals.git
More information about the Python-modules-commits
mailing list