Skip to content

Commit da48588

Browse files
Merge pull request #61 from GiacomoPope/introduce-submodules
Introduce submodules into python-flint
2 parents 71bf110 + 644b5bb commit da48588

34 files changed

+407
-213
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build/*
22
dist/*
3-
src/flint/*.c
3+
src/flint/**/*.c
44
src/flint/*.html
55
doc/build/*
66
fmake*
@@ -16,3 +16,4 @@ MANIFEST
1616
.coverage
1717
*.swp
1818
.python-version
19+
*.DS_Store

setup.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,26 @@
6363
compiler_directives['linetrace'] = True
6464

6565

66-
ext_modules = [
67-
Extension(
68-
"flint._flint", ["src/flint/pyflint.pyx"],
69-
libraries=libraries,
70-
library_dirs=default_lib_dirs,
71-
include_dirs=default_include_dirs,
72-
define_macros=define_macros,
73-
)
66+
ext_files = [
67+
("flint._flint", ["src/flint/pyflint.pyx"]), # Main Module
68+
# Submodules
69+
("flint.flint_base.flint_base", ["src/flint/flint_base/flint_base.pyx"]),
70+
("flint.flint_base.flint_context", ["src/flint/flint_base/flint_context.pyx"]),
71+
7472
]
7573

74+
ext_options = {
75+
"libraries" : libraries,
76+
"library_dirs" : default_lib_dirs,
77+
"include_dirs" : default_include_dirs,
78+
"define_macros" : define_macros,
79+
}
80+
81+
ext_modules = []
82+
for mod_name, src_files in ext_files:
83+
ext = Extension(mod_name, src_files, **ext_options)
84+
ext_modules.append(ext)
85+
7686
for e in ext_modules:
7787
e.cython_directives = {"embedsignature": True}
7888

@@ -92,3 +102,4 @@
92102
author_email='[email protected]',
93103
license='MIT',
94104
classifiers=['Topic :: Scientific/Engineering :: Mathematics'])
105+

src/flint/acb.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from flint.flint_base.flint_base cimport flint_scalar
2+
from flint.flint_base.flint_context cimport getprec
3+
14
cdef int acb_set_python(acb_t x, obj, bint allow_conversion):
25
cdef double re, im
36

src/flint/acb_mat.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from flint.flint_base.flint_context cimport getprec
2+
3+
from flint.flint_base.flint_base cimport flint_mat
4+
15
cdef acb_mat_coerce_operands(x, y):
26
if isinstance(y, (fmpz_mat, fmpq_mat, arb_mat)):
37
return x, acb_mat(y)

src/flint/acb_poly.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
from flint.flint_base.flint_context cimport getprec
2+
# TODO: waiting for fix on the roots method, currently
3+
# globally defined.
4+
# from flint.flint_base.flint_base cimport flint_poly
5+
16
cdef acb_poly_coerce_operands(x, y):
27
if isinstance(y, (int, long, float, complex, fmpz, fmpq, arb, acb, fmpz_poly, fmpq_poly, arb_poly)):
38
return x, acb_poly(y)

src/flint/acb_series.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from flint.flint_base.flint_context cimport getprec, getcap
2+
from flint.flint_base.flint_base cimport flint_series
3+
14
cdef acb_series_coerce_operands(x, y):
25
if isinstance(y, (int, long, float, complex, fmpz, fmpz_poly, fmpz_series, fmpq, fmpq_poly, fmpq_series, arb, arb_poly, arb_series, acb, acb_poly)):
36
return x, acb_series(y)

src/flint/arb.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from cpython.version cimport PY_MAJOR_VERSION
2+
3+
from flint.flint_base.flint_context cimport getprec
4+
from flint.flint_base.flint_base cimport flint_scalar
5+
from flint.utils.conversion cimport chars_from_str, str_from_chars
6+
17
cdef _str_trunc(s, trunc=0):
28
if trunc > 0 and len(s) > 3 * trunc:
39
left = right = trunc

src/flint/arb_mat.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from flint.flint_base.flint_context cimport getprec
2+
from flint.flint_base.flint_base cimport flint_mat
3+
14
cdef arb_mat_coerce_operands(x, y):
25
if isinstance(y, (fmpz_mat, fmpq_mat)):
36
return x, arb_mat(y)

src/flint/arb_poly.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
from flint.flint_base.flint_context cimport getprec
2+
# TODO: waiting for fix on the roots method, currently
3+
# globally defined.
4+
# from flint.flint_base.flint_base cimport flint_poly
5+
16
cdef arb_poly_coerce_operands(x, y):
27
if isinstance(y, (int, long, float, fmpz, fmpq, arb, fmpz_poly, fmpq_poly)):
38
return x, arb_poly(y)

src/flint/arb_series.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from flint.flint_base.flint_context cimport getprec, getcap
2+
from flint.flint_base.flint_base cimport flint_series
3+
14
cdef arb_series_coerce_operands(x, y):
25
if isinstance(y, (int, long, float, fmpz, fmpz_poly, fmpz_series, fmpq, fmpq_poly, fmpq_series, arb, arb_poly)):
36
return x, arb_series(y)

0 commit comments

Comments
 (0)