Skip to content

Commit bf61c5d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pr_nmod_ctx
2 parents 3306dda + 9a0327f commit bf61c5d

9 files changed

Lines changed: 74 additions & 9 deletions

File tree

.github/workflows/buildwheel.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ jobs:
4646
env:
4747
# override setting in pyproject.toml to use msys2 instead of msys64 bash
4848
CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows.sh
49-
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel && msys2 -c bin/cibw_before_build_windows.sh
49+
#
50+
# Don't need to create pythonXX.a under meson. Not needed any more:
51+
# CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel && msys2 -c bin/cibw_before_build_windows.sh
52+
#
5053

5154
- uses: actions/upload-artifact@v4
5255
with:
@@ -109,7 +112,7 @@ jobs:
109112
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
110113
# This list to be kept in sync with cibuildwheel config
111114
# and python-requires in pyproject.toml.
112-
python-version: ['3.10', '3.11', '3.12', '3.13-dev']
115+
python-version: ['3.10', '3.11', '3.12', '3.13-dev', 'pypy3.10']
113116

114117
steps:
115118
- uses: actions/setup-python@v5
@@ -205,9 +208,9 @@ jobs:
205208
python-version: '3.12'
206209
- run: sudo apt-get update
207210
- run: sudo apt-get install libflint-dev
208-
# This is branch is for a Cython PR:
211+
# Need Cython's master branch until 3.1 is released because of:
209212
# https://github.com/cython/cython/pull/6341
210-
- run: pip install git+https://github.com/oscarbenjamin/cython.git@pr_relative_paths
213+
- run: pip install git+https://github.com/cython/cython.git@master
211214
- run: pip install -r requirements-dev.txt
212215
- run: bin/coverage.sh
213216

bin/cibw_before_build_windows.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
#
4+
# This script was previously needed to make libpythonXX.a on Windows when using
5+
# MinGW and setuptools. This is no longer needed now that we use meson.
6+
#
7+
38
set -o errexit
49

510
# Uncomment this to run cibuildwheel locally on Windows:

bin/cibw_repair_wheel_command_windows.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
#
55
# https://github.com/scipy/scipy/blob/main/tools/wheels/repair_windows.sh
66

7+
#
8+
# This was previously needed because delvewheel would reject wheels with
9+
# binaries generated by MinGW unless they had been stripped. This is not needed
10+
# any more with newer versions of delvewheel.
11+
#
12+
713
set -o errexit
814

915
# Uncomment this to run cibuildwheel locally on Windows:

pyproject.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ package = "flint"
5858
[tool.cibuildwheel]
5959
# requires-python needs to keep in sync with this and also the list of Python
6060
# versions the wheels are tested against in CI.
61-
build = "cp310-* cp311-* cp312-* cp313-*"
61+
build = "cp310-* cp311-* cp312-* cp313-* pp310-*"
6262
skip = "*-win32 *-manylinux_i686 *-musllinux_*"
6363

6464
# This is needed for free-threaded wheels:
@@ -90,5 +90,18 @@ before-all = "bin/cibw_before_all_macosx_$(uname -m).sh"
9090

9191
[tool.cibuildwheel.windows]
9292
before-all = "C:\\msys64\\usr\\bin\\bash bin/cibw_before_all_windows.sh"
93-
before-build = "pip install delvewheel && C:\\msys64\\usr\\bin\\bash bin/cibw_before_build_windows.sh"
94-
repair-wheel-command = "bin\\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel}"
93+
before-build = "pip install delvewheel"
94+
repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path .local/bin"
95+
96+
# Previously with setuptools and MinGW it was necessary to run
97+
# bin/cibw_before_build_windows.sh before building the wheel to create the
98+
# libpython*.a files. This is no longer necessary now meson is used:
99+
#
100+
# before-build = "pip install delvewheel && C:\\msys64\\usr\\bin\\bash bin/cibw_before_build_windows.sh"
101+
#
102+
# Previously a custom delvewheel command was needed because delvewheel would
103+
# reject binaries created with MinGW unless they had been stripped. This is not
104+
# needed any more with newer versions of delvewheel:
105+
#
106+
# repair-wheel-command = "bin\\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel}"
107+
#

src/flint/flint_base/flint_base.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ cdef class flint_poly(flint_elem):
258258
roots.append((v, m))
259259
return roots
260260

261+
def real_roots(self):
262+
raise NotImplementedError("Real roots are not supported for this polynomial")
263+
261264
def complex_roots(self):
262-
raise AttributeError("Complex roots are not supported for this polynomial")
265+
raise NotImplementedError("Complex roots are not supported for this polynomial")
263266

