From 1e47d959c4edd9c15e1f893a570e4b0082a39501 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 29 Sep 2024 16:25:26 -0500 Subject: [PATCH 01/15] cython 3.1 fixes --- cmake/cython_test.pyx | 3 --- symengine/lib/symengine_wrapper.in.pyx | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index 22cdb17c6..cb803c60d 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -1,6 +1,3 @@ -# Test that numpy works in Cython: -from numpy cimport ndarray - # Test that libcpp module is present: from libcpp.vector cimport vector from libcpp.string cimport string diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8bb9f9cb8..26c31ad87 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -5135,24 +5135,24 @@ cdef class _Lambdify(object): return result -cdef double _scipy_callback_lambda_real(int n, double *x, void *user_data) nogil: +cdef double _scipy_callback_lambda_real(int n, double *x, void *user_data) noexcept nogil: cdef symengine.LambdaRealDoubleVisitor* lamb = user_data cdef double result deref(lamb).call(&result, x) return result -cdef void _ctypes_callback_lambda_real(double *output, const double *input, void *user_data) nogil: +cdef void _ctypes_callback_lambda_real(double *output, const double *input, void *user_data) noexcept nogil: cdef symengine.LambdaRealDoubleVisitor* lamb = user_data deref(lamb).call(output, input) IF HAVE_SYMENGINE_LLVM: - cdef double _scipy_callback_llvm_real(int n, double *x, void *user_data) nogil: + cdef double _scipy_callback_llvm_real(int n, double *x, void *user_data) noexcept nogil: cdef symengine.LLVMDoubleVisitor* lamb = user_data cdef double result deref(lamb).call(&result, x) return result - cdef void _ctypes_callback_llvm_real(double *output, const double *input, void *user_data) nogil: + cdef void _ctypes_callback_llvm_real(double *output, const double *input, void *user_data) noexcept nogil: cdef symengine.LLVMDoubleVisitor* lamb = user_data deref(lamb).call(output, input) From 845168d3683f28781b32577abf4f38ed93f0bc79 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Sep 2024 11:38:54 -0500 Subject: [PATCH 02/15] Another cython 3.1 fix --- cmake/cython_test.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index cb803c60d..47f98476d 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -75,8 +75,8 @@ cdef extern from "" namespace "SymEngine": string get_name() nogil cdef extern from "" namespace "SymEngine": - cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except+ - cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except+ + cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil + cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) From 170e7ded46b60ee43ec1e6ee997fd95205cad2f4 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Sep 2024 11:39:06 -0500 Subject: [PATCH 03/15] freethreading support --- cmake/FindPython.cmake | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index f3381327e..2f54f5096 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -22,26 +22,36 @@ execute_process( string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH) execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" - OUTPUT_VARIABLE PYTHON_PREFIX_PATH - ) + COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" + OUTPUT_VARIABLE PYTHON_PREFIX_PATH +) string(STRIP ${PYTHON_PREFIX_PATH} PYTHON_PREFIX_PATH) execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" + COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" OUTPUT_VARIABLE PYTHON_VERSION - ) +) string(STRIP ${PYTHON_VERSION} PYTHON_VERSION) message(STATUS "Python version: ${PYTHON_VERSION}") string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION}) +execute_process( + COMMAND ${PYTHON_BIN} -c "import sysconfig;print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))" + OUTPUT_VARIABLE PY_GIL_DISABLED +) +string(STRIP ${PY_GIL_DISABLED} PY_GIL_DISABLED) + +if ("${PY_GIL_DISABLED}" STREQUAL "True") + set (PY_THREAD "t") +endif() + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") FIND_LIBRARY(PYTHON_LIBRARY NAMES - python${PYTHON_VERSION} + python${PYTHON_VERSION}${PY_THREAD} python${PYTHON_VERSION}m - python${PYTHON_VERSION_WITHOUT_DOTS} + python${PYTHON_VERSION_WITHOUT_DOTS}${PY_THREAD} PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} NO_DEFAULT_PATH @@ -51,8 +61,8 @@ endif() execute_process( COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])" - OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp - ) + OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp +) string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp} CACHE BOOL "Python install path") @@ -129,5 +139,9 @@ macro(ADD_PYTHON_LIBRARY name) IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(${name} ${PYTHON_LIBRARY}) set_target_properties(${name} PROPERTIES SUFFIX ".pyd") + IF("${PY_GIL_DISABLED}" STREQUAL "True") + target_compile_definitions(${name} PRIVATE Py_GIL_DISABLED=1) + ENDIF() ENDIF() + endmacro(ADD_PYTHON_LIBRARY) From 8157e6a483b72a6278606ebf5c53f2fae414e734 Mon Sep 17 00:00:00 2001 From: Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:18:50 -0800 Subject: [PATCH 04/15] Fix build with spaces Building symenginepy as part of the SymForce build, I get an error currently if I try to build under a source directory with a space in the path: ``` [100%] Linking CXX shared library symengine_wrapper.cpython-38-x86_64-linux-gnu.so c++: error: test/build/symenginepy-prefix/src/symenginepy-build/build/lib.linux-x86_64-cpython-38/symengine/lib/version_script_symengine_wrapper.txt: No such file or directory make[5]: *** [symengine/lib/CMakeFiles/symengine_wrapper.dir/build.make:121: symengine/lib/symengine_wrapper.cpython-38-x86_64-linux-gnu.so] Error 1 make[4]: *** [CMakeFiles/Makefile2:132: symengine/lib/CMakeFiles/symengine_wrapper.dir/all] Error 2 make[3]: *** [Makefile:136: all] Error 2 error: error building project make[2]: *** [CMakeFiles/symenginepy.dir/build.make:86: symenginepy-prefix/src/symenginepy-stamp/symenginepy-build] Error 1 ``` This change seems to fix that. I'm not 100% sure in what scenarios this applies to a standalone build of symengine? But I figured I'd open a PR and propose this change Coming from here on the SymForce repo: https://github.com/symforce-org/symforce/pull/414 --- cmake/FindPython.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index 2f54f5096..df8bfdc15 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -130,7 +130,7 @@ macro(ADD_PYTHON_LIBRARY name) configure_file(${CMAKE_SOURCE_DIR}/cmake/version_script.txt ${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt @ONLY) set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt") + LINK_FLAGS " \"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt\"") ELSE() add_library(${name} SHARED ${ARGN}) ENDIF() From 0bc912b865cc4ce643011c92d93c9ffb7670c67a Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 21 Dec 2024 14:46:10 +0530 Subject: [PATCH 05/15] Fix CI --- bin/install_travis.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install_travis.sh b/bin/install_travis.sh index 8176202dc..572bb0d2b 100644 --- a/bin/install_travis.sh +++ b/bin/install_travis.sh @@ -2,7 +2,7 @@ # symengine's bin/install_travis.sh will install miniconda -export conda_pkgs="python=${PYTHON_VERSION} pip 'cython>=0.29.24' pytest gmp mpfr" +export conda_pkgs="python=${PYTHON_VERSION} pip pytest gmp mpfr" if [[ "${WITH_NUMPY}" != "no" ]]; then export conda_pkgs="${conda_pkgs} numpy"; @@ -27,7 +27,7 @@ if [[ "${WITH_SAGE}" == "yes" ]]; then export conda_pkgs="${conda_pkgs} sage=8.1"; fi -conda install -q ${conda_pkgs} +conda install -q ${conda_pkgs} "cython>=0.29.24" if [[ "${WITH_SYMPY}" != "no" ]]; then pip install sympy; From 21485318d0ba4ece84df8fb9b2cc646fd2fea06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Mon, 13 Jan 2025 15:16:48 +0100 Subject: [PATCH 06/15] normlize cython syntax: cython/cython#5430 --- cmake/cython_test.pyx | 4 +- symengine/lib/symengine.pxd | 304 ++++++++++++++++++------------------ 2 files changed, 154 insertions(+), 154 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index 47f98476d..e97be0b43 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -75,8 +75,8 @@ cdef extern from "" namespace "SymEngine": string get_name() nogil cdef extern from "" namespace "SymEngine": - cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil - cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil + cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except + + cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except + cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 3e2b5d08a..65b3456aa 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -51,11 +51,11 @@ cdef extern from "" namespace "SymEngine": cdef cppclass RCP[T]: T& operator*() nogil # Not yet supported in Cython: -# RCP[T]& operator=(RCP[T] &r_ptr) except+ nogil - void reset() except+ nogil +# RCP[T]& operator=(RCP[T] &r_ptr) nogil except + + void reset() nogil except + cdef cppclass Ptr[T]: - T& operator*() except+ nogil + T& operator*() nogil except + void print_stack_on_segfault() nogil @@ -65,7 +65,7 @@ cdef extern from "" namespace "SymEngine": ctypedef RCP[const_Basic] rcp_const_basic "SymEngine::RCP" #cdef cppclass rcp_const_basic "SymEngine::RCP": # Basic& operator*() nogil - # void reset() except+ nogil + # void reset() nogil except + # pass # Cython has broken support for the following: # ctypedef map[rcp_const_basic, rcp_const_basic] map_basic_basic @@ -112,8 +112,8 @@ cdef extern from "" namespace "SymEngine": ctypedef multiset[rcp_const_basic] multiset_basic "SymEngine::multiset_basic" cdef cppclass Basic: - string __str__() except+ nogil - unsigned int hash() except+ nogil + string __str__() nogil except + + unsigned int hash() nogil except + vec_basic get_args() nogil int __cmp__(const Basic &o) nogil @@ -124,11 +124,11 @@ cdef extern from "" namespace "SymEngine": ctypedef unordered_map[rcp_const_basic, rcp_const_number].iterator umap_basic_num_iterator "SymEngine::umap_basic_num::iterator" ctypedef vector[pair[rcp_const_basic, rcp_const_basic]] vec_pair "SymEngine::vec_pair" - bool eq(const Basic &a, const Basic &b) except+ nogil - bool neq(const Basic &a, const Basic &b) except+ nogil + bool eq(const Basic &a, const Basic &b) nogil except + + bool neq(const Basic &a, const Basic &b) nogil except + RCP[const Symbol] rcp_static_cast_Symbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) except+ nogil + RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil except + RCP[const Integer] rcp_static_cast_Integer "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Rational] rcp_static_cast_Rational "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Complex] rcp_static_cast_Complex "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil @@ -162,18 +162,18 @@ cdef extern from "" namespace "SymEngine": bool is_a[T] (const Basic &b) nogil bool is_a_sub[T] (const Basic &b) nogil - rcp_const_basic expand(rcp_const_basic &o, bool deep) except+ nogil + rcp_const_basic expand(rcp_const_basic &o, bool deep) nogil except + void as_numer_denom(rcp_const_basic &x, const Ptr[RCP[Basic]] &numer, const Ptr[RCP[Basic]] &denom) nogil void as_real_imag(rcp_const_basic &x, const Ptr[RCP[Basic]] &real, const Ptr[RCP[Basic]] &imag) nogil - void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) except+ nogil + void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil - rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil - rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) except+ nogil + rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + + rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + + rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) except+ nogil + rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Symbol(Basic): @@ -215,8 +215,8 @@ cdef extern from "pywrapper.h" namespace "SymEngine": PySymbol(string name, PyObject* pyobj, bool use_pickle) except + PyObject* get_py_object() except + - string wrapper_dumps(const Basic &x) except+ nogil - rcp_const_basic wrapper_loads(const string &s) except+ nogil + string wrapper_dumps(const Basic &x) nogil except + + rcp_const_basic wrapper_loads(const string &s) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Integer(Number): @@ -286,9 +286,9 @@ cdef extern from "" namespace "SymEngine": pass cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic add(const vec_basic &a) except+ nogil + cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic add(const vec_basic &a) nogil except + cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -296,10 +296,10 @@ cdef extern from "" namespace "SymEngine": const umap_basic_num &get_dict() cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic neg(rcp_const_basic &a) except+ nogil - cdef rcp_const_basic mul(const vec_basic &a) except+ nogil + cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic neg(rcp_const_basic &a) nogil except + + cdef rcp_const_basic mul(const vec_basic &a) nogil except + cdef cppclass Mul(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -308,9 +308,9 @@ cdef extern from "" namespace "SymEngine": cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &d) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic sqrt(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic exp(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic sqrt(rcp_const_basic &x) nogil except + + cdef rcp_const_basic exp(rcp_const_basic &x) nogil except + cdef cppclass Pow(Basic): rcp_const_basic get_base() nogil @@ -344,58 +344,58 @@ cdef extern from "" namespace "SymEngine": RCP[const PyFunctionClass] pyfunc_class, const PyObject* pyobject) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic sin(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cos(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic tan(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cot(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic csc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sec(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asin(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acos(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atan(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acot(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acsc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asec(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sinh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cosh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic tanh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic coth(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic csch(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sech(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asinh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acosh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atanh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acoth(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acsch(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asech(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) except+ nogil - cdef rcp_const_basic abs(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic max(const vec_basic &arg) except+ nogil - cdef rcp_const_basic min(const vec_basic &arg) except+ nogil - cdef rcp_const_basic gamma(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) except+ nogil - cdef rcp_const_basic lambertw(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic zeta(rcp_const_basic &s) except+ nogil - cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) except+ nogil - cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) except+ nogil - cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) except+ nogil - cdef rcp_const_basic levi_civita(const vec_basic &arg) except+ nogil - cdef rcp_const_basic erf(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic erfc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic loggamma(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) except+ nogil - cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic digamma(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic trigamma(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic sign(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic floor(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic ceiling(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic conjugate(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic log(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) except+ nogil - cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic sin(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cos(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic tan(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cot(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic csc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sec(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asin(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acos(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atan(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acot(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acsc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asec(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sinh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cosh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic tanh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic coth(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic csch(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sech(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asinh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acosh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atanh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acoth(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acsch(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asech(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) nogil except + + cdef rcp_const_basic abs(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic max(const vec_basic &arg) nogil except + + cdef rcp_const_basic min(const vec_basic &arg) nogil except + + cdef rcp_const_basic gamma(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) nogil except + + cdef rcp_const_basic lambertw(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic zeta(rcp_const_basic &s) nogil except + + cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) nogil except + + cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) nogil except + + cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) nogil except + + cdef rcp_const_basic levi_civita(const vec_basic &arg) nogil except + + cdef rcp_const_basic erf(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic erfc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + + cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + + cdef rcp_const_basic loggamma(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) nogil except + + cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) nogil except + + cdef rcp_const_basic digamma(rcp_const_basic &x) nogil except + + cdef rcp_const_basic trigamma(rcp_const_basic &x) nogil except + + cdef rcp_const_basic sign(rcp_const_basic &x) nogil except + + cdef rcp_const_basic floor(rcp_const_basic &x) nogil except + + cdef rcp_const_basic ceiling(rcp_const_basic &x) nogil except + + cdef rcp_const_basic conjugate(rcp_const_basic &x) nogil except + + cdef rcp_const_basic log(rcp_const_basic &x) nogil except + + cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) nogil except + + cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) nogil except + cdef cppclass Function(Basic): pass @@ -632,7 +632,7 @@ cdef extern from "" namespace "SymEngine": const unsigned ncols() nogil rcp_const_basic get(unsigned i, unsigned j) nogil rcp_const_basic set(unsigned i, unsigned j, rcp_const_basic e) nogil - string __str__() except+ nogil + string __str__() nogil except + bool eq(const MatrixBase &) nogil rcp_const_basic det() nogil void inv(MatrixBase &) @@ -681,20 +681,20 @@ cdef extern from "" namespace "SymEngine": DenseMatrix* static_cast_DenseMatrix "static_cast"(const MatrixBase *a) void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A, - DenseMatrix &B) except+ nogil - void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) except+ nogil + DenseMatrix &B) nogil except + + void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil except + void inverse_GJ "SymEngine::inverse_gauss_jordan"(const DenseMatrix &A, - DenseMatrix &B) except+ nogil + DenseMatrix &B) nogil except + void FFLU_solve "SymEngine::fraction_free_LU_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) except+ nogil + const DenseMatrix &b, DenseMatrix &x) nogil except + void FFGJ_solve "SymEngine::fraction_free_gauss_jordan_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) except+ nogil + const DenseMatrix &b, DenseMatrix &x) nogil except + void LDL_solve "SymEngine::LDL_solve"(const DenseMatrix &A, const DenseMatrix &b, - DenseMatrix &x) except+ nogil + DenseMatrix &x) nogil except + void jacobian "SymEngine::sjacobian"(const DenseMatrix &A, - const DenseMatrix &x, DenseMatrix &result) except+ nogil + const DenseMatrix &x, DenseMatrix &result) nogil except + void diff "SymEngine::sdiff"(const DenseMatrix &A, - rcp_const_basic &x, DenseMatrix &result) except+ nogil + rcp_const_basic &x, DenseMatrix &result) nogil except + void eye (DenseMatrix &A, int k) nogil void diag(DenseMatrix &A, vec_basic &v, int k) nogil void ones(DenseMatrix &A) nogil @@ -707,7 +707,7 @@ cdef extern from "" namespace "SymEngine": void cross(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C) nogil cdef extern from "": - void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) except+ nogil + void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) nogil except + cdef extern from "" namespace "SymEngine": int probab_prime_p(const Integer &a, int reps) @@ -716,10 +716,10 @@ cdef extern from "" namespace "SymEngine": RCP[const Integer] lcm(const Integer &a, const Integer &b) nogil void gcd_ext(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, const Ptr[RCP[Integer]] &t, const Integer &a, const Integer &b) nogil - RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) except+ nogil - RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) except+ nogil + RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) nogil except + + RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) nogil except + void quotient_mod "SymEngine::quotient_mod_f"(const Ptr[RCP[Integer]] &q, const Ptr[RCP[Integer]] &mod, - const Integer &n, const Integer &d) except+ nogil + const Integer &n, const Integer &d) nogil except + int mod_inverse(const Ptr[RCP[Integer]] &b, const Integer &a, const Integer &m) nogil bool crt(const Ptr[RCP[Integer]] &R, const vec_integer &rem, @@ -739,9 +739,9 @@ cdef extern from "" namespace "SymEngine": unsigned B, unsigned retries) nogil int factor_pollard_rho_method(const Ptr[RCP[Integer]] &f, const Integer &n, unsigned retries) nogil - void prime_factors(vec_integer &primes, const Integer &n) except+ nogil - void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) except+ nogil - RCP[const Number] bernoulli(unsigned long n) except+ nogil + void prime_factors(vec_integer &primes, const Integer &n) nogil except + + void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) nogil except + + RCP[const Number] bernoulli(unsigned long n) nogil except + bool primitive_root(const Ptr[RCP[Integer]] &g, const Integer &n) nogil void primitive_root_list(vec_integer &roots, const Integer &n) nogil RCP[const Integer] totient(RCP[const Integer] n) nogil @@ -769,15 +769,15 @@ cdef extern from "" namespace "SymEngine": unsigned next_prime() nogil cdef extern from "" namespace "SymEngine": - bool has_symbol(const Basic &b, const Basic &x) except+ nogil - rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) except+ nogil - set_basic free_symbols(const Basic &b) except+ nogil - set_basic free_symbols(const MatrixBase &b) except+ nogil + bool has_symbol(const Basic &b, const Basic &x) nogil except + + rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except + + set_basic free_symbols(const Basic &b) nogil except + + set_basic free_symbols(const MatrixBase &b) nogil except + unsigned count_ops(const vec_basic &a) nogil cdef extern from "" namespace "SymEngine": cdef cppclass Boolean(Basic): - RCP[const Boolean] logical_not() except+ nogil + RCP[const Boolean] logical_not() nogil except + cdef cppclass BooleanAtom(Boolean): bool get_val() nogil cdef cppclass Relational(Boolean): @@ -805,25 +805,25 @@ cdef extern from "" namespace "SymEngine": rcp_const_basic boolTrue rcp_const_basic boolFalse - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) except+ nogil - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) nogil except + + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + ctypedef Boolean const_Boolean "const SymEngine::Boolean" ctypedef vector[pair[rcp_const_basic, RCP[const_Boolean]]] PiecewiseVec; ctypedef vector[RCP[Boolean]] vec_boolean "SymEngine::vec_boolean" ctypedef set[RCP[Boolean]] set_boolean "SymEngine::set_boolean" - cdef RCP[const Boolean] logical_and(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_nand(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_or(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) except+ nogil - cdef RCP[const Boolean] logical_nor(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_xor(vec_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_xnor(vec_boolean &s) except+ nogil - cdef rcp_const_basic piecewise(PiecewiseVec vec) except+ nogil + cdef RCP[const Boolean] logical_and(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_nand(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_or(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) nogil except + + cdef RCP[const Boolean] logical_nor(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_xor(vec_boolean &s) nogil except + + cdef RCP[const Boolean] logical_xnor(vec_boolean &s) nogil except + + cdef rcp_const_basic piecewise(PiecewiseVec vec) nogil except + cdef RCP[const Boolean] contains(rcp_const_basic &expr, RCP[const Set] &set) nogil @@ -833,26 +833,26 @@ cdef extern from "" namespace "SymEngine": cdef EvalfDomain EvalfComplex "SymEngine::EvalfDomain::Complex" cdef EvalfDomain EvalfReal "SymEngine::EvalfDomain::Real" cdef EvalfDomain EvalfSymbolic "SymEngine::EvalfDomain::Symbolic" - rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) except+ nogil + rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) nogil except + cdef extern from "" namespace "SymEngine": - double eval_double(const Basic &b) except+ nogil - double complex eval_complex_double(const Basic &b) except+ nogil + double eval_double(const Basic &b) nogil except + + double complex eval_complex_double(const Basic &b) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass LambdaRealDoubleVisitor: LambdaRealDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + void call(double *r, const double *x) nogil cdef cppclass LambdaComplexDoubleVisitor: LambdaComplexDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + void call(double complex *r, const double complex *x) nogil cdef extern from "" namespace "SymEngine": cdef cppclass LLVMVisitor: LLVMVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except + const string& dumps() nogil void loads(const string&) nogil @@ -868,27 +868,27 @@ cdef extern from "" namespace "SymEngine": cdef extern from "" namespace "SymEngine": cdef cppclass SeriesCoeffInterface: - rcp_const_basic as_basic() except+ nogil - umap_int_basic as_dict() except+ nogil - rcp_const_basic get_coeff(int) except+ nogil + rcp_const_basic as_basic() nogil except + + umap_int_basic as_dict() nogil except + + rcp_const_basic get_coeff(int) nogil except + ctypedef RCP[const SeriesCoeffInterface] rcp_const_seriescoeffinterface "SymEngine::RCP" - rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) except+ nogil + rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) nogil except + cdef extern from "" namespace "SymEngine": - void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil + void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + cdef extern from "" namespace "SymEngine": - void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil + void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic parse(const string &n) except+ nogil + rcp_const_basic parse(const string &n) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Set(Basic): - RCP[const Set] set_intersection(RCP[const Set] &o) except+ nogil - RCP[const Set] set_union(RCP[const Set] &o) except+ nogil - RCP[const Set] set_complement(RCP[const Set] &o) except+ nogil - RCP[const Boolean] contains(rcp_const_basic &a) except+ nogil + RCP[const Set] set_intersection(RCP[const Set] &o) nogil except + + RCP[const Set] set_union(RCP[const Set] &o) nogil except + + RCP[const Set] set_complement(RCP[const Set] &o) nogil except + + RCP[const Boolean] contains(rcp_const_basic &a) nogil except + cdef cppclass Interval(Set): pass cdef cppclass EmptySet(Set): @@ -912,24 +912,24 @@ cdef extern from "" namespace "SymEngine": cdef cppclass ImageSet(Set): pass ctypedef set[RCP[Set]] set_set "SymEngine::set_set" - cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) except+ nogil - cdef RCP[const EmptySet] emptyset() except+ nogil - cdef RCP[const Reals] reals() except+ nogil - cdef RCP[const Rationals] rationals() except+ nogil - cdef RCP[const Integers] integers() except+ nogil - cdef RCP[const UniversalSet] universalset() except+ nogil - cdef RCP[const Set] finiteset(set_basic &container) except+ nogil - cdef RCP[const Set] set_union(set_set &a) except+ nogil - cdef RCP[const Set] set_intersection(set_set &a) except+ nogil - cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) except+ nogil - cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) except+ nogil - cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) except+ nogil - cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) except+ nogil + cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) nogil except + + cdef RCP[const EmptySet] emptyset() nogil except + + cdef RCP[const Reals] reals() nogil except + + cdef RCP[const Rationals] rationals() nogil except + + cdef RCP[const Integers] integers() nogil except + + cdef RCP[const UniversalSet] universalset() nogil except + + cdef RCP[const Set] finiteset(set_basic &container) nogil except + + cdef RCP[const Set] set_union(set_set &a) nogil except + + cdef RCP[const Set] set_intersection(set_set &a) nogil except + + cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) nogil except + + cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) nogil except + + cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) nogil except + + cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) nogil except + cdef extern from "" namespace "SymEngine": - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) except+ nogil - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) except+ nogil - cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) except+ nogil + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) nogil except + + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) nogil except + + cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) nogil except + cdef extern from "symengine/tribool.h" namespace "SymEngine": cdef cppclass tribool: @@ -945,10 +945,10 @@ cdef extern from "symengine/tribool.h" namespace "SymEngine::tribool": cdef tribool tritrue cdef extern from "" namespace "SymEngine": - string ccode(const Basic &x) except+ nogil - string latex(const Basic &x) except+ nogil - string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) except+ nogil - string unicode(const Basic &x) except+ nogil + string ccode(const Basic &x) nogil except + + string latex(const Basic &x) nogil except + + string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) nogil except + + string unicode(const Basic &x) nogil except + ## Defined in 'symengine/cwrapper.cpp' cdef struct CRCPBasic: From cb92ff6a9190ada12daaff78ca31cb97bad2b618 Mon Sep 17 00:00:00 2001 From: firatbezir Date: Mon, 10 Feb 2025 22:01:51 +0300 Subject: [PATCH 07/15] Update README with verification instructions --- README.md | 108 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 847af7d6f..d9141c7c1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ + # SymEngine Python Wrappers -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), +Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), a fast C++ symbolic manipulation library. -[![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) [![Build status](https://ci.appveyor.com/api/projects/status/sl189l9ck3gd8qvk/branch/master?svg=true)](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) +[![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) +[![Build status](https://ci.appveyor.com/api/projects/status/sl189l9ck3gd8qvk/branch/master?svg=true)](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) ## Installation @@ -11,71 +13,91 @@ a fast C++ symbolic manipulation library. See License section for information about wheels - pip install symengine --user +```bash +pip install symengine --user +``` ### Conda package manager - conda install python-symengine -c symengine -c conda-forge +```bash +conda install python-symengine -c symengine -c conda-forge +``` -optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): +Optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): - conda install python-symengine -c symengine/label/dev -c conda-forge +```bash +conda install python-symengine -c symengine/label/dev -c conda-forge +``` ### Build from source Install prerequisites. - CMake >= 2.8.12 - Python3 >= 3.8 - Cython >= 0.29.24 - SymEngine >= 0.7.0 +```bash +CMake >= 2.8.12 +Python3 >= 3.8 +Cython >= 0.29.24 +SymEngine >= 0.7.0 +``` -For SymEngine, only a specific commit/tag (see symengine_version.txt) is supported. -Latest git master branch may not work as there may be breaking changes in SymEngine. +For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is supported. +The latest git master branch may not work as there may be breaking changes in **SymEngine**. Python wrappers can be installed by, - python setup.py install +```bash +python setup.py install +``` + +Additional options to `setup.py` are: + +```bash +python setup.py install build_ext + --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory + --compiler=mingw32|msvc|cygwin # Select the compiler for Windows + --generator=cmake-generator # CMake Generator + --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC + --define="var1=value1;var2=value2" # Give options to CMake + --inplace # Build the extension in source tree +``` + +Standard options to `setup.py` like `--user`, `--prefix` can be used to configure install location. +NumPy is used if found by default, if you wish to make your choice of NumPy use explicit: then add e.g. `WITH_NUMPY=False` to `--define`. + +### Notes on Dependencies -Additional options to setup.py are +If you intend to evaluate floating-point expressions (using **lambdify**), you should consider linking against **LLVM**. Many users might also benefit from linking against **FLINT**, as it is now LGPL-licensed. - python setup.py install build_ext - --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory - --compiler=mingw32|msvc|cygwin # Select the compiler for Windows - --generator=cmake-generator # CMake Generator - --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC - --define="var1=value1;var2=value2" # Give options to CMake - --inplace # Build the extension in source tree +In general, **sudo** is only required if you are installing to the default prefix (`/usr/local`). We recommend specifying a custom prefix (`--prefix=$HOME/.local`) to avoid requiring administrative privileges, which most users can do without using **sudo**. -Standard options to setup.py like `--user`, `--prefix` can be used to -configure install location. NumPy is used if found by default, if you wish -to make your choice of NumPy use explicit: then add -e.g. ``WITH_NUMPY=False`` to ``--define``. +If you're uncomfortable specifying the prefix manually, we suggest using **Conda** or installing the pre-built wheels via **pip** instead of building from source. -Use SymEngine from Python as follows: +## Verification - >>> from symengine import var - >>> var("x y z") - (x, y, z) - >>> e = (x+y+z)**2 - >>> e.expand() - 2*x*y + 2*x*z + 2*y*z + x**2 + y**2 + z**2 +You can verify the installation of **SymEngine** by using the provided code snippet in this README. This snippet ensures that the installation works as expected and that basic functionality is available. -You can read Python tests in `symengine/tests` to see what features are -implemented. +```python +from symengine import var +x, y, z = var('x y z') +e = (x + y + z)**2 +expanded_e = e.expand() +print(expanded_e) +``` +This will output: +```python +x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z +``` +Note: The verification code provided above checks the functionality of SymEngine. For additional verification specific to SymEngine, please refer to the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) for further tests and examples. ## License -symengine.py is MIT licensed and uses several LGPL, BSD-3 and MIT licensed libraries +symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed libraries. -Licenses for the dependencies of pip wheels are as follows, +Licenses for the dependencies of pip wheels are as follows: -pip wheels on Unix use GMP (LGPL-3.0-or-later), MPFR (LGPL-3.0-or-later), -MPC (LGPL-3.0-or-later), LLVM (Apache-2.0), zlib (Zlib), libxml2 (MIT), -zstd (BSD-3-Clause) and symengine (MIT AND BSD-3-Clause). -pip wheels on Windows use MPIR (LGPL-3.0-or-later) instead of GMP above and -pthreads-win32 (LGPL-3.0-or-later) additionally. -NumPy (BSD-3-Clause) and SymPy (BSD-3-Clause) are optional dependencies. -Sources for these binary dependencies can be found on https://github.com/symengine/symengine-wheels/releases +- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). +- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** above and **pthreads-win32** (LGPL-3.0-or-later) additionally. +- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional dependencies. +- Sources for these binary dependencies can be found on [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). From 984cb44b9b85c55b6e375b548b5665fd9183dece Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:30:19 -0600 Subject: [PATCH 08/15] Remove symengine conda channel from isntructions --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index d9141c7c1..6e6e624fc 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,7 @@ pip install symengine --user ### Conda package manager ```bash -conda install python-symengine -c symengine -c conda-forge -``` - -Optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): - -```bash -conda install python-symengine -c symengine/label/dev -c conda-forge +conda install python-symengine -c conda-forge ``` ### Build from source From 63a7a0f6d3bde94b1fb21cd87874935478ee4875 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:35:57 -0600 Subject: [PATCH 09/15] Update README.md --- README.md | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6e6e624fc..2a89249ea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SymEngine Python Wrappers -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), +Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), a fast C++ symbolic manipulation library. [![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) @@ -34,8 +34,9 @@ Cython >= 0.29.24 SymEngine >= 0.7.0 ``` -For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is supported. -The latest git master branch may not work as there may be breaking changes in **SymEngine**. +For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is +supported. The latest git master branch may not work as there may be breaking +changes in **SymEngine**. Python wrappers can be installed by, @@ -55,20 +56,31 @@ python setup.py install build_ext --inplace # Build the extension in source tree ``` -Standard options to `setup.py` like `--user`, `--prefix` can be used to configure install location. -NumPy is used if found by default, if you wish to make your choice of NumPy use explicit: then add e.g. `WITH_NUMPY=False` to `--define`. +Standard options to `setup.py` like `--user`, `--prefix` can be used to +configure install location. NumPy is used if found by default, if you wish +to make your choice of NumPy use explicit: then add +e.g. `WITH_NUMPY=False` to `--define`. ### Notes on Dependencies -If you intend to evaluate floating-point expressions (using **lambdify**), you should consider linking against **LLVM**. Many users might also benefit from linking against **FLINT**, as it is now LGPL-licensed. +If you intend to evaluate floating-point expressions (using **lambdify**), +you should consider linking against **LLVM**. Many users might also benefit +from linking against **FLINT**, as it is now LGPL-licensed. -In general, **sudo** is only required if you are installing to the default prefix (`/usr/local`). We recommend specifying a custom prefix (`--prefix=$HOME/.local`) to avoid requiring administrative privileges, which most users can do without using **sudo**. +In general, **sudo** is only required if you are installing to the default +prefix (`/usr/local`). We recommend specifying a custom prefix +(`--prefix=$HOME/.local`) to avoid requiring administrative privileges, +which most users can do without using **sudo**. -If you're uncomfortable specifying the prefix manually, we suggest using **Conda** or installing the pre-built wheels via **pip** instead of building from source. +If you're uncomfortable specifying the prefix manually, we suggest using +**Conda** or installing the pre-built wheels via **pip** instead of building +from source. ## Verification -You can verify the installation of **SymEngine** by using the provided code snippet in this README. This snippet ensures that the installation works as expected and that basic functionality is available. +You can verify the installation of **SymEngine** by using the provided code +snippet in this README. This snippet ensures that the installation works as +expected and that basic functionality is available. ```python from symengine import var @@ -82,16 +94,26 @@ This will output: x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z ``` -Note: The verification code provided above checks the functionality of SymEngine. For additional verification specific to SymEngine, please refer to the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) for further tests and examples. +Note: The verification code provided above checks the functionality of +SymEngine. For additional verification specific to SymEngine, please refer to +the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) +for further tests and examples. ## License -symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed libraries. +symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed +libraries. Licenses for the dependencies of pip wheels are as follows: -- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). -- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** above and **pthreads-win32** (LGPL-3.0-or-later) additionally. -- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional dependencies. -- Sources for these binary dependencies can be found on [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). +- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), + **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), + **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), + **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). +- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** + above and **pthreads-win32** (LGPL-3.0-or-later) additionally. +- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional + dependencies. +- Sources for these binary dependencies can be found on + [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). From a3a9ce81796a2b4defdc2b7f074d440c58158e39 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:38:47 -0600 Subject: [PATCH 10/15] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2a89249ea..e13eb7272 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # SymEngine Python Wrappers Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), From 7c48a0d75dcdd543486587584ecaa0643fa9d6d4 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 19:56:16 -0600 Subject: [PATCH 11/15] Update version --- CMakeLists.txt | 2 +- symengine_version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 418b6704c..3c83e7cfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH}) include(GNUInstallDirs) -find_package(SymEngine 0.8.1 REQUIRED CONFIG +find_package(SymEngine 0.14.0 REQUIRED CONFIG PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/) message("SymEngine_DIR : " ${SymEngine_DIR}) message("SymEngine Version : " ${SymEngine_VERSION}) diff --git a/symengine_version.txt b/symengine_version.txt index 6345c2168..6718d65f7 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.13.0 +fac9314c78f2809570494017efc6603befeb4eda From 0a3e0af889785cb7ec489da2a96dd98b9a2aa138 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 20:06:48 -0600 Subject: [PATCH 12/15] Use RCPBasicAware{Output,Input}Archive --- symengine/lib/pywrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/symengine/lib/pywrapper.cpp b/symengine/lib/pywrapper.cpp index 4f45a0b7d..5ab5e5866 100644 --- a/symengine/lib/pywrapper.cpp +++ b/symengine/lib/pywrapper.cpp @@ -292,7 +292,7 @@ PyObject* pickle_loads(const std::string &pickle_str) { return obj; } -RCP load_basic(cereal::PortableBinaryInputArchive &ar, RCP &) +RCP load_basic(RCPBasicAwareInputArchive &ar, RCP &) { bool is_pysymbol; bool store_pickle; @@ -324,7 +324,7 @@ std::string pickle_dumps(const PyObject * obj) { return std::string(buffer, size); } -void save_basic(cereal::PortableBinaryOutputArchive &ar, const Symbol &b) +void save_basic(RCPBasicAwareOutputArchive &ar, const Symbol &b) { bool is_pysymbol = is_a_sub(b); ar(is_pysymbol); @@ -344,7 +344,7 @@ std::string wrapper_dumps(const Basic &x) std::ostringstream oss; unsigned short major = SYMENGINE_MAJOR_VERSION; unsigned short minor = SYMENGINE_MINOR_VERSION; - cereal::PortableBinaryOutputArchive{oss}(major, minor, + RCPBasicAwareOutputArchive{oss}(major, minor, x.rcp_from_this()); return oss.str(); } @@ -354,7 +354,7 @@ RCP wrapper_loads(const std::string &serialized) unsigned short major, minor; RCP obj; std::istringstream iss(serialized); - cereal::PortableBinaryInputArchive iarchive{iss}; + RCPBasicAwareInputArchive iarchive{iss}; iarchive(major, minor); if (major != SYMENGINE_MAJOR_VERSION or minor != SYMENGINE_MINOR_VERSION) { throw SerializationError(StreamFmt() From 320c984c1a196c03dd8c9442935db9f610022737 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 20:18:34 -0600 Subject: [PATCH 13/15] update version to 0.14.0 --- setup.py | 2 +- symengine/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f105b328f..035471db0 100644 --- a/setup.py +++ b/setup.py @@ -222,7 +222,7 @@ def finalize_options(self): ''' setup(name="symengine", - version="0.13.0", + version="0.14.0", description="Python library providing wrappers to SymEngine", setup_requires=['cython>=0.29.24'], long_description=long_description, diff --git a/symengine/__init__.py b/symengine/__init__.py index 97e9afd0f..4ca4dd7cb 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -63,7 +63,7 @@ def __getattr__(name): raise AttributeError(f"module 'symengine' has no attribute '{name}'") -__version__ = "0.13.0" +__version__ = "0.14.0" # To not expose internals From 248e6dc1747c8e69633fde3072527a61abe9049d Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 17 Feb 2025 08:04:59 -0600 Subject: [PATCH 14/15] update symengine c++ to 0.14.0 --- symengine_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine_version.txt b/symengine_version.txt index 6718d65f7..4a29f93bb 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -fac9314c78f2809570494017efc6603befeb4eda +v0.14.0 From df4081db4a0167862e959cf3190e4dd54a269165 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 17 Feb 2025 12:15:17 -0600 Subject: [PATCH 15/15] Add Aaron and Firat to README. Welcome to SymEngine!! --- .mailmap | 1 + AUTHORS | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.mailmap b/.mailmap index 71840613b..5a35cee3f 100644 --- a/.mailmap +++ b/.mailmap @@ -21,3 +21,4 @@ Abhinav Agarwal Nilay Pochhi Björn Dahlgren Richard Otis richardotis +Firat Bezir diff --git a/AUTHORS b/AUTHORS index 427f83ad9..19d0bd089 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,3 +36,5 @@ Pieter Eendebak Ayush Kumar Christian Clauss Moraxyc +Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> +Firat Bezir