Skip to content

Commit

Permalink
Merge pull request #130 from videlec/cysignals-hook
Browse files Browse the repository at this point in the history
Cysignals hook
  • Loading branch information
Matthias Köppe authored Mar 25, 2024
2 parents f51596b + c3c4d3b commit 7938dc4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
tags:
- '*'
workflow_dispatch:
# Allow to run manually

concurrency:
# Cancel previous runs of this workflow for the same branch
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
cypari2 change log
==================

v2.2.0 (in development)
------

- require cysignals >= 1.11.3

v2.1.5
------

Expand Down
3 changes: 3 additions & 0 deletions cypari2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .pari_instance import Pari
from .handle_error import PariError
from .gen import Gen
from .custom_block import init_custom_block

init_custom_block()
29 changes: 29 additions & 0 deletions cypari2/custom_block.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# distutils: libraries = gmp pari

#*****************************************************************************
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

from cysignals.signals cimport add_custom_signals

cdef extern from "pari/pari.h":
int PARI_SIGINT_block, PARI_SIGINT_pending

cdef int custom_signal_is_blocked():
return PARI_SIGINT_block

cdef void custom_signal_unblock():
global PARI_SIGINT_block
PARI_SIGINT_block = 0

cdef void custom_set_pending_signal(int sig):
global PARI_SIGINT_pending
PARI_SIGINT_pending = sig

def init_custom_block():
add_custom_signals(&custom_signal_is_blocked,
&custom_signal_unblock,
&custom_set_pending_signal)
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[build-system]
requires = ["setuptools",
"Cython>=3.0",
"cysignals>=1.7"]
requires = [
"setuptools",
"Cython>=3.0",
"cysignals>=1.11.3",
]
# We need access to the autogen package at build time.
# Hence we declare a custom build backend.
build-backend = "_custom_build_meta" # just re-exports setuptools.build_meta definitions
Expand All @@ -17,7 +19,7 @@ maintainers = [
{name = "SageMath developers", email = "[email protected]"},
]
dependencies = [
"cysignals>=1.7",
"cysignals>=1.11.3",
]
requires-python = ">=3.9"
readme = "README.rst"
Expand Down

0 comments on commit 7938dc4

Please sign in to comment.