Skip to content

trying mypyc on Cython-3.1.0a1 with Python-3.13.0b1 I get a "this header requires Py_BUILD_CORE define" #119203

Description

@stonebig

Bug report

Bug description:

on python-3.13.0b1 on Windows 11 non-english

mypyc WPy64-31300b1b\notebooks\docs\Solvers_Raymond_Hettinger\python\sudoku_norvig_for_comparison_of_complexity.py

generates

WPy64-31300b1b\notebooks\docs\Solvers_Raymond_Hettinger\python>mypyc WPy64-31300b1b\notebooks\docs\Solvers_Raymond_Hettinger\python\sudoku_norvig_for_comparison_of_complexity.py
WPy64-31300b1b\notebooks\docs\Solvers_Raymond_Hettinger\python\sudoku_norvig_for_comparison_of_complexity.py:123: warning: Treating generator comprehension as list
running build_ext
building 'sudoku_norvig_for_comparison_of_complexity' extension
creating build\temp.win-amd64-cpython-313
creating build\temp.win-amd64-cpython-313\Release
creating build\temp.win-amd64-cpython-313\Release\build
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IWPy64-31300b1b\python-3.13.0b1.amd64\Lib\site-packages\mypyc\lib-rt -IWPy64-31300b1b\python-3.13.0b1.amd64\include -IWPy64-31300b1b\python-3.13.0b1.amd64\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" /Tcbuild\__native.c /Fobuild\temp.win-amd64-cpython-313\Release\build\__native.obj /O2 /DEBUG:FASTLINK /wd4102 /wd4101 /wd4146
__native.c
WPy64-31300b1b\python-3.13.0b1.amd64\include\internal/pycore_frame.h(8): fatal error C1189: #error:  "this header requires Py_BUILD_CORE define"
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Activity

  1. stonebig commented on May 20, 2024

    @stonebig
    Author

    the problem doesn't occure with Python-3.12, so the 'unexpected' bad result of this wild experiment.

    python-3.13.0b1 was downloaded from python.org, and installed with this checkmarks (ep free-threading)
    image

    then I copied python3.13t.exe in python.exe

    package list

    Package              Version      Summary
    ____________________ ____________ ______________________________________________________________________
    appdirs              1.4.4        A small Python module for determining appropriate platform-specific di
    asttokens            2.4.1        Annotate AST trees with source code positions
    build                1.2.1        A simple, correct Python build frontend
    colorama             0.4.6        Cross-platform colored terminal text.
    cython               3.1.0a0      The Cython compiler for writing C extensions in the Python language.
    decorator            5.1.1        Decorators for Humans
    executing            2.0.1        Get the currently executing AST node of a frame, and other information
    interpreters-pep-734 0.1.0        Use this module to try out multiple interpreters and a per-interpreter
    ipython              8.24.0       IPython: Productive Interactive Computing
    jedi                 0.19.1       An autocompletion tool for Python that can be used for text editors.
    matplotlib-inline    0.1.6        Inline Matplotlib backend for Jupyter
    msvc-runtime         14.38.33135  Install the Microsoft™ Visual C++™ runtime DLLs to the sys.prefix and
    mypy                 1.8.0        Optional static typing for Python
    mypy-extensions      1.0.0        Type system extensions for programs checked with the mypy type checker
    packaging            24.0         Core utilities for Python packages
    parso                0.8.4        A Python Parser
    pip                  24.1b1       The PyPA recommended tool for installing Python packages.
    prompt-toolkit       3.0.43       Library for building powerful interactive command lines in Python
    psutil               5.9.5        Cross-platform lib for process and system monitoring in Python.
    ptpython             3.0.26       Python REPL build on top of prompt_toolkit
    pure-eval            0.2.2        Safely evaluate AST nodes without side effects
    pygments             2.17.2       Pygments is a syntax highlighting package written in Python.
    pyperf               2.7.0        Python module to run and analyze benchmarks
    pyproject-hooks      1.0.0        Wrappers to call pyproject.toml-based build backend hooks.
    setuptools           69.5.1       Easily download, build, install, upgrade, and uninstall Python package
    six                  1.16.0       Python 2 and 3 compatibility utilities
    sqlite-bro           0.13.1       a graphic SQLite Client in 1 Python file
    stack-data           0.6.3        Extract data from python stack frames and tracebacks for informative d
    traitlets            5.14.1       Traitlets Python configuration system
    typing-extensions    4.9.0        Backported and Experimental Type Hints for Python 3.8+
    wcwidth              0.2.13       Measures the displayed width of unicode strings in a terminal
    wheel                0.43.0       A built-package format for Python
    winpython            8.0.20240514 WinPython distribution tools, including WPPM
    
  2. stonebig commented on May 20, 2024

    @stonebig
    Author

    here it was written zephyrproject-rtos/windows-curses#26 (comment)

    "You can't use Py_BUILD_CORE as it's ONLY usable when building the CPython itself "

    so maybe the current way I got free-threading is the problem ?

  3. stonebig commented on May 20, 2024

    @stonebig
    Author

    coming from this ? gh-85283: If Py_LIMITED_API is defined, undefine Py_BUILD_CORE

    Apparently same error message with python-3.13.0b1 "standard"

  4. stonebig commented on May 20, 2024

    @stonebig
    Author

    trying the fibonacci cython tutorial https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html#fibonacci-fun

    • everything ok on python-3.13.0b1 "standard"
    • on python-3.13.0b1 "free_threading":
      • python setup.py build_ext --inplace does no error
      • but import fib cause python to exit with no error message
  5. stonebig commented on May 20, 2024

    @stonebig
    Author

    well it seems cython is far from ready at this point, so maybe it's too early to complain ?
    cython/cython#6162 (comment)

  6. emmatyping commented on May 20, 2024

    @emmatyping
    Member

    In 3.13 many functions and some internal headers were moved to be private.

    3.12 version without requiring PY_BUILD_CORE:
    https://github.com/python/cpython/blob/3.12/Include/internal/pycore_frame.h

    3.13 version requiring PY_BUILD_CORE:
    https://github.com/python/cpython/blob/3.13/Include/internal/pycore_frame.h#L7

    Mypyc and I believe Cython need to be updated before they will work with Python 3.13, so this error is a bug in mypyc/Cython

  7. vstinner commented on May 20, 2024

    @vstinner
    Member

    Mypyc and I believe Cython need to be updated before they will work with Python 3.13, so this error is a bug in mypyc/Cython

    Please report this issue to mypyc and/or Cython.

  8. da-woods commented on May 21, 2024

    @da-woods
    Contributor

    I agree with Victor that this is better reported to mypyc and/or Cython.

    I'm a bit puzzled by the issue though: Cython and mypyc are both Python->C transpilers; it'd be very odd to try to build Cython with MyPyC as the title suggests (it expects to either be built with itself, or just run as Python code).

    The current master branch of Cython does work with Python 3.13b1 (both regular build and the free-threading build). It isn't necessarily thread-safe so you can get into trouble if you try to use multiple threads. But for a simple, single-threaded program like the Fibonacci example it runs fine (and I've tested that and confirmed it).

  9. stonebig commented on May 21, 2024

    @stonebig
    Author

    When I import the compiled Fibonacci example of cython pages, my python REPL just quit.. are you sure free-threading works on windows with cython-3.1.0a0 ? (Stolen from CI)

    Applying an end-user procedure ? Devil can be in the detail of a end-user procedure done wrong

  10. stonebig commented on May 21, 2024

    @stonebig
    Author

    If it was possible, may you publish a pure-wheel of the working cython ? An a1 ? did try with a0 pure-wheel of May 9th and may 16th... maybe it's too much manual procedure, but failed at both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions