gleb-sevruk / pycrunch-trace

Time Travel Debugging for Python
https://pytrace.com
MIT License
149 stars 11 forks source link

Errors running on Python 3.11 #12

Closed Andrej730 closed 1 month ago

Andrej730 commented 1 month ago

Installing with the commands below (with protobuf > 3.20 it throws even more errors).

pip install pycrunch-trace
pip install protobuf==3.20

Running example code:

from pycrunch_trace.client.api import Trace

tracer = Trace()
tracer.start('recording_name')

def some_code():
    print('hi')

some_code()

tracer.stop()

Error

\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: \pycrunch_trace\events\file_contents_in_protobuf.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
    cdef NativeStackFrame parent
    cdef NativeExecutionCursor cursor
    cdef int id

cdef class NativeCodeEvent:
    cpdef str event_name
          ^
------------------------------------------------------------

\pycrunch_trace\native\native_models.pxd:15:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Traceback (most recent call last):
  File "\pyximport\_pyximport3.py", line 314, in create_module
    so_path = build_module(spec.name, pyxfilename=spec.origin, pyxbuild_dir=self._pyxbuild_dir,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\pyximport\_pyximport3.py", line 197, in build_module
    so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\pyximport\pyxbuild.py", line 103, in pyx_to_dll
    dist.run_commands()
  File "\setuptools\_distutils\dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "\setuptools\dist.py", line 976, in run_command
    super().run_command(command)
  File "\setuptools\_distutils\dist.py", line 988, in run_command
    cmd_obj.run()
  File "\setuptools\_distutils\command\build_ext.py", line 359, in run
    self.build_extensions()
  File "\setuptools\_distutils\command\build_ext.py", line 479, in build_extensions
    self._build_extensions_serial()
  File "\setuptools\_distutils\command\build_ext.py", line 505, in _build_extensions_serial
    self.build_extension(ext)
  File "\Cython\Distutils\build_ext.py", line 130, in build_extension
    new_ext = cythonize(
              ^^^^^^^^^^
  File "\Cython\Build\Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "\Cython\Build\Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: \pycrunch_trace\events\file_contents_in_protobuf.pyx

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "\pyximport\_pyximport3.py", line 336, in exec_module
    return super().exec_module(module)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 1241, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "native_write_strategy.pyx", line 8, in init pycrunch_trace.client.networking.strategies.native_write_strategy
  File "\pyximport\_pyximport3.py", line 332, in create_module
    raise exc.with_traceback(tb)
  File "\pyximport\_pyximport3.py", line 314, in create_module
    so_path = build_module(spec.name, pyxfilename=spec.origin, pyxbuild_dir=self._pyxbuild_dir,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\pyximport\_pyximport3.py", line 197, in build_module
    so_path = pyxbuild.pyx_to_dll(pyxfilename, extension_mod,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\pyximport\pyxbuild.py", line 103, in pyx_to_dll
    dist.run_commands()
  File "\setuptools\_distutils\dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "\setuptools\dist.py", line 976, in run_command
    super().run_command(command)
  File "\setuptools\_distutils\dist.py", line 988, in run_command
    cmd_obj.run()
  File "\setuptools\_distutils\command\build_ext.py", line 359, in run
    self.build_extensions()
  File "\setuptools\_distutils\command\build_ext.py", line 479, in build_extensions
    self._build_extensions_serial()
  File "\setuptools\_distutils\command\build_ext.py", line 505, in _build_extensions_serial
    self.build_extension(ext)
  File "\Cython\Distutils\build_ext.py", line 130, in build_extension
    new_ext = cythonize(
              ^^^^^^^^^^
  File "\Cython\Build\Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "\Cython\Build\Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
ImportError: Building module pycrunch_trace.events.file_contents_in_protobuf failed: ['Cython.Compiler.Errors.CompileError: pycrunch_trace\\events\\file_contents_in_protobuf.pyx\n']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "\test.py", line 1, in <module>
    from pycrunch_trace.client.api import Trace
  File "\pycrunch_trace\client\api\__init__.py", line 1, in <module>
    from .trace_decorator import trace
  File "\pycrunch_trace\client\api\trace_decorator.py", line 2, in <module>
    from pycrunch_trace.client.api.trace import Trace
  File "\pycrunch_trace\client\api\trace.py", line 8, in <module>
    from pycrunch_trace.client.networking import event_queue
  File "\pycrunch_trace\client\networking\__init__.py", line 1, in <module>
    from .ClientOutgoingQueueThread import event_queue
  File "\pycrunch_trace\client\networking\ClientOutgoingQueueThread.py", line 13, in <module>
    from pycrunch_trace.client.networking.strategies.native_write_strategy import NativeLocalRecordingStrategy
  File "\pyximport\_pyximport3.py", line 340, in exec_module
    raise ImportError("Executing module %s failed %s" % (
ImportError: Executing module \.pyxbld\lib.win-amd64-cpython-311\pycrunch_trace\client\networking\strategies\native_write_strategy.cp311-win_amd64.pyd failed ["ImportError: Building module pycrunch_trace.events.file_contents_in_protobuf failed: ['Cython.Compiler.Errors.CompileError: pycrunch_trace\\\\events\\\\file_contents_in_protobuf.pyx\\n']\n"]
Andrej730 commented 1 month ago

For anyone trying to make it work - can confirm that I got it working by using Python 3.10 and pip install protobuf==3.11.3 Cython==0.29.27 (latest versions of python and cython based for the current last commit 2d047a216393ab9d983629dfbc0dc862c929086f, protobuf version comes from requirements.txt).

In fact it seems to work with any Cython version prior to 3.0.0 (latest currently is 0.29.37) and protobuf prior to 4.0 (latest currently is 3.20.3)