Skip to content

Commit

Permalink
Back out changes for flint3 and setuptools
Browse files Browse the repository at this point in the history
I hope these work for CI.  I currently don't have flint 3.0 or whatever
the matching arb lib is.
  • Loading branch information
deinst committed Aug 17, 2023
1 parent 518c0a7 commit 89d567c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml

This file was deleted.

19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os
from subprocess import check_call

from setuptools import setup
from setuptools import Extension
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
from numpy.distutils.system_info import default_include_dirs, default_lib_dirs

Expand All @@ -28,15 +29,22 @@
elif os.getenv('PYTHON_FLINT_MINGW64_TMP'):
# This would be used to build under Windows against these libraries if
# they have been installed somewhere other than .local
libraries = ["flint", "mpfr", "gmp"]
libraries = ["arb", "flint", "mpfr", "gmp"]
else:
# For the MSVC toolchain link with mpir instead of gmp
libraries = ["flint", "mpir", "mpfr", "pthreads"]
libraries = ["arb", "flint", "mpir", "mpfr", "pthreads"]
else:
libraries = ["flint"]
# On Ubuntu libarb.so is called libflint-arb.so
if os.getenv('PYTHON_FLINT_LIBFLINT_ARB'):
arb = 'flint-arb'
else:
arb = 'arb'

libraries = [arb, "flint"]
(opt,) = get_config_vars('OPT')
os.environ['OPT'] = " ".join(flag for flag in opt.split() if flag != '-Wstrict-prototypes')


default_include_dirs += [
os.path.join(d, "flint") for d in default_include_dirs
]
Expand Down Expand Up @@ -70,6 +78,7 @@

setup(
name='python-flint',
cmdclass={'build_ext': build_ext},
ext_modules=cythonize(ext_modules, compiler_directives=compiler_directives),
#ext_modules=cythonize(ext_modules, compiler_directives=compiler_directives, annotate=True),
packages=['flint', 'flint.test'],
Expand Down
56 changes: 26 additions & 30 deletions src/flint/_flint.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ cdef extern from "flint/nmod_poly.h":
nmod_t mod
ctypedef nmod_poly_struct nmod_poly_t[1]

ctypedef struct nmod_poly_factor_struct:
nmod_poly_struct *p
long *exp
long num
long alloc
ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1]

void nmod_poly_init(nmod_poly_t poly, mp_limb_t n)
void nmod_poly_init_preinv(nmod_poly_t poly, mp_limb_t n, mp_limb_t ninv)
void nmod_poly_init2(nmod_poly_t poly, mp_limb_t n, long alloc)
Expand Down Expand Up @@ -149,15 +156,6 @@ cdef extern from "flint/nmod_poly.h":
void nmod_poly_exp_series(nmod_poly_t f, nmod_poly_t h, long n)

int nmod_poly_is_irreducible(nmod_poly_t f)

cdef extern from "flint/nmod_poly_factor.h":
ctypedef struct nmod_poly_factor_struct:
nmod_poly_struct *p
long *exp
long num
long alloc
ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1]

mp_limb_t nmod_poly_factor_with_berlekamp(nmod_poly_factor_t result, nmod_poly_t poly)
mp_limb_t nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t result, nmod_poly_t poly)
mp_limb_t nmod_poly_factor(nmod_poly_factor_t result, nmod_poly_t input)
Expand Down Expand Up @@ -755,7 +753,7 @@ cdef extern from "flint/arith.h":
void arith_chebyshev_u_polynomial(fmpz_poly_t v, ulong n)
void arith_cyclotomic_polynomial(fmpz_poly_t v, ulong n)

cdef extern from "flint/mag.h":
cdef extern from "mag.h":
ctypedef struct mag_struct:
fmpz_struct exp
mp_limb_t man
Expand All @@ -770,7 +768,7 @@ cdef extern from "flint/mag.h":
void mag_set_ui_2exp_si(mag_t x, ulong v, long e)
void mag_hypot(mag_t x, const mag_t y, const mag_t z)

cdef extern from "flint/arf.h":
cdef extern from "arf.h":
ctypedef struct arf_struct:
fmpz_struct exp
long size
Expand Down Expand Up @@ -904,7 +902,7 @@ cdef extern from "flint/arf.h":
double arf_get_d(const arf_t x, arf_rnd_t rnd)
void arf_set_d(arf_t x, double v)

cdef extern from "flint/arb.h":
cdef extern from "arb.h":
ctypedef struct arb_struct:
arf_struct mid
mag_struct rad
Expand Down Expand Up @@ -1195,7 +1193,7 @@ cdef extern from "flint/arb.h":
cdef ulong ARB_STR_CONDENSE
char * arb_get_str(const arb_t x, long n, ulong flags)

cdef extern from "flint/acb.h":
cdef extern from "acb.h":
ctypedef struct acb_struct:
arb_struct real
arb_struct imag
Expand Down Expand Up @@ -1386,15 +1384,15 @@ cdef extern from "flint/acb.h":

void acb_root_ui(acb_t z, const acb_t x, ulong k, long prec)

cdef extern from "flint/partitions.h":
cdef extern from "partitions.h":
void partitions_fmpz_fmpz(fmpz_t, const fmpz_t, int)

cdef extern from "flint/bernoulli.h":
cdef extern from "bernoulli.h":
void bernoulli_fmpq_ui(fmpq_t, ulong)
void bernoulli_cache_compute(long n)


cdef extern from "flint/arb_poly.h":
cdef extern from "arb_poly.h":
ctypedef struct arb_poly_struct:
arb_ptr coeffs
long length
Expand Down Expand Up @@ -1602,7 +1600,7 @@ cdef extern from "flint/arb_poly.h":

void arb_poly_lambertw_series(arb_poly_t res, const arb_poly_t z, int flags, long len, long prec)

cdef extern from "flint/arb_mat.h":
cdef extern from "arb_mat.h":
ctypedef struct arb_mat_struct:
arb_ptr entries
long r
Expand Down Expand Up @@ -1683,7 +1681,7 @@ cdef extern from "flint/arb_mat.h":

int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, long prec)

cdef extern from "flint/acb_poly.h":
cdef extern from "acb_poly.h":
ctypedef struct acb_poly_struct:
acb_ptr coeffs
long length
Expand Down Expand Up @@ -1888,7 +1886,7 @@ cdef extern from "flint/acb_poly.h":

void acb_poly_lambertw_series(acb_poly_t res, const acb_poly_t z, const fmpz_t k, int flags, long len, long prec)

cdef extern from "flint/acb_mat.h":
cdef extern from "acb_mat.h":
ctypedef struct acb_mat_struct:
acb_ptr entries
long r
Expand Down Expand Up @@ -1978,7 +1976,7 @@ cdef extern from "flint/acb_mat.h":
int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, long prec)


cdef extern from "flint/acb_modular.h":
cdef extern from "acb_modular.h":
void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec)
void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, long len, long prec)
void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, long len, long prec)
Expand All @@ -1994,7 +1992,7 @@ cdef extern from "flint/acb_modular.h":
void acb_modular_elliptic_e(acb_t w, const acb_t m, long prec)
void acb_modular_hilbert_class_poly(fmpz_poly_t res, long D)

cdef extern from "flint/acb_hypgeom.h":
cdef extern from "acb_hypgeom.h":
void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, long prec)
void acb_hypgeom_bessel_k(acb_t res, const acb_t nu, const acb_t z, long prec)
void acb_hypgeom_bessel_i(acb_t res, const acb_t nu, const acb_t z, long prec)
Expand Down Expand Up @@ -2072,7 +2070,7 @@ cdef extern from "flint/acb_hypgeom.h":
void acb_hypgeom_chi_series(acb_poly_t res, const acb_poly_t h, long n, long prec)
void acb_hypgeom_li_series(acb_poly_t res, const acb_poly_t h, int offset, long n, long prec)

