Repository: pytries/marisa-trie (language: python)

Issue:
Seems like python 3.12 is not supported
Hello. Recently I tried to bump python to 3.12 in my project, but got following poetry errors during dependencies installation. I am using arm64, if it's important.

So, is the python 3.12 supported?

```sh
  • Installing marisa-trie (0.7.8): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke build_wheel
  
  running bdist_wheel
  running build
  running build_clib
  building 'libmarisa-trie' library
  creating build
  creating build/temp.macosx-14-arm64-cpython-312
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/trie
  creating build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/vector
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/agent.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/agent.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/io/mapper.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/mapper.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/io/reader.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/reader.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/io/writer.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/writer.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/trie/louds-trie.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/trie/louds-trie.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/trie/tail.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/trie/tail.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/grimoire/vector/bit-vector.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/vector/bit-vector.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/keyset.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/keyset.o
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/trie.cc -o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/trie.o
  /usr/bin/xcrun ar rcs build/temp.macosx-14-arm64-cpython-312/liblibmarisa-trie.a build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/agent.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/mapper.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/reader.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/io/writer.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/trie/louds-trie.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/trie/tail.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/grimoire/vector/bit-vector.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/keyset.o build/temp.macosx-14-arm64-cpython-312/marisa-trie/lib/marisa/trie.o
  ranlib build/temp.macosx-14-arm64-cpython-312/liblibmarisa-trie.a
  running build_ext
  building 'marisa_trie' extension
  creating build/temp.macosx-14-arm64-cpython-312/src
  clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Imarisa-trie/include -I/private/var/folders/82/shvhkdb51rb7_s34yld2pst00000gn/T/tmpeetivgwk/.venv/include -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/agent.cpp -o build/temp.macosx-14-arm64-cpython-312/src/agent.o
  src/agent.cpp:1582:27: warning: 'ma_version_tag' is deprecated [-Wdeprecated-declarations]
      return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
                            ^
  src/agent.cpp:1046:65: note: expanded from macro '__PYX_GET_DICT_VERSION'
  #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
                                                                  ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: 'ma_version_tag' has been explicitly marked deprecated here
      Py_DEPRECATED(3.12) uint64_t ma_version_tag;
      ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  src/agent.cpp:1594:36: warning: 'ma_version_tag' is deprecated [-Wdeprecated-declarations]
      return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
                                     ^
  src/agent.cpp:1046:65: note: expanded from macro '__PYX_GET_DICT_VERSION'
  #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
                                                                  ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: 'ma_version_tag' has been explicitly marked deprecated here
      Py_DEPRECATED(3.12) uint64_t ma_version_tag;
      ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  src/agent.cpp:1598:56: warning: 'ma_version_tag' is deprecated [-Wdeprecated-declarations]
      if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
                                                         ^
  src/agent.cpp:1046:65: note: expanded from macro '__PYX_GET_DICT_VERSION'
  #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
                                                                  ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: 'ma_version_tag' has been explicitly marked deprecated here
      Py_DEPRECATED(3.12) uint64_t ma_version_tag;
      ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  src/agent.cpp:1657:9: warning: 'ma_version_tag' is deprecated [-Wdeprecated-declarations]
          __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
          ^
  src/agent.cpp:1053:16: note: expanded from macro '__PYX_PY_DICT_LOOKUP_IF_MODIFIED'
      if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
                 ^
  src/agent.cpp:1046:65: note: expanded from macro '__PYX_GET_DICT_VERSION'
  #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
                                                                  ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: 'ma_version_tag' has been explicitly marked deprecated here
      Py_DEPRECATED(3.12) uint64_t ma_version_tag;
      ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  src/agent.cpp:1657:9: warning: 'ma_version_tag' is deprecated [-Wdeprecated-declarations]
          __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
          ^
  src/agent.cpp:1057:30: note: expanded from macro '__PYX_PY_DICT_LOOKUP_IF_MODIFIED'
          __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
                               ^
  src/agent.cpp:1046:65: note: expanded from macro '__PYX_GET_DICT_VERSION'
  #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
                                                                  ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: 'ma_version_tag' has been explicitly marked deprecated here
      Py_DEPRECATED(3.12) uint64_t ma_version_tag;
      ^
  /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  src/agent.cpp:1958:55: error: no member named 'ob_digit' in '_longobject'
              const digit* digits = ((PyLongObject*)x)->ob_digit;
                                    ~~~~~~~~~~~~~~~~~~  ^
  src/agent.cpp:2013:55: error: no member named 'ob_digit' in '_longobject'
              const digit* digits = ((PyLongObject*)x)->ob_digit;
                                    ~~~~~~~~~~~~~~~~~~  ^
  src/agent.cpp:2154:55: error: no member named 'ob_digit' in '_longobject'
              const digit* digits = ((PyLongObject*)x)->ob_digit;
                                    ~~~~~~~~~~~~~~~~~~  ^
  src/agent.cpp:2209:55: error: no member named 'ob_digit' in '_longobject'
              const digit* digits = ((PyLongObject*)x)->ob_digit;
                                    ~~~~~~~~~~~~~~~~~~  ^
  src/agent.cpp:2660:47: error: no member named 'ob_digit' in '_longobject'
      const digit* digits = ((PyLongObject*)b)->ob_digit;
                            ~~~~~~~~~~~~~~~~~~  ^
  5 warnings and 5 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  

  at ~/Library/Application Support/pypoetry/venv/lib/python3.12/site-packages/poetry/installation/chef.py:147 in _prepare
      143│ 
      144│                 error = ChefBuildError("\n\n".join(message_parts))
      145│ 
      146│             if error is not None:
    → 147│                 raise error from None
      148│ 
      149│             return path
      150│ 
      151│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with marisa-trie (0.7.8) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "marisa-trie (==0.7.8)"'.
```


