From 310fde805d574f7758113bf6b0ce67ad83d7b2ce Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 15 Sep 2023 13:29:14 +0200 Subject: [PATCH 1/4] Update installation command in quickstart --- docs/quickstart.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index b526552e7..f57063cfa 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -4,14 +4,17 @@ HPy Quickstart This section shows how to quickly get started with HPy by creating a simple HPy extension from scratch. -Install HPy: +Install latest HPy release: -.. - This should be updated to pip install hpy once this version is released +.. code-block:: console + + python3 -m pip install hpy + +Alternatively, you can also install HPy from the development repository: .. code-block:: console - python3 -m pip install git+https://github.com/hpyproject/hpy.git#egg=hpy.universal + python3 -m pip install git+https://github.com/hpyproject/hpy.git#egg=hpy Create a new directory for the new HPy extension. Location and name of the directory do not matter. Add the following two files: From 517557d5da8b983a730253546b2f7457899e7a13 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 15 Sep 2023 14:00:39 +0200 Subject: [PATCH 2/4] Fix #448; account for zero terminator in type name --- hpy/debug/src/debug_ctx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hpy/debug/src/debug_ctx.c b/hpy/debug/src/debug_ctx.c index fbcb0b21e..1f021daa5 100644 --- a/hpy/debug/src/debug_ctx.c +++ b/hpy/debug/src/debug_ctx.c @@ -559,7 +559,7 @@ const char *debug_ctx_Type_GetName(HPyContext *dctx, DHPy type) ctx_info->is_valid = false; const char *name = HPyType_GetName(uctx, uh_type); ctx_info->is_valid = true; - n_name = strlen(name); + n_name = strlen(name) + 1; return (const char *)protect_and_associate_data_ptr(type, (void *)name, n_name); } From 9baeccff31662aedf17ef426fc387b702b7f47e7 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 15 Sep 2023 14:32:26 +0200 Subject: [PATCH 3/4] Fix: Use PyType_GetDict for structseq type for >=3.12 --- hpy/devel/src/runtime/structseq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hpy/devel/src/runtime/structseq.c b/hpy/devel/src/runtime/structseq.c index 8feb27d6f..9acd23775 100644 --- a/hpy/devel/src/runtime/structseq.c +++ b/hpy/devel/src/runtime/structseq.c @@ -224,7 +224,15 @@ HPyStructSequence_New(HPyContext *ctx, HPy type, HPy_ssize_t nargs, HPy *args) tp = (PyTypeObject *)_h2py(type); name = PyUnicode_FromStringAndSize(s_n_fields, sizeof(s_n_fields)); // CPython also accesses the dict directly - v = PyDict_GetItemWithError(tp->tp_dict, name); +#if PY_VERSION_HEX >= 0x030C0000 + PyObject *dict = PyType_GetDict(tp); +#else + PyObject *dict = tp->tp_dict; +#endif + v = PyDict_GetItemWithError(dict, name); +#if PY_VERSION_HEX >= 0x030C0000 + Py_DECREF(dict); +#endif Py_DECREF(name); if (v == NULL && !PyErr_Occurred()) { goto type_error; From f4a57b733b5114597a984f52130e8eaa9ade0a04 Mon Sep 17 00:00:00 2001 From: Florian Angerer Date: Fri, 15 Sep 2023 14:37:20 +0200 Subject: [PATCH 4/4] Add Python 3.12 to gate --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1da03c460..81094ecb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,8 @@ jobs: compiler: 'g++' - os: ubuntu-latest python-version: '3.11' + - os: ubuntu-latest + python-version: '3.12' steps: - uses: actions/checkout@v3 @@ -37,6 +39,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install/Upgrade Python dependencies run: python -m pip install --upgrade pip wheel 'setuptools>=60.2' @@ -61,7 +64,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ['3.11', '3.10', '3.9', '3.8'] + python-version: ['3.12', '3.11', '3.10', '3.9', '3.8'] steps: - uses: actions/checkout@v3 @@ -102,6 +105,8 @@ jobs: python-version: '3.9' - os: ubuntu-latest python-version: '3.11' + - os: ubuntu-latest + python-version: '3.12' steps: - uses: actions/checkout@v3 @@ -117,6 +122,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install/Upgrade Python dependencies run: python -m pip install --upgrade pip wheel