Skip to content
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

[Bug-Candidate]: Can't install slither on python 3.11 #1466

Closed
alephao opened this issue Nov 10, 2022 · 7 comments · Fixed by #1454
Closed

[Bug-Candidate]: Can't install slither on python 3.11 #1466

alephao opened this issue Nov 10, 2022 · 7 comments · Fixed by #1454
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@alephao
Copy link

alephao commented Nov 10, 2022

Describe the issue:

One of my CI jobs started failing to install slither and it seems to happen because of the pysha3 dependency when using python > 3.11 : https://github.com/alephao/solidity-template/actions/runs/3440054726/jobs/5738065786

After freezing python to 3.10 it started working again: https://github.com/alephao/solidity-template/actions/runs/3440105452/jobs/5738181105

I had a look on pysha3 repository and looks like it is deprecated and the owner suggests using the sha3 functions from the hashlib module.

Code example to reproduce the issue:

https://github.com/alephao/solidity-template/blob/ff2c556f185275a193b9f07006481ada73eb1c9d/.github/workflows/analyze.yml

Version:

0.9.1

Relevant log output:

Run pip install -r requirements.txt
2
  pip install -r requirements.txt
3
  shell: /usr/bin/bash -e {0}
4
  env:
5
    pythonLocation: /opt/hostedtoolcache/Python/3.11.0/x64
6
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.0/x64/lib/pkgconfig
7
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.0/x64
8
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.0/x64
9
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.0/x64
10
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.0/x64/lib
11
Collecting slither-analyzer
12
  Downloading slither_analyzer-0.9.1-py3-none-any.whl (615 kB)
13
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 615.0/615.0 kB 49.5 MB/s eta 0:00:00
14
Collecting solc-select
15
  Downloading solc_select-1.0.1-py3-none-any.whl (19 kB)
16
Collecting prettytable>=0.7.2
17
  Downloading prettytable-3.5.0-py3-none-any.whl (26 kB)
18
Collecting pysha3>=1.0.2
19
  Downloading pysha3-1.0.2.tar.gz (829 kB)
20
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 829.2/829.2 kB 95.2 MB/s eta 0:00:00
21
  Preparing metadata (setup.py): started
22
  Preparing metadata (setup.py): finished with status 'done'
23
Collecting crytic-compile>=0.2.4
24
  Downloading crytic_compile-0.2.4-py3-none-any.whl (87 kB)
25
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.7/87.7 kB 30.6 MB/s eta 0:00:00
26
Collecting packaging
27
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
28
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 kB 7.0 MB/s eta 0:00:00
29
Collecting wcwidth
30
  Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
31
Collecting pyparsing!=3.0.5,>=2.0.2
32
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
33
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 32.1 MB/s eta 0:00:00
34
Installing collected packages: wcwidth, pysha3, pyparsing, prettytable, crytic-compile, slither-analyzer, packaging, solc-select
35
  DEPRECATION: pysha3 is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
36
  Running setup.py install for pysha3: started
37
  Running setup.py install for pysha3: finished with status 'error'
38
  error: subprocess-exited-with-error
39
  
40
  × Running setup.py install for pysha3 did not run successfully.
41
  │ exit code: 1
42
  ╰─> [20 lines of output]
43
      running install
44
      /opt/hostedtoolcache/Python/3.11.0/x64/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.
