From c39edc018dae9a7369be7ff83c0d08338613a98e Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Thu, 13 Jun 2024 17:18:34 +0100 Subject: [PATCH 1/2] Add build option to set rpath on Linux --- .gitignore | 1 + meson.build | 10 ++++++++++ meson.options | 1 + requirements-dev.txt | 7 +++++++ 4 files changed, 19 insertions(+) create mode 100644 meson.options create mode 100644 requirements-dev.txt diff --git a/.gitignore b/.gitignore index 0f4570f3..075ec3ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/* +build-install/* dist/* src/flint/**/*.c src/flint/*.html diff --git a/meson.build b/meson.build index b4fe7f83..7e941dbb 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,16 @@ gmp_dep = dependency('gmp') mpfr_dep = dependency('mpfr') flint_dep = dependency('flint') +# Add rpaths for a local build of flint found via pkgconfig +# https://github.com/mesonbuild/meson/issues/13046 +if get_option('add_flint_rpath') + flint_lib_dir = flint_dep.get_pkgconfig_variable('libdir') + add_project_link_arguments( + '-Wl,-rpath=' + flint_lib_dir, + language: 'c', + ) +endif + # flint.pc was missing -lflint until Flint 3.1.0 if flint_dep.version().version_compare('<3.1') flint_dep = cc.find_library('flint') diff --git a/meson.options b/meson.options new file mode 100644 index 00000000..21079382 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('add_flint_rpath', type : 'boolean', value : false) diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..536a010f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,7 @@ +cython +spin +meson +meson-python +pytest +coverage +pytest-cov From d357d1f63ae3b33a811398a7e3e619bef08bae80 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Thu, 13 Jun 2024 17:44:25 +0100 Subject: [PATCH 2/2] Handle renamed Flint functions --- src/flint/flintlib/flint.pxd | 17 +++++++++++++++-- src/flint/pyflint.pyx | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/flint/flintlib/flint.pxd b/src/flint/flintlib/flint.pxd index 739cc9d2..65ed5d84 100644 --- a/src/flint/flintlib/flint.pxd +++ b/src/flint/flintlib/flint.pxd @@ -36,13 +36,26 @@ cdef extern from "flint/fmpz.h": ctypedef slong fmpz_struct +cdef extern from *: + """ + /* + * Functions renamed in Flint 3.2.0 + */ + #if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */ + + #define flint_rand_init flint_randinit + #define flint_rand_clear flint_randclear + + #endif + """ + cdef extern from "flint/flint.h": const char * FLINT_VERSION const int __FLINT_RELEASE const int FLINT_BITS ctypedef void * flint_rand_t - void flint_randinit(flint_rand_t state) - void flint_randclear(flint_rand_t state) + void flint_rand_init(flint_rand_t state) + void flint_rand_clear(flint_rand_t state) void flint_set_num_threads(long) long flint_get_num_threads() void flint_cleanup() diff --git a/src/flint/pyflint.pyx b/src/flint/pyflint.pyx index 5c4770d1..fcb6afbe 100644 --- a/src/flint/pyflint.pyx +++ b/src/flint/pyflint.pyx @@ -9,6 +9,6 @@ cimport cython from flint.flint_base.flint_context cimport thectx cdef flint_rand_t global_random_state -flint_randinit(global_random_state) +flint_rand_init(global_random_state) ctx = thectx