Skip to content

Commit 7938dc4

Browse files
author
Matthias Köppe
authored
Merge pull request #130 from videlec/cysignals-hook
Cysignals hook
2 parents f51596b + c3c4d3b commit 7938dc4

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
push:
77
tags:
88
- '*'
9+
workflow_dispatch:
10+
# Allow to run manually
911

1012
concurrency:
1113
# Cancel previous runs of this workflow for the same branch

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
cypari2 change log
33
==================
44

5+
v2.2.0 (in development)
6+
------
7+
8+
- require cysignals >= 1.11.3
9+
510
v2.1.5
611
------
712

cypari2/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
from .pari_instance import Pari
22
from .handle_error import PariError
33
from .gen import Gen
4+
from .custom_block import init_custom_block
5+
6+
init_custom_block()

cypari2/custom_block.pyx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# distutils: libraries = gmp pari
2+
3+
#*****************************************************************************
4+
# Distributed under the terms of the GNU General Public License (GPL)
5+
# as published by the Free Software Foundation; either version 2 of
6+
# the License, or (at your option) any later version.
7+
# http://www.gnu.org/licenses/
8+
#*****************************************************************************
9+
10+
from cysignals.signals cimport add_custom_signals
11+
12+
cdef extern from "pari/pari.h":
13+
int PARI_SIGINT_block, PARI_SIGINT_pending
14+
15+
cdef int custom_signal_is_blocked():
16+
return PARI_SIGINT_block
17+
18+
cdef void custom_signal_unblock():
19+
global PARI_SIGINT_block
20+
PARI_SIGINT_block = 0
21+
22+
cdef void custom_set_pending_signal(int sig):
23+
global PARI_SIGINT_pending
24+
PARI_SIGINT_pending = sig
25+
26+
def init_custom_block():
27+
add_custom_signals(&custom_signal_is_blocked,
28+
&custom_signal_unblock,
29+
&custom_set_pending_signal)

pyproject.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[build-system]
2-
requires = ["setuptools",
3-
"Cython>=3.0",
4-
"cysignals>=1.7"]
2+
requires = [
3+
"setuptools",
4+
"Cython>=3.0",
5+
"cysignals>=1.11.3",
6+
]
57
# We need access to the autogen package at build time.
68
# Hence we declare a custom build backend.
79
build-backend = "_custom_build_meta" # just re-exports setuptools.build_meta definitions
@@ -17,7 +19,7 @@ maintainers = [
1719
{name = "SageMath developers", email = "[email protected]"},
1820
]
1921
dependencies = [
20-
"cysignals>=1.7",
22+
"cysignals>=1.11.3",
2123
]
2224
requires-python = ">=3.9"
2325
readme = "README.rst"

0 commit comments

Comments
 (0)