Discussion / hints:
Python 3.12 is not yet supported. I'll have a look ASAP, or if you want to step in, go ahead too :)

Fix patch:
diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml
index 7b1dced..ba92591 100644
--- a/.github/workflows/build-and-publish.yml
+++ b/.github/workflows/build-and-publish.yml
@@ -29,13 +29,13 @@ jobs:
       - name: Install Python
         uses: actions/setup-python@v4
         with:
-          python-version: "3.11"
+          python-version: "3.x"
       - name: Install build dependencies
         run: python -m pip install --upgrade cibuildwheel
       - name: Build wheels
         run: python -m cibuildwheel
         env:
-          CIBW_SKIP: "cp36-* cp312*" # skip 3.6 and 3.12 wheels
+          CIBW_SKIP: "cp36-*" # skip 3.6
           CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
       - uses: actions/upload-artifact@v3
         with:
@@ -54,7 +54,7 @@ jobs:
       - name: Install Python
         uses: actions/setup-python@v4
         with:
-          python-version: "3.11"
+          python-version: "3.x"
       - name: Build source distribution
         run: python setup.py sdist
       - name: Store the source distribution
diff --git a/CHANGES.rst b/CHANGES.rst
index ea95ec5..fcc7c49 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -2,6 +2,11 @@
 CHANGES
 =======
 
+1.1.0 (2023-10-06)
+------------------
+
+* Added Python 3.12 support.
+
 1.0.0 (2023-09-03)
 ------------------
 
diff --git a/docs/conf.py b/docs/conf.py
index b7733e7..2320faa 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -59,7 +59,7 @@
 # built documents.
 #
 # The short X.Y version.
-version = "1.0.0"
+version = "1.1.0"
 # The full version, including alpha/beta/rc tags.
 release = version
 
diff --git a/setup.py b/setup.py
index bd77b87..dcb9204 100755
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,7 @@
     "Programming Language :: Python :: 3.9",
     "Programming Language :: Python :: 3.10",
     "Programming Language :: Python :: 3.11",
+    "Programming Language :: Python :: 3.12",
     "Programming Language :: Python :: Implementation :: CPython",
     "Topic :: Software Development :: Libraries :: Python Modules",
     "Topic :: Scientific/Engineering :: Information Analysis",
@@ -60,7 +61,7 @@
 
 setup(
     name="marisa-trie",
-    version="1.0.0",
+    version="1.1.0",
     description=DESCRIPTION,
     long_description=LONG_DESCRIPTION,
     long_description_content_type="text/x-rst",


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index f84d834..1457a72 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -11,7 +11,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest, windows-latest, macos-latest]
-        python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
+        python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
     steps:
       - name: Checkout
         uses: actions/checkout@v4