Skip to content

Commit

Permalink
Add support for Free Threading
Browse files Browse the repository at this point in the history
  • Loading branch information
hattya committed Oct 21, 2024
1 parent 41cd2b6 commit f6222d5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: pypa/cibuildwheel@v2.21
env:
CIBW_SKIP: pp* *musllinux*
CIBW_FREE_THREADED_SUPPORT: true
CIBW_ARCHS_MACOS: universal2
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ZopfliPy Changelog
==================

Version 1.12
------------

* Add support for Free Threading.


Version 1.11
------------

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#

import os
import sysconfig

from setuptools import setup, Extension

Expand All @@ -21,5 +22,6 @@ def sources(path, exts):
setup(
ext_modules=[Extension('zopfli._zopfli',
sources=list(sources('zopfli', ['.c', '.cc', '.cpp'])),
include_dirs=[os.path.join('zopfli', '_zopfli', 'zopfli', 'src')])],
include_dirs=[os.path.join('zopfli', '_zopfli', 'zopfli', 'src')],
define_macros=[('Py_GIL_DISABLED', 1)] if sysconfig.get_config_var('Py_GIL_DISABLED') else [])]
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps =
ruff
mypy
scmver[toml] >= 1.7
passenv = *FLAGS, INCLUDE, LC_*, LIB, MSSdk, Program*
passenv = *FLAGS, INCLUDE, LC_*, LIB, MSSdk, Program*, PYTHON*
commands =
python setup.py build_ext --inplace
# test
Expand Down
5 changes: 4 additions & 1 deletion zopfli/_zopfli/_zopflimodule.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* zopfli._zopfli :: _zopflimodule.c
*
* Copyright (c) 2015-2021 Akinori Hattori <hattya@gmail.com>
* Copyright (c) 2015-2024 Akinori Hattori <hattya@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -387,6 +387,9 @@ PyInit__zopfli(void) {
if (m == NULL) {
goto err;
}
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
if (PyModule_AddIntMacro(m, ZOPFLI_FORMAT_GZIP) < 0
|| PyModule_AddIntMacro(m, ZOPFLI_FORMAT_ZLIB) < 0
|| PyModule_AddIntMacro(m, ZOPFLI_FORMAT_DEFLATE) < 0) {
Expand Down

0 comments on commit f6222d5

Please sign in to comment.