264267

265268
cdef class flint_mpoly_context(flint_elem):

src/flint/test/test_all.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,9 @@ def set_bad2():
14691469
assert P([1], 11).roots() == []
14701470
assert P([1, 2, 3], 11).roots() == [(8, 1), (6, 1)]
14711471
assert P([1, 6, 1, 8], 11).roots() == [(5, 3)]
1472+
assert raises(lambda: P([1, 2, 3], 11).real_roots(), DomainError)
1473+
assert raises(lambda: P([1, 2, 3], 11).complex_roots(), DomainError)
1474+
14721475

14731476
def test_nmod_mat():
14741477
M = flint.nmod_mat
@@ -2230,12 +2233,15 @@ def test_fmpz_mod_poly():
22302233
assert set(ff.factor()[1]) == set(ff.factor(algorithm="kaltofen_shoup")[1])
22312234
assert set(ff.factor()[1]) == set(ff.factor(algorithm="berlekamp")[1])
22322235
assert raises(lambda: R_test([0,0,1]).factor(algorithm="AAA"), ValueError)
2236+
assert raises(lambda: R_test([0,0,1]).real_roots(), DomainError)
22332237
assert raises(lambda: R_test([0,0,1]).complex_roots(), DomainError)
22342238

2239+
22352240
# composite moduli not supported
22362241
assert raises(lambda: R_cmp([0,0,1]).factor(), DomainError)
22372242
assert raises(lambda: R_cmp([0,0,1]).factor_squarefree(), DomainError)
22382243
assert raises(lambda: R_cmp([0,0,1]).roots(), NotImplementedError)
2244+
assert raises(lambda: R_cmp([0,0,1]).real_roots(), DomainError)
22392245
assert raises(lambda: R_cmp([0,0,1]).complex_roots(), DomainError)
22402246

22412247
# minpoly
@@ -4396,7 +4402,6 @@ def test_fq_default_poly():
43964402
assert raises(lambda: f / "AAA", TypeError)
43974403
assert raises(lambda: "AAA" / f, TypeError)
43984404

4399-
44004405
# ZeroDivisionError
44014406
assert raises(lambda: f / 0, ZeroDivisionError)
44024407
assert raises(lambda: f // 0, ZeroDivisionError)
@@ -4429,6 +4434,9 @@ def test_fq_default_poly():
44294434
# pow_mod
44304435
assert f.pow_mod(2, g) == (f*f) % g
44314436
assert raises(lambda: f.pow_mod(2, "AAA"), TypeError)
4437+
4438+
# roots
4439+
assert raises(lambda: f.real_roots(), DomainError)
44324440
assert raises(lambda: f.complex_roots(), DomainError)
44334441

44344442
# compose errors

src/flint/types/fmpz_mod_poly.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,13 @@ cdef class fmpz_mod_poly(flint_poly):
18841884
res[i] = root
18851885
return res
18861886

1887+
def real_roots(self):
1888+
"""
1889+
This method is not implemented for polynomials in
1890+
:math:`(\mathbb{Z}/N\mathbb{Z})[X]`
1891+
"""
1892+
raise DomainError("Cannot compute real roots for polynomials over integers modulo N")
1893+
18871894
def complex_roots(self):
18881895
"""
18891896
This method is not implemented for polynomials in

src/flint/types/fq_default_poly.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,12 @@ cdef class fq_default_poly(flint_poly):
15881588
res[i] = root
15891589
return res
15901590

1591+
def real_roots(self):
1592+
"""
1593+
This method is not implemented for polynomials in finite fields
1594+
"""
1595+
raise DomainError("Cannot compute real roots for polynomials over finite fields")
1596+
15911597
def complex_roots(self):
15921598
"""
15931599
This method is not implemented for polynomials in finite fields

src/flint/types/nmod_poly.pyx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,3 +863,17 @@ cdef class nmod_poly(flint_poly):
863863
v = self.ctx.new_nmod_poly()
864864
nmod_poly_deflate(v.val, self.val, n)
865865
return v, int(n)
866+
867+
def real_roots(self):
868+
"""
869+
This method is not implemented for polynomials in
870+
:math:`(\mathbb{Z}/N\mathbb{Z})[X]`
871+
"""
872+
raise DomainError("Cannot compute real roots for polynomials over integers modulo N")
873+
874+
def complex_roots(self):
875+
"""
876+
This method is not implemented for polynomials in
877+
:math:`(\mathbb{Z}/N\mathbb{Z})[X]`
878+
"""
879+
raise DomainError("Cannot compute complex roots for polynomials over integers modulo N")

0 commit comments

Comments
 (0)