MagicStack / immutables

A high-performance immutable mapping type for Python.
Other
1.14k stars 57 forks source link

Replace `_PyLong_Format` with `PyNumber_ToBase` #118

Closed musicinmybrain closed 1 month ago

musicinmybrain commented 5 months ago

_PyLong_Format is in Python’s internal, private API; PyNumber_ToBase belongs to the Stable API, and is a fairly thin wrapper around _PyLong_Format with a bit of extra error checking.

Fixes #116.

inducer commented 1 month ago

Python 3.13 is out, and immutables won't build on it without this:

Collecting immutables
  Using cached immutables-0.20.tar.gz (88 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: immutables
  Building wheel for immutables (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for immutables (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      /tmp/pip-build-env-5kwi0m9m/overlay/lib/python3.13/site-packages/setuptools/command/easy_install.py:41: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
        import pkg_resources
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/__init__.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_protocols.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_testutils.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/_version.py -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/map.py -> build/lib.linux-x86_64-cpython-313/immutables
      running egg_info
      writing immutables.egg-info/PKG-INFO
      writing dependency_links to immutables.egg-info/dependency_links.txt
      writing requirements to immutables.egg-info/requires.txt
      writing top-level names to immutables.egg-info/top_level.txt
      reading manifest file 'immutables.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      adding license file 'LICENSE-APACHE'
      adding license file 'NOTICE'
      writing manifest file 'immutables.egg-info/SOURCES.txt'
      copying immutables/_map.pyi -> build/lib.linux-x86_64-cpython-313/immutables
      copying immutables/py.typed -> build/lib.linux-x86_64-cpython-313/immutables
      running build_ext
      building 'immutables._map' extension
      creating build/temp.linux-x86_64-cpython-313/immutables
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DNDEBUG=1 -I/home/andreas/src/env-3.13/include -I/usr/include/python3.13 -c immutables/_map.c -o build/temp.linux-x86_64-cpython-313/immutables/_map.o -O2 -std=c99 -fsigned-char -Wall -Wsign-compare -Wconversion
      immutables/_map.c: In function ‘map_node_bitmap_dump’:
      immutables/_map.c:1287:12: error: implicit declaration of function ‘_PyLong_Format’; did you mean ‘_PyLong_Copy’? [-Wimplicit-function-declaration]
       1287 |     tmp2 = _PyLong_Format(tmp1, 2);
            |            ^~~~~~~~~~~~~~
            |            _PyLong_Copy
      immutables/_map.c:1287:10: error: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
       1287 |     tmp2 = _PyLong_Format(tmp1, 2);
            |          ^
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for immutables
Failed to build immutables
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (immutables)

I maintain a package that relies on immutables, and this is keeping my package from working with Py3.13.

inducer commented 1 month ago

For the benefit of anyone else seeing this, this command will get a working immutables in place on 3.13 as a stopgap:

pip install "git+https://github.com/musicinmybrain/immutables.git@python3.13#egg=immutables"
1st1 commented 1 month ago

cc @fantix

inducer commented 1 month ago

Thank you very much, also for rolling a new release!