45
        warnings.warn(
46
      running build
47
      running build_py
48
      creating build
49
      creating build/lib.linux-x86_64-cpython-311
50
      copying sha3.py -> build/lib.linux-x86_64-cpython-311
51
      running build_ext
52
      building '_pysha3' extension
53
      creating build/temp.linux-x86_64-cpython-311
54
      creating build/temp.linux-x86_64-cpython-311/Modules
55
      creating build/temp.linux-x86_64-cpython-311/Modules/_sha3
56
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_WITH_KECCAK=1 -I/opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-311/Modules/_sha3/sha3module.o
57
      In file included from Modules/_sha3/sha3module.c:20:
58
      Modules/_sha3/backport.inc:78:10: fatal error: pystrhex.h: No such file or directory
59
         78 | #include "pystrhex.h"
60
            |          ^~~~~~~~~~~~
61
      compilation terminated.
62
      error: command '/usr/bin/gcc' failed with exit code 1
63
      [end of output]
64
  
65
  note: This error originates from a subprocess, and is likely not a problem with pip.
66
error: legacy-install-failure
67

68
× Encountered error while trying to install package.
69
╰─> pysha3
70

71
note: This is an issue with the package mentioned above, not pip.
72
hint: See above for output from the failure.
73
Error: Process completed with exit code 1.
@alephao alephao added the bug-candidate Bugs reports that are not yet confirmed label Nov 10, 2022
@elopez
Copy link
Member

elopez commented Nov 10, 2022

Thanks for the report @alephao! A PR with a fix is open here: #1454. Many of the crytic tools have this dependency though, so it'll require updating several packages to achieve Python 3.11 compatibility.

Related: #1463, crytic/solc-select#125

@alephao
Copy link
Author

alephao commented Nov 10, 2022

Oh, that's great, thanks for the quick reply!

I searched for issues, but did not look into PRs, sorry if it's a duplicate!

If there a list of thing that needs to be updated I'm happy to pick something to help

@Akagi201
Copy link

pysha3 is outdated, please use https://docs.python.org/3/library/hashlib.html

@elopez elopez linked a pull request Nov 14, 2022 that will close this issue
@alephao alephao closed this as completed Nov 14, 2022
@0xalpharush
Copy link
Contributor

We haven't made a release so you will need to install the fix from pip using:
pip install git+https://github.com/crytic/slither@dev
Alternatively, you can downgrade to python 3.10 temporarily.

michalinacienciala added a commit to keep-network/keep-core that referenced this issue Dec 6, 2022
In a previous commit we wre trying to upgrade Python version to `3.11.0`, but we
discovered that the Slither installation does currently not work correctly when
that version is used (there's an Issue created for that, see
crytic/slither#1466). One of the recommended solutions
is temporary downgrade to Python `3.10`.
michalinacienciala added a commit to keep-network/keep-core that referenced this issue Dec 6, 2022
In a previous commit we wre trying to upgrade Python version to `3.11.0`, but we
discovered that the Slither installation does currently not work correctly when
that version is used (there's an Issue created for that, see
crytic/slither#1466). One of the recommended solutions
is temporary downgrade to Python `3.10`.
michalinacienciala added a commit to keep-network/keep-core that referenced this issue Dec 6, 2022
In a previous commit we were trying to upgrade Python version to `3.11.0`, but
we discovered that the Slither installation does currently not work correctly
when that version is used (there's an Issue created for that, see
crytic/slither#1466). One of the recommended solutions
is temporary downgrade to Python `3.10`. We tested that, but for some
reason, parameter was interpreted as `3.1`. Hence we're now using
`3.10.8`, which is the highest `3.10.x` version and it is available for
Ubuntu 22.04.
michalinacienciala added a commit to keep-network/coverage-pools that referenced this issue Dec 7, 2022
The `ubuntu-latest` runner used by us to run GH Actions jobs is getting migrated
from Ubuntu `20.04` to `22.04`
(actions/runner-images#6399). The `22.04` version does
not work with the config of the `actions/setup-python@v4` action which we use
in the jobs running slither. We were getting following failures in workflows:
```
Version 3.8.5 was not found in the local cache
Error: Version 3.8.5 with arch x64 not found
The list of all available versions can be found here:
https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
```
Based on actions/setup-python#555, we should upgrade
Python version to `3.9.12` or higher. Or we could configure job to run on the
hardcoded Ubuntu `20.04` runner.
According to Slither documentation `Slither requires Python 3.8+ and solc, the
Solidity compiler`, so upgrading to latest Python version (`3.11.0`) should be
ok. We tried using this version, but another issue occurred:
crytic/slither#1466. As recommended in the comments,
we downgraded the Python version (to `3.10.8`, which is supported on Ubuntu
`22.04`).
michalinacienciala added a commit to keep-network/tbtc-v2 that referenced this issue Dec 7, 2022
The `ubuntu-latest` runner used by us to run GH Actions jobs is getting migrated
from Ubuntu `20.04` to `22.04`
(actions/runner-images#6399). The `22.04` version does
not work with the config of the `actions/setup-python@v4` action which we use
in the jobs running slither. We were getting following failures in workflows:
```
Version 3.8.5 was not found in the local cache
Error: Version 3.8.5 with arch x64 not found
The list of all available versions can be found here:
https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
```
Based on actions/setup-python#555, we should upgrade
Python version to `3.9.12` or higher. Or we could configure job to run on the
hardcoded Ubuntu `20.04` runner.
According to Slither documentation `Slither requires Python 3.8+ and solc, the
Solidity compiler`, so upgrading to latest Python version (`3.11.0`) should be
ok. We tried using this version, but another issue occurred:
crytic/slither#1466. As recommended in the comments,
we downgraded the Python version (to `3.10.8`, which is supported on Ubuntu
`22.04`).
michalinacienciala added a commit to threshold-network/solidity-contracts that referenced this issue Dec 7, 2022
The `ubuntu-latest` runner used by us to run GH Actions jobs is getting migrated
from Ubuntu `20.04` to `22.04`
(actions/runner-images#6399). The `22.04` version does
not work with the config of the `actions/setup-python@v4` action which we use
in the jobs running slither. We were getting following failures in workflows:
```
Version 3.8.5 was not found in the local cache
Error: Version 3.8.5 with arch x64 not found
The list of all available versions can be found here:
https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
```
Based on actions/setup-python#555, we should upgrade
Python version to `3.9.12` or higher. Or we could configure job to run on the
hardcoded Ubuntu `20.04` runner.
According to Slither documentation `Slither requires Python 3.8+ and solc, the
Solidity compiler`, so upgrading to latest Python version (`3.11.0`) should be
ok. We tried using this version, but another issue occurred:
crytic/slither#1466. As recommended in the comments,
we downgraded the Python version (to `3.10.8`, which is supported on Ubuntu
`22.04`).
dimpar added a commit to keep-network/keep-core that referenced this issue Dec 7, 2022
The `ubuntu-latest` runner used by us to run GH Actions jobs is getting
migrated
from Ubuntu `20.04` to `22.04`
(actions/runner-images#6399). The `22.04`
version does
not work with the config of the `actions/setup-python@v4` action which
we use
in the jobs running slither. We were getting following failures in
workflows:
```
Version 3.8.5 was not found in the local cache
Error: Version 3.8.5 with arch x64 not found
The list of all available versions can be found here:
https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
```
Based on

actions/setup-python#555 (comment),
we
should update Python version to `3.9.12` or higher. Or we could
configure job to
run on the hardcoded Ubuntu 20.04 runner.
According to Slither documentation `Slither requires Python 3.8+ and
solc, the
Solidity compiler`,
so upgrading to latest Python version (`3.11.0`) should be ok.

We tried doing that, but another issue occurred:
crytic/slither#1466. As recommended in the
comments, we downgraded the Python version (to `3.10.8`, which is
supported on Ubuntu `22.04`).

As part of this PR we're changing workflows configs so that the
workflows would
be triggered also on changes to their config. This should allow for
testing of
the aforementioned python version change.

Refs:
keep-network/coverage-pools#219
keep-network/tbtc-v2#423
threshold-network/solidity-contracts#131
@0xNadr
Copy link

0xNadr commented Dec 25, 2022

I am having the same issue downgraded python to 3.10.8 but still nothing

@taiyangc
Copy link

taiyangc commented Jan 1, 2023

Is there a plan for a new release to include this fix?

@0xmp
Copy link

0xmp commented Mar 7, 2023

I ran into a similar issue trying to use slither-read-storage with Python 3.11. In my case it was related to an issue with the web3 package (ethereum/web3.py#2704), and was caught under the following exception
ERROR: in order to use slither-read-storage, you need to install web3.

I don't think there's anything to do here as it will be fixed on its own when the web3 pip package new release gets approved. Downgrading to Python 3.9 worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants