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

Support python 3.12 on sagemath-standard #36407

Merged
merged 14 commits into from
Oct 21, 2023
Merged

Commits on Oct 9, 2023

  1. py312: changes in PyLong internals

    The layout for python integers changed in python 3.12.
    We add a module `sage.cpython.pycore_long` which copies the new
    (internal) api of PyLong from python 3.12. We also implement fallback
    version of these functions suitable for python pre-3.12.
    
    Note the files implementing the `pycore_long` module (`pycore_long.pxd`
    and `pycore_long.h`) are shared with fpylll and cypari2.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    dc71bd0 View commit details
    Browse the repository at this point in the history
  2. py312: atexit_callback change

    In python 3.12, the `struct atexit_callback` was renamed to
    `struct atexit_py_callback`. The easiest workaround is to add
    `#define atexit_callback atexit_py_callback` in the right place when
    building using python 3.12 or newer.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    4d35af2 View commit details
    Browse the repository at this point in the history
  3. py312: disable cython profile=true in one file

    Tracing has changed in python 3.12 in such a way that cython doesn't
    support it properly anymore. This one file sets `profile=true` for
    cython which won't work anymore (and it fails to build, at least with
    cython 0.29). We just disable that line.
    
    See also: cython/cython#5450
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    2f31aa8 View commit details
    Browse the repository at this point in the history
  4. py312: fix issue when including internal python header

    To use some (internal) declarations related to dict type, we have to
    include `<internal/pycore_dict.h>` which needs `#define Py_BUILD_CORE`
    to be loaded. This causes trouble when `Python.h` was included before
    defining `Py_BUILD_CORE`, due to a macro `_PyGC_FINALIZED`. We fix it
    by undefining said macro.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    c9c5026 View commit details
    Browse the repository at this point in the history
  5. py312: use new api for ast

    Some changes in ast, the old `node.n` and `node.s` are deprecated in
    favour of a common `node.value`. Making this change seems better than
    just ignoring the deprecation warning.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    ca63dcf View commit details
    Browse the repository at this point in the history
  6. py312: filter deprecation warnings

    This adds some filterwarnings that trigger with python 3.12.
    
     - deprecation of `datetime.datetime.utcfromtimestamp()` this is
       triggered by python modules `dateutil` and `sphinx`.
     - `os.fork()` and `os.ptyfork()` are deprecated when running
       multi-threaded; I don't see an easy way out of this, so ignore it.
     - itertools won't support pickling in python 3.14; let's ignore this
       for now with the hope there's an alternative before 3.14.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    7710fc0 View commit details
    Browse the repository at this point in the history
  7. py312: don't use pkgutil.find_loader()

    Is deprecated, and it can be replaced just fine with
    `importlib.util.find_spec()`.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    57a5468 View commit details
    Browse the repository at this point in the history
  8. py312: fix sage.misc.dev_tools.load_submodules()

    Since `importer.find_module(...)` was removed in 3.12.
    
    We just follow the suggestion from
    
    https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
    
    Note that the last three added lines here could be replaced instead by
    
        spec.loader.load_module(module_name)
    
    which works; however this is deprecated so it's better to use the
    recommended way using `importlib.util.module_from_spec(...)` and
    `spec.loader.execute_module(...)`.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    29e4ebd View commit details
    Browse the repository at this point in the history
  9. py312: sum changed in python 3.12, fix doctest

    In python < 3.12 we have
    
        sage: a = delta_qexp(1000)
        sage: sum(a[n]/float(n)^14 for n in range(1,1000))
        0.9985830631627459
    
    This changed in python 3.12 to
    
        sage: sum(a[n]/float(n)^14 for n in range(1,1000))
        0.9985830631627461
    
    The latter is the correct one as can be seen using rationals:
    
        sage: float(sum(a[n]/n^14 for n in range(1,1000)))
        0.9985830631627461
    
    As a workaround, we do the sum in reverse (from small to large terms),
    which gives the correct result in any case:
    
        sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
        0.9985830631627461
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    07ee873 View commit details
    Browse the repository at this point in the history
  10. py312: use dict instead of OrderedDict for consistent printing

    In python 3.12 the printing of OrderedDict has been changed.
    
    As of Python 3.7, regular dicts are guaranteed to be ordered, so it's
    safe to replace OrderedDict by dict.
    
    Maybe convenient to replace other uses of OrderedDict, although this is
    out of scope of python 3.12 support.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    3600123 View commit details
    Browse the repository at this point in the history
  11. py312: fix crash in polyhedron face iterator

    Running
    
        sage: g = Polyhedron().face_generator()
        sage: g.__next__()
        A -1-dimensional face of a Polyhedron in ZZ^0
        sage: g.__next__()
    
    is supposed to raise `StopIteration`. However in python 3.12 the second
    call to `__next__()` leads to a crash.
    
    This is caused by a `return -1` in `next_face_loop()` which is supposed
    to mean `raise StopIteration`. Using raise explicitly fixes the crash.
    tornaria committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    168063c View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    0a1dd38 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    3a7cd3f View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2023

  1. Configuration menu
    Copy the full SHA
    1cf3634 View commit details
    Browse the repository at this point in the history