cdef extern from "flint/arb_hypgeom.h":
cdef extern from "arb_hypgeom.h":
void arb_hypgeom_pfq(arb_t res, arb_srcptr a, long p, arb_srcptr b, long q, const arb_t z, int regularized, long prec)
void arb_hypgeom_0f1(arb_t res, const arb_t a, const arb_t z, int regularized, long prec)
void arb_hypgeom_m(arb_t res, const arb_t a, const arb_t b, const arb_t z, int regularized, long prec)
Expand Down Expand Up @@ -2137,7 +2135,7 @@ cdef extern from "flint/arb_hypgeom.h":

void arb_hypgeom_legendre_p_ui_root(arb_t res, arb_t weight, ulong n, ulong k, long prec)

cdef extern from "flint/dirichlet.h":
cdef extern from "dirichlet.h":
ctypedef struct dirichlet_group_struct:
ulong q
ulong q_even
Expand Down Expand Up @@ -2196,7 +2194,7 @@ cdef extern from "flint/dirichlet.h":
int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi)
ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n)

cdef extern from "flint/acb_dirichlet.h":
cdef extern from "acb_dirichlet.h":
void acb_dirichlet_eta(acb_t res, const acb_t s, long prec)
void acb_dirichlet_chi(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, ulong n, long prec)

Expand All @@ -2213,7 +2211,7 @@ cdef extern from "flint/acb_dirichlet.h":
void acb_dirichlet_zeta_zero(acb_t res, const fmpz_t n, long prec)
void acb_dirichlet_zeta_zeros(acb_ptr res, const fmpz_t n, long len, long prec)

cdef extern from "flint/acb_elliptic.h":
cdef extern from "acb_elliptic.h":
void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec)
void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, long prec)
void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, long prec)
Expand All @@ -2228,7 +2226,7 @@ cdef extern from "flint/acb_elliptic.h":
void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, long prec)
void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, long prec)

cdef extern from "flint/acb_calc.h":
cdef extern from "acb_calc.h":
ctypedef int (*acb_calc_func_t)(acb_ptr out, const acb_t inp, void * param, long order, long prec)

ctypedef struct acb_calc_integrate_opt_struct:
Expand All @@ -2248,14 +2246,14 @@ cdef extern from "flint/acb_calc.h":
const acb_calc_integrate_opt_t options,
long prec)

cdef extern from "flint/arb_fmpz_poly.h":
cdef extern from "arb_fmpz_poly.h":
void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, long prec)
void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, long prec)
void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly)
void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation)

cdef extern from "flint/acb_dft.h":
cdef extern from "acb_dft.h":
void acb_dft(acb_ptr w, acb_srcptr v, long n, long prec)
void acb_dft_inverse(acb_ptr w, acb_srcptr v, long n, long prec)

Expand Down Expand Up @@ -2397,8 +2395,6 @@ cdef extern from "flint/fmpz_mpoly.h":
void fmpz_mpoly_get_term_monomial(fmpz_mpoly_t M, const fmpz_mpoly_t A,
slong i, const fmpz_mpoly_ctx_t ctx)

void fmpz_mpoly_sort_terms(fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx)

# Addition/Subtraction
void fmpz_mpoly_add_fmpz(fmpz_mpoly_t A, const fmpz_mpoly_t B, const fmpz_t c, const fmpz_mpoly_ctx_t ctx)
void fmpz_mpoly_add_si(fmpz_mpoly_t A, const fmpz_mpoly_t B, slong c, const fmpz_mpoly_ctx_t ctx)
Expand Down
2 changes: 1 addition & 1 deletion src/flint/fmpz_mpoly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ cdef class fmpz_mpoly(flint_mpoly):
fmpz_mpoly_init(self.val, self.ctx.val)
self._init = True
fmpz_mpoly_set_str_pretty(self.val, val, self.ctx.c_names, self.ctx.val)
fmpz_mpoly_sort_terms(self.val, self.ctx.val)
# fmpz_mpoly_sort_terms(self.val, self.ctx.val)
else:
v = any_as_fmpz(val)
if v is NotImplemented:
Expand Down

0 comments on commit 89d567c

Please sign in to comment.