Skip to content

Commit 7f2d282

Browse files
authored
Merge pull request #59 from jonathanhogg/build_python3.13
Python 3.13 support
2 parents 9ee409e + f2a8441 commit 7f2d282

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

.github/workflows/ci-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: ["3.10", "3.11", "3.12"]
23+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2424
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
2525
include:
2626
- os: macos-13

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.10",
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
2627
"Environment :: Console",
2728
"Environment :: GPU",
2829
"Environment :: MacOS X",

src/flitter/language/vm.pyx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from .. import name_patch
1010
from ..cache import SharedCache
1111
from .functions import STATIC_FUNCTIONS, DYNAMIC_FUNCTIONS
1212
from ..model cimport StateDict, null_, true_, false_, inf_, nan_
13+
from ..timer cimport perf_counter
1314
from .noise import NOISE_FUNCTIONS
1415

1516
from libc.math cimport floor as c_floor
@@ -25,16 +26,9 @@ from cpython.tuple cimport PyTuple_New, PyTuple_GET_ITEM, PyTuple_SET_ITEM, PyTu
2526

2627

2728
cdef extern from "Python.h":
28-
ctypedef int64_t _PyTime_t
29-
_PyTime_t _PyTime_GetPerfCounter() noexcept nogil
30-
double _PyTime_AsSecondsDouble(_PyTime_t t) noexcept nogil
3129
object PyObject_CallOneArg(object callable_object, object arg)
3230

3331

34-
cdef inline double perf_counter() noexcept nogil:
35-
return _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter())
36-
37-
3832
logger = name_patch(logger, __name__)
3933

4034
cdef const char* ContextFunc = "context_func\0"

src/flitter/render/window/canvas.pyx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,18 @@ import cython
1010
from cpython cimport array, PyObject
1111
from cpython.dict cimport PyDict_GetItem, PyDict_SetItem
1212
from libc.math cimport acos, sqrt
13-
from libc.stdint cimport int64_t, uint32_t
13+
from libc.stdint cimport uint32_t
1414
from loguru import logger
1515
import skia
1616

1717
from . import WindowNode
1818
from flitter import name_patch
1919
from ...cache import SharedCache
2020
from ...model cimport Vector, Node
21+
from ...timer cimport perf_counter
2122
from .glconstants import GL_TEXTURE_2D, GL_RGBA8, GL_RGBA16F, GL_RGBA32F
2223
from .target import RenderTarget, COLOR_FORMATS
2324

24-
cdef extern from "Python.h":
25-
ctypedef int64_t _PyTime_t
26-
_PyTime_t _PyTime_GetPerfCounter() noexcept nogil
27-
double _PyTime_AsSecondsDouble(_PyTime_t t) noexcept nogil
28-
29-
30-
cdef inline double perf_counter() noexcept nogil:
31-
return _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter())
32-
3325

3426
logger = name_patch(logger, __name__)
3527

src/flitter/timer.pxd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
cdef extern from *:
3+
"""
4+
#include "Python.h"
5+
6+
#if PY_MINOR_VERSION >= 13
7+
static inline double perf_counter() {
8+
PyTime_t result;
9+
PyTime_PerfCounter(&result);
10+
return PyTime_AsSecondsDouble(result);
11+
}
12+
#else
13+
static inline double perf_counter() {
14+
return _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter());
15+
}
16+
#endif
17+
"""
18+
19+
cdef double perf_counter() noexcept nogil

0 commit comments

Comments
 (0)