Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please release a new version (and put it on PyPi) #79

Closed
HJarausch opened this issue Oct 23, 2018 · 4 comments
Closed

Please release a new version (and put it on PyPi) #79

HJarausch opened this issue Oct 23, 2018 · 4 comments

Comments

@HJarausch
Copy link

The current version 0.3.0 does NOT build with Python3.7 and some distributions have switched to this recent Python version.

@MNRK01
Copy link

MNRK01 commented Nov 22, 2018

The following patch for the file "mpfr.c" in the bigfloat code allows me to build 64-bit bigfloat on Windows 10 with Python 3.7.1 (Anaconda 5.3.0 edition) using msys2 and mingw-w64 gcc 8.1.0 without any issues.

--- mpfr.c.orig	2014-07-06 10:58:27.000000000 -0500
+++ mpfr.c	2018-10-30 22:34:44.194885900 -0500
@@ -7654,7 +7654,7 @@
  * def mpfr_pow(Mpfr_t rop not None, Mpfr_t op1 not None, Mpfr_t op2 not None,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_From_int(mpfr_root((&__pyx_v_rop->_value), (&__pyx_v_op->_value), __pyx_v_k, __pyx_v_rnd)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_From_int(mpfr_rootn_ui((&__pyx_v_rop->_value), (&__pyx_v_op->_value), __pyx_v_k, __pyx_v_rnd)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -31259,12 +31259,12 @@
     *value = local_value;
     *tb = local_tb;
 #if CYTHON_COMPILING_IN_CPYTHON
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = local_type;
-    tstate->exc_value = local_value;
-    tstate->exc_traceback = local_tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = local_type;
+    tstate->curexc_value = local_value;
+    tstate->curexc_traceback = local_tb;
     Py_XDECREF(tmp_type);
     Py_XDECREF(tmp_value);
     Py_XDECREF(tmp_tb);
@@ -31286,12 +31286,12 @@
     PyObject *tmp_type, *tmp_value, *tmp_tb;
 #if CYTHON_COMPILING_IN_CPYTHON
     PyThreadState *tstate = PyThreadState_GET();
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = *type;
-    tstate->exc_value = *value;
-    tstate->exc_traceback = *tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = *type;
+    tstate->curexc_value = *value;
+    tstate->curexc_traceback = *tb;
 #else
     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
     PyErr_SetExcInfo(*type, *value, *tb);
@@ -31304,9 +31304,9 @@
 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
 #if CYTHON_COMPILING_IN_CPYTHON
     PyThreadState *tstate = PyThreadState_GET();
-    *type = tstate->exc_type;
-    *value = tstate->exc_value;
-    *tb = tstate->exc_traceback;
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
     Py_XINCREF(*type);
     Py_XINCREF(*value);
     Py_XINCREF(*tb);
@@ -31318,12 +31318,12 @@
 #if CYTHON_COMPILING_IN_CPYTHON
     PyObject *tmp_type, *tmp_value, *tmp_tb;
     PyThreadState *tstate = PyThreadState_GET();
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = type;
-    tstate->exc_value = value;
-    tstate->exc_traceback = tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
     Py_XDECREF(tmp_type);
     Py_XDECREF(tmp_value);
     Py_XDECREF(tmp_tb);

You will still need to compile gmp (6.1.2 for me) and mpfr (4.0.1 for me) prior to compiling bigfloat using the same version of gcc as above.

I briefly testing the bigfloat 0.3.0 wheel and it gives the right results based on the bigfloat documentation:

In [2]: from bigfloat import *
   ...: print(sqrt(2, precision(100)))  # compute sqrt(2) with 100 bits of precision
   ...: with precision(100):     # another way to get the same result
   ...:     print(sqrt(2))
   ...: my_context = precision(100) + RoundTowardPositive
   ...: print(my_context)
   ...: print(sqrt(2, my_context))      # and another, this time rounding up
   ...: with RoundTowardNegative: # a lower bound for zeta(2)
   ...:     print(sum(1/sqr(n) for n in range(1, 10000)))
   ...: print(zeta(2)) # actual value, for comparison
   ...: print(const_pi()**2/6.0)  # double check value
   ...: quadruple_precision  # context implementing IEEE 754 binary128 format
   ...: print(next_up(0, quadruple_precision))  # smallest subnormal for binary128
   ...: print(log2(next_up(0, quadruple_precision)))
1.4142135623730950488016887242092
1.4142135623730950488016887242092
Context(precision=100, rounding=ROUND_TOWARD_POSITIVE)
1.4142135623730950488016887242108
1.6448340618469506
1.6449340668482264
1.6449340668482264
6.47517511943802511092443895822764655e-4966
-16494.000000000000

In [3]: 

Good luck.

@brlauuu
Copy link

brlauuu commented Oct 29, 2019

Is there an update on this issue? Pip installation of bigfloat on Mac is still not working with Python3.7.

@DNS
Copy link

DNS commented Dec 26, 2019

Can't install using pip on Python 3.8, Win10

@mdickinson
Copy link
Owner

There's now a new release on PyPI: https://pypi.org/project/bigfloat/0.4.0/. I'm able to install from PyPI on Python 2.7 and Python 3.5 through Python 3.8 on macOS. Please let me know of any issues you encounter.

To avoid future issues like this, it may make sense to perform the Cythonization at install time rather than at sdist creation time. I'll open a separate issue for that.

Apologies for taking so long to get to this; my free time is in short supply. If anyone is interested in co-maintaining (or even taking over maintainership) for this package, please let me know - I'd be happy to discuss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants