GoogleCloudPlatform / cloud-profiler-python

Stackdriver Profiler Python agent is a tool that continuously gathers CPU usage information from Python applications
Apache License 2.0
27 stars 23 forks source link

Cannot compile with Python 3.11 #127

Closed ray-ray closed 1 year ago

ray-ray commented 1 year ago

pip install fails using this Dockerfile (from https://cloud.google.com/profiler/docs/profiling-python#using-profiler ):

FROM python:3
RUN apt-get update && apt-get install -y build-essential python3-pip
RUN pip3 install google-cloud-profiler

Here is the build output:

% docker build --no-cache -t gcloud-profiler:local .
[+] Building 16.7s (6/6) FINISHED                                                                                                                                                               
 => [internal] load build definition from Dockerfile                                                                                                                                       0.0s
 => => transferring dockerfile: 163B                                                                                                                                                       0.0s
 => [internal] load .dockerignore                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/python:3                                                                                                                                0.2s
 => CACHED [1/3] FROM docker.io/library/python:3@sha256:10fc14aa6ae69f69e4c953cffd9b0964843d8c163950491d2138af891377bc1d                                                                   0.0s
 => [2/3] RUN apt-get update && apt-get install -y build-essential python3-pip                                                                                                             6.1s
 => ERROR [3/3] RUN pip3 install google-cloud-profiler                                                                                                                                    10.3s 
------                                                                                                                                                                                          
 > [3/3] RUN pip3 install google-cloud-profiler:                                                                                                                                                
#6 1.591 Collecting google-cloud-profiler                                                                                                                                                       
#6 1.722   Downloading google-cloud-profiler-4.0.0.tar.gz (30 kB)                                                                                                                               
#6 1.737   Preparing metadata (setup.py): started                                                                                                                                               
#6 2.193   Preparing metadata (setup.py): finished with status 'done'                                                                                                                           
#6 2.295 Collecting google-api-python-client!=1.12.0,!=2.0.2
#6 2.315   Downloading google_api_python_client-2.66.0-py2.py3-none-any.whl (10.5 MB)
#6 3.372      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.5/10.5 MB 10.1 MB/s eta 0:00:00
#6 3.509 Collecting google-auth>=1.0.0
#6 3.528   Downloading google_auth-2.14.1-py2.py3-none-any.whl (175 kB)
#6 3.562      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.4/175.4 kB 5.3 MB/s eta 0:00:00
#6 3.598 Collecting google-auth-httplib2
#6 3.624   Downloading google_auth_httplib2-0.1.0-py2.py3-none-any.whl (9.3 kB)
#6 3.852 Collecting protobuf
#6 3.890   Downloading protobuf-4.21.9-cp37-abi3-manylinux2014_x86_64.whl (408 kB)
#6 3.969      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 408.4/408.4 kB 5.3 MB/s eta 0:00:00
#6 4.030 Collecting requests
#6 4.049   Downloading requests-2.28.1-py3-none-any.whl (62 kB)
#6 4.060      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 11.9 MB/s eta 0:00:00
#6 4.125 Collecting httplib2<1dev,>=0.15.0
#6 4.147   Downloading httplib2-0.21.0-py3-none-any.whl (96 kB)
#6 4.158      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.8/96.8 kB 11.0 MB/s eta 0:00:00
#6 4.259 Collecting google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
#6 4.275   Downloading google_api_core-2.10.2-py3-none-any.whl (115 kB)
#6 4.288      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.6/115.6 kB 10.3 MB/s eta 0:00:00
#6 4.324 Collecting uritemplate<5,>=3.0.1
#6 4.344   Downloading uritemplate-4.1.1-py2.py3-none-any.whl (10 kB)
#6 4.443 Collecting cachetools<6.0,>=2.0.0
#6 4.473   Downloading cachetools-5.2.0-py3-none-any.whl (9.3 kB)
#6 4.527 Collecting pyasn1-modules>=0.2.1
#6 4.549   Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
#6 4.563      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 12.5 MB/s eta 0:00:00
#6 4.595 Collecting six>=1.9.0
#6 4.616   Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
#6 4.657 Collecting rsa<5,>=3.1.4
#6 4.682   Downloading rsa-4.9-py3-none-any.whl (34 kB)
#6 4.780 Collecting charset-normalizer<3,>=2
#6 4.801   Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
#6 4.843 Collecting idna<4,>=2.5
#6 4.860   Downloading idna-3.4-py3-none-any.whl (61 kB)
#6 4.879      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 6.0 MB/s eta 0:00:00
#6 4.943 Collecting urllib3<1.27,>=1.21.1
#6 4.970   Downloading urllib3-1.26.13-py2.py3-none-any.whl (140 kB)
#6 4.984      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.6/140.6 kB 11.1 MB/s eta 0:00:00
#6 5.028 Collecting certifi>=2017.4.17
#6 5.055   Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)
#6 5.071      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 161.1/161.1 kB 11.4 MB/s eta 0:00:00
#6 5.155 Collecting googleapis-common-protos<2.0dev,>=1.56.2
#6 5.177   Downloading googleapis_common_protos-1.57.0-py2.py3-none-any.whl (217 kB)
#6 5.204      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 218.0/218.0 kB 8.4 MB/s eta 0:00:00
#6 5.306 Collecting pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2
#6 5.323   Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
#6 5.336      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 8.1 MB/s eta 0:00:00
#6 5.395 Collecting pyasn1<0.5.0,>=0.4.6
#6 5.429   Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
#6 5.453      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 3.1 MB/s eta 0:00:00
#6 5.521 Building wheels for collected packages: google-cloud-profiler
#6 5.523   Building wheel for google-cloud-profiler (setup.py): started
#6 6.826   Building wheel for google-cloud-profiler (setup.py): finished with status 'error'
#6 6.833   error: subprocess-exited-with-error
#6 6.833   
#6 6.833   × python setup.py bdist_wheel did not run successfully.
#6 6.833   │ exit code: 1
#6 6.833   ╰─> [74 lines of output]
#6 6.833       running bdist_wheel
#6 6.833       running build
#6 6.833       running build_py
#6 6.833       creating build
#6 6.833       creating build/lib.linux-x86_64-cpython-311
#6 6.833       creating build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/pythonprofiler.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/profile_pb2.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/cpu_profiler.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/__version__.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/__init__.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/backoff.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/builder.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       copying googlecloudprofiler/client.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       running build_ext
#6 6.833       building 'googlecloudprofiler._profiler' extension
#6 6.833       creating build/temp.linux-x86_64-cpython-311
#6 6.833       creating build/temp.linux-x86_64-cpython-311/googlecloudprofiler
#6 6.833       creating build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src
#6 6.833       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/_profiler.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/_profiler.o -std=c++11
#6 6.833       In file included from googlecloudprofiler/src/profiler.h:26,
#6 6.833                        from googlecloudprofiler/src/_profiler.cc:18:
#6 6.833       googlecloudprofiler/src/stacktraces.h: In member function ‘void AsyncSafeTraceMultiset::Reset()’:
#6 6.833       googlecloudprofiler/src/stacktraces.h:72:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct AsyncSafeTraceMultiset::TraceData’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
#6 6.833          72 |   void Reset() { memset(traces_, 0, sizeof(traces_)); }
#6 6.833             |                                                    ^
#6 6.833       googlecloudprofiler/src/stacktraces.h:89:10: note: ‘struct AsyncSafeTraceMultiset::TraceData’ declared here
#6 6.833          89 |   struct TraceData {
#6 6.833             |          ^~~~~~~~~
#6 6.833       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/clock.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/clock.o -std=c++11
#6 6.833       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/log.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/log.o -std=c++11
#6 6.833       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/profiler.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/profiler.o -std=c++11
#6 6.833       In file included from googlecloudprofiler/src/profiler.h:26,
#6 6.833                        from googlecloudprofiler/src/profiler.cc:15:
#6 6.833       googlecloudprofiler/src/stacktraces.h: In member function ‘void AsyncSafeTraceMultiset::Reset()’:
#6 6.833       googlecloudprofiler/src/stacktraces.h:72:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct AsyncSafeTraceMultiset::TraceData’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
#6 6.833          72 |   void Reset() { memset(traces_, 0, sizeof(traces_)); }
#6 6.833             |                                                    ^
#6 6.833       googlecloudprofiler/src/stacktraces.h:89:10: note: ‘struct AsyncSafeTraceMultiset::TraceData’ declared here
#6 6.833          89 |   struct TraceData {
#6 6.833             |          ^~~~~~~~~
#6 6.833       googlecloudprofiler/src/profiler.cc: In static member function ‘static void Profiler::Handle(int, siginfo_t*, void*)’:
#6 6.833       googlecloudprofiler/src/profiler.cc:160:32: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘frame’; did you mean ‘cframe’?
#6 6.833         160 |     PyFrameObject *frame = ts->frame;
#6 6.833             |                                ^~~~~
#6 6.833             |                                cframe
#6 6.833       googlecloudprofiler/src/profiler.cc:163:40: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833         163 |       frames[num_frames].lineno = frame->f_lineno;
#6 6.833             |                                        ^~
#6 6.833       In file included from /usr/local/include/python3.11/Python.h:42,
#6 6.833                        from googlecloudprofiler/src/profiler.h:18,
#6 6.833                        from googlecloudprofiler/src/profiler.cc:15:
#6 6.833       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833          22 | typedef struct _frame PyFrameObject;
#6 6.833             |                ^~~~~~
#6 6.833       googlecloudprofiler/src/profiler.cc:164:41: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833         164 |       frames[num_frames].py_code = frame->f_code;
#6 6.833             |                                         ^~
#6 6.833       In file included from /usr/local/include/python3.11/Python.h:42,
#6 6.833                        from googlecloudprofiler/src/profiler.h:18,
#6 6.833                        from googlecloudprofiler/src/profiler.cc:15:
#6 6.833       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833          22 | typedef struct _frame PyFrameObject;
#6 6.833             |                ^~~~~~
#6 6.833       googlecloudprofiler/src/profiler.cc:166:20: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833         166 |       frame = frame->f_back;
#6 6.833             |                    ^~
#6 6.833       In file included from /usr/local/include/python3.11/Python.h:42,
#6 6.833                        from googlecloudprofiler/src/profiler.h:18,
#6 6.833                        from googlecloudprofiler/src/profiler.cc:15:
#6 6.833       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 6.833          22 | typedef struct _frame PyFrameObject;
#6 6.833             |                ^~~~~~
#6 6.833       error: command '/usr/bin/gcc' failed with exit code 1
#6 6.833       [end of output]
#6 6.833   
#6 6.833   note: This error originates from a subprocess, and is likely not a problem with pip.
#6 6.834   ERROR: Failed building wheel for google-cloud-profiler
#6 6.838   Running setup.py clean for google-cloud-profiler
#6 7.025 Failed to build google-cloud-profiler
#6 7.115 Installing collected packages: pyasn1, urllib3, uritemplate, six, rsa, pyparsing, pyasn1-modules, protobuf, idna, charset-normalizer, certifi, cachetools, requests, httplib2, googleapis-common-protos, google-auth, google-auth-httplib2, google-api-core, google-api-python-client, google-cloud-profiler
#6 8.314   Running setup.py install for google-cloud-profiler: started
#6 9.592   Running setup.py install for google-cloud-profiler: finished with status 'error'
#6 9.598   error: subprocess-exited-with-error
#6 9.598   
#6 9.598   × Running setup.py install for google-cloud-profiler did not run successfully.
#6 9.598   │ exit code: 1
#6 9.598   ╰─> [76 lines of output]
#6 9.598       running install
#6 9.598       /usr/local/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
#6 9.598         warnings.warn(
#6 9.598       running build
#6 9.598       running build_py
#6 9.598       creating build
#6 9.598       creating build/lib.linux-x86_64-cpython-311
#6 9.598       creating build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/pythonprofiler.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/profile_pb2.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/cpu_profiler.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/__version__.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/__init__.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/backoff.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/builder.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       copying googlecloudprofiler/client.py -> build/lib.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       running build_ext
#6 9.598       building 'googlecloudprofiler._profiler' extension
#6 9.598       creating build/temp.linux-x86_64-cpython-311
#6 9.598       creating build/temp.linux-x86_64-cpython-311/googlecloudprofiler
#6 9.598       creating build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src
#6 9.598       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/_profiler.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/_profiler.o -std=c++11
#6 9.598       In file included from googlecloudprofiler/src/profiler.h:26,
#6 9.598                        from googlecloudprofiler/src/_profiler.cc:18:
#6 9.598       googlecloudprofiler/src/stacktraces.h: In member function ‘void AsyncSafeTraceMultiset::Reset()’:
#6 9.598       googlecloudprofiler/src/stacktraces.h:72:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct AsyncSafeTraceMultiset::TraceData’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
#6 9.598          72 |   void Reset() { memset(traces_, 0, sizeof(traces_)); }
#6 9.598             |                                                    ^
#6 9.598       googlecloudprofiler/src/stacktraces.h:89:10: note: ‘struct AsyncSafeTraceMultiset::TraceData’ declared here
#6 9.598          89 |   struct TraceData {
#6 9.598             |          ^~~~~~~~~
#6 9.598       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/clock.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/clock.o -std=c++11
#6 9.598       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/log.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/log.o -std=c++11
#6 9.598       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Igooglecloudprofiler/src -I/usr/local/include/python3.11 -c googlecloudprofiler/src/profiler.cc -o build/temp.linux-x86_64-cpython-311/googlecloudprofiler/src/profiler.o -std=c++11
#6 9.598       In file included from googlecloudprofiler/src/profiler.h:26,
#6 9.598                        from googlecloudprofiler/src/profiler.cc:15:
#6 9.598       googlecloudprofiler/src/stacktraces.h: In member function ‘void AsyncSafeTraceMultiset::Reset()’:
#6 9.598       googlecloudprofiler/src/stacktraces.h:72:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct AsyncSafeTraceMultiset::TraceData’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
#6 9.598          72 |   void Reset() { memset(traces_, 0, sizeof(traces_)); }
#6 9.598             |                                                    ^
#6 9.598       googlecloudprofiler/src/stacktraces.h:89:10: note: ‘struct AsyncSafeTraceMultiset::TraceData’ declared here
#6 9.598          89 |   struct TraceData {
#6 9.598             |          ^~~~~~~~~
#6 9.598       googlecloudprofiler/src/profiler.cc: In static member function ‘static void Profiler::Handle(int, siginfo_t*, void*)’:
#6 9.598       googlecloudprofiler/src/profiler.cc:160:32: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘frame’; did you mean ‘cframe’?
#6 9.598         160 |     PyFrameObject *frame = ts->frame;
#6 9.598             |                                ^~~~~
#6 9.598             |                                cframe
#6 9.598       googlecloudprofiler/src/profiler.cc:163:40: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598         163 |       frames[num_frames].lineno = frame->f_lineno;
#6 9.598             |                                        ^~
#6 9.598       In file included from /usr/local/include/python3.11/Python.h:42,
#6 9.598                        from googlecloudprofiler/src/profiler.h:18,
#6 9.598                        from googlecloudprofiler/src/profiler.cc:15:
#6 9.598       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598          22 | typedef struct _frame PyFrameObject;
#6 9.598             |                ^~~~~~
#6 9.598       googlecloudprofiler/src/profiler.cc:164:41: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598         164 |       frames[num_frames].py_code = frame->f_code;
#6 9.598             |                                         ^~
#6 9.598       In file included from /usr/local/include/python3.11/Python.h:42,
#6 9.598                        from googlecloudprofiler/src/profiler.h:18,
#6 9.598                        from googlecloudprofiler/src/profiler.cc:15:
#6 9.598       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598          22 | typedef struct _frame PyFrameObject;
#6 9.598             |                ^~~~~~
#6 9.598       googlecloudprofiler/src/profiler.cc:166:20: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598         166 |       frame = frame->f_back;
#6 9.598             |                    ^~
#6 9.598       In file included from /usr/local/include/python3.11/Python.h:42,
#6 9.598                        from googlecloudprofiler/src/profiler.h:18,
#6 9.598                        from googlecloudprofiler/src/profiler.cc:15:
#6 9.598       /usr/local/include/python3.11/pytypedefs.h:22:16: note: forward declaration of ‘PyFrameObject’ {aka ‘struct _frame’}
#6 9.598          22 | typedef struct _frame PyFrameObject;
#6 9.598             |                ^~~~~~
#6 9.598       error: command '/usr/bin/gcc' failed with exit code 1
#6 9.598       [end of output]
#6 9.598   
#6 9.598   note: This error originates from a subprocess, and is likely not a problem with pip.
#6 9.601 error: legacy-install-failure
#6 9.601 
#6 9.601 × Encountered error while trying to install package.
#6 9.601 ╰─> google-cloud-profiler
#6 9.601 
#6 9.601 note: This is an issue with the package mentioned above, not pip.
#6 9.601 hint: See above for output from the failure.
#6 9.780 
#6 9.780 [notice] A new release of pip available: 22.3 -> 22.3.1
#6 9.780 [notice] To update, run: pip install --upgrade pip
------
executor failed running [/bin/sh -c pip3 install google-cloud-profiler]: exit code: 1

python:3 is equivalent to python:3.11.0 The install does succeed if I instead use python:3.10.8

mathieu-benoit commented 1 year ago

Same issue here: https://github.com/GoogleCloudPlatform/microservices-demo/pull/1318 with python:3.11.0 but not with python:3.10.8.

In file included from googlecloudprofiler/src/profiler.h:26,
                       from googlecloudprofiler/src/_profiler.cc:18:
      googlecloudprofiler/src/stacktraces.h: In member function ‘void AsyncSafeTraceMultiset::Reset()’:
      googlecloudprofiler/src/stacktraces.h:72:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct AsyncSafeTraceMultiset::TraceData’ with no trivial copy-assignment; use value-initialization instead [-Wclass-memaccess]
         72 |   void Reset() { memset(traces_, 0, sizeof(traces_)); }
            |                                                    ^
      googlecloudprofiler/src/stacktraces.h:89:10: note: ‘struct AsyncSafeTraceMultiset::TraceData’ declared here
         89 |   struct TraceData {
            |          ^~~~~~~~~
× Encountered error while trying to install package.
╰─> google-cloud-profiler
aabmass commented 1 year ago

The actual issue is that the build is broken with 3.11, it is not specific to docker. The breaking change in the Python C API is https://docs.python.org/3/whatsnew/3.11.html#pyframeobject-3-11-hiding. I'm working on a fix

aabmass commented 1 year ago

Hey folks. #131 potentially adds support for Python 3.11.

However, I am not particularly confident that this fix is safe/correct. The handler operates possibly without the GIL, as it does not currently modify any of the PyObjects it works with. It gets the thread local ThreadState with PyGILState_GetThisThreadState().

The problem is that the getters described in the changelog (PyThreadState_GetFrame(), PyFrame_GetCode(), PyFrame_GetBack()) increment the refcount for those PyObjects which afaict is NOT safe to do without holding the GIL. Trying to acquire the GIL in the handler seems to deadlock some of the internal integration tests; I'm also not confident that this would be async-signal-safe.

Folks are welcome to try the profiler in Python 3.11 from this PR but I am not comfortable merging it as is. If you do try it, please report back on if you encountered any issues. I unfortunately don't have the time to work more on getting this merged right now.

GabrieleCalarota commented 1 year ago

Is there any update on this? 🙏🏻

aabmass commented 1 year ago

I took another approach and just merged the PR. Hopefully should see a release next week, but you're welcome to try it from HEAD.