aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
516 stars 87 forks source link

gmpy-2.1.5 fails to compile with python-3.12 #446

Closed andreygrozin closed 2 months ago

andreygrozin commented 11 months ago
In file included from src/gmpy2.c:605:
src/gmpy2_convert_gmp.c: In function ‘GMPy_MPZ_From_PyIntOrLong’:
src/gmpy2_convert_gmp.c:64:48: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
   64 |         mpz_set_si(result->z, -(sdigit)templong->ob_digit[0]);
      |                                                ^~
src/gmpy2_convert_gmp.c:70:39: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
   70 |         mpz_set_si(result->z, templong->ob_digit[0]);
      |                                       ^~
src/gmpy2_convert_gmp.c:83:55: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
   83 |         mpz_import(result->z, len, -1, sizeof(templong->ob_digit[0]), 0,
      |                                                       ^~
src/gmpy2_convert_gmp.c:84:35: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
   84 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                   ^~
src/gmpy2_convert_gmp.c:84:76: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
   84 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                                                            ^~
src/gmpy2_convert_gmp.c: In function ‘mpz_set_PyIntOrLong’:
src/gmpy2_convert_gmp.c:110:40: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  110 |         mpz_set_si(z, -(sdigit)templong->ob_digit[0]);
      |                                        ^~
src/gmpy2_convert_gmp.c:116:31: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  116 |         mpz_set_si(z, templong->ob_digit[0]);
      |                               ^~
src/gmpy2_convert_gmp.c:129:47: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  129 |         mpz_import(z, len, -1, sizeof(templong->ob_digit[0]), 0,
      |                                               ^~
src/gmpy2_convert_gmp.c:130:35: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  130 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                   ^~
src/gmpy2_convert_gmp.c:130:76: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  130 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                                                            ^~
src/gmpy2_convert_gmp.c: In function ‘GMPy_PyLong_From_MPZ’:
src/gmpy2_convert_gmp.c:203:22: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  203 |     mpz_export(result->ob_digit, &count, -1, sizeof(result->ob_digit[0]), 0,
      |                      ^~
src/gmpy2_convert_gmp.c:203:59: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  203 |     mpz_export(result->ob_digit, &count, -1, sizeof(result->ob_digit[0]), 0,
      |                                                           ^~
src/gmpy2_convert_gmp.c:204:29: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  204 |                sizeof(result->ob_digit[0])*8 - PyLong_SHIFT, obj->z);
      |                             ^~
src/gmpy2_convert_gmp.c:207:15: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  207 |         result->ob_digit[0] = 0;
      |               ^~
src/gmpy2_convert_gmp.c:212:31: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  212 |     while ((size>0) && (result->ob_digit[size-1] == 0)) {
      |                               ^~
src/gmpy2_convert_gmp.c: In function ‘GMPy_XMPZ_From_PyIntOrLong’:
src/gmpy2_convert_gmp.c:481:48: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  481 |         mpz_set_si(result->z, -(sdigit)templong->ob_digit[0]);
      |                                                ^~
src/gmpy2_convert_gmp.c:487:39: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  487 |         mpz_set_si(result->z, templong->ob_digit[0]);
      |                                       ^~
src/gmpy2_convert_gmp.c:500:55: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  500 |         mpz_import(result->z, len, -1, sizeof(templong->ob_digit[0]), 0,
      |                                                       ^~
src/gmpy2_convert_gmp.c:501:35: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  501 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                   ^~
src/gmpy2_convert_gmp.c:501:76: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  501 |                    sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, templong->ob_digit);
      |                                                                            ^~
error: command '/usr/bin/x86_64-pc-linux-gnu-gcc' failed with exit code 1
skirpichev commented 11 months ago

@andreygrozin, this is fixed in the current development version and in the published on the PyPI alpha: 2.2.0a1. See #375 and #410. Edit: but beware #438 - published wheels aren't working on some systems.

In principle, the fix could be ported to 2.1.x. On another hand, README says: "Release 2.1.5 is the last planned release of the 2.1 series." @casevh should we release a new 2.1.6 version or this issue can be closed?

casevh commented 11 months ago

If it were possible to make a source only release....

I would prefer to release 2.2.0 as soon as practical. And then plan to make a 2.3.0 release when Python 3.13 is available.

skirpichev commented 11 months ago

Ok, I will provide a patch today or tomorrow. Unfortunately, there is no branches for old stable releases to make pr against (c.f. cpython repo).

I would prefer to release 2.2.0 as soon as practical.

I think it will be great, if we could solve #377 and document how to test installed package.

skirpichev commented 11 months ago

Attached patch should fix this issue: gmpy2-2.1.5-py3.12.diff.txt

This is against tag gmpy2-2.1.5.

andreygrozin commented 11 months ago

Attached patch should fix this issue: gmpy2-2.1.5-py3.12.diff.txt

This is against tag gmpy2-2.1.5.

Thanks, I'll commit gmpy-2.1.5_p1 to Gentoo today

skirpichev commented 8 months ago

@casevh, do you have plans for a minor release? If not, probably this could be closed.

paddyroddy commented 5 months ago

Any plans to support python 3.12?

skirpichev commented 5 months ago

@casevh, see above patch. BTW, 3.13b1 release is close: it's not so hard to backport 3.13 fixes for 2.1.x. Let me know if this does make sense for you.

chenrui333 commented 5 months ago

Attached patch should fix this issue: gmpy2-2.1.5-py3.12.diff.txt

This is against tag gmpy2-2.1.5.

patch works for me on the homebrew side as well, thanks!

chenrui333 commented 4 months ago

Any change of cutting a new release for the patch?? Thanks!

relates to https://github.com/Homebrew/homebrew-core/pull/171463

skirpichev commented 3 months ago

@casevh, with v2.2 release, probably this can be closed?