baking-bad / pytezos

🐍 Python SDK for Tezos | Michelson VM in Python
https://pytezos.org
MIT License
112 stars 38 forks source link

pytezos broken with python 3.11 #336

Closed nicolasochem closed 1 year ago

nicolasochem commented 1 year ago

I'm refreshing our utils container used in tezos-k8s to do a variety of things before the octez container starts.

I found that I can't install pytezos in the python:3.11-alpine container. Best I can do is 3.10.

Here is a minimal Dockerfile that reproduces the problem:

FROM python:3.11-alpine

RUN     PIP="pip --no-cache install"                                    \
  APK_ADD="apk add --no-cache";                                 \
  $APK_ADD --virtual .build-deps gcc python3-dev                        \
  libffi-dev musl-dev make              \
  && $APK_ADD libsodium-dev libsecp256k1-dev gmp-dev                    \
  && $APK_ADD zeromq-dev                                                \
  && $PIP install pytezos

pytezos has a dependency on pysha3 which no longer works with python 3.11

  × Running setup.py install for pysha3 did not run successfully.                                                                                                                    
  │ exit code: 1                                                                                                                                                                     
  ╰─> [20 lines of output]                                                                                                                                                           
      running install                                                                                                                                                                
      /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-b
ased tools.                                                                                                                                                                          
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      copying sha3.py -> build/lib.linux-x86_64-cpython-311
      running build_ext
      building '_pysha3' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/Modules
      creating build/temp.linux-x86_64-cpython-311/Modules/_sha3
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPY_WITH_KECCAK=1 -I/usr/local/include/python3.11 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-311/Modules/_sha3/sha3module.o
      In file included from Modules/_sha3/sha3module.c:20:
      Modules/_sha3/backport.inc:78:10: fatal error: pystrhex.h: No such file or directory 
         78 | #include "pystrhex.h"
            |          ^~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1

It looks like pysha3 has been rolled into python and is no longer supported.

It does not appear to be a direct pytezos dependency, so you'd need to trace the dependency chain and potentially bump some version somewhere.

Thanks in advance :)

nicolasochem commented 1 year ago

btw you may want to replace the tqtezos logo with the oxhead alpha logo on the pytezos.org front page

droserasprout commented 1 year ago

Hi Nicolas!

Yeah, pystrhex.h header was removed in Python 3.11 breaking sha3. There's a PyTezos fork (crypto only) based on different libraries which possibly works with py311.

https://github.com/aleph-im/aleph-pytezos