-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use custom extension types in C extensions for free-threading python #126267
Comments
Would you mind to build the CPython with --pydebug flag and run the code and post the result here? I can test it later. |
This comment has been minimized.
This comment has been minimized.
Sure, I'll try this out. Should I use 3.13 source code or newest? |
Both would be great, But you can try 3.13 branch first! |
Hi @shinyano, thanks for the bug report. The Windows installer has an issue where not all the required macros are defined for the free threaded build. You can work around it by adjusting your setup.py to define the from setuptools import Extension, setup
import sysconfig
macros = []
if sysconfig.get_config_var("Py_GIL_DISABLED"):
macros.append(("Py_GIL_DISABLED", 1))
setup(ext_modules=[Extension("custom", ["custom.c"], define_macros=macros)]) |
Should we update the doc to remind this different or this would be fixed in 3.14? |
I don't think the issue will be fixed with the Windows installer any time soon (if ever). We should:
|
Here is the corresponding issue in setuptools: pypa/setuptools#4662 |
SGTM I have noticed that you have already commit to the setuptools. So I will update documentation. |
The PR to distutils turned out to be easy. Let's not bother with changing the newtypes tutorial -- it's already fairly long and I think the distutils/setuptools change will probably happen relatively quickly. |
SGTM, BTW I think distutils should release a new version ASAP. I will discuss this in distutils repo |
After some test I noticed that I'm doing
This is exacly what I needed to do, thank you all for the discussion. And I'm sorry for taking up your time with such a basic error. |
Bug report
Bug description:
Python3.13t seems to be unable to use C extensions which use new extension types?
According to
chapter 2.1. The Basics
in official guide, I wrote 3 files:custom.c
,pyproject.toml
andsetup.py
which were identical to the code provided in this tutorial.In the same location I executed
D:\python3.13\python3.13t.exe -m pip install .
The extension got installed successfully but when I executedimport custom
inpython3.13t.exe
, Python just exited without any output or errors:Then I tried
pip install
with stable version of 3.13, and successfully importedcustom
module:I'm using Windows11 and Python3.13, setuptools==75.2.0. The complete code is as follows:
custom.c
:pyproject.toml
:setup.py
:CPython versions tested on:
3.13
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: