Skip to content

Commit

Permalink
add support for python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed Mar 1, 2024
1 parent 6368368 commit 0c10e27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-2022"]
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.11"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11"]') }}
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.12"]')) || fromJSON('["3.8", "3.9", "3.10", "3.12"]') }}
type: ["cli",
"dapp",
"data_dependency",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
os: ["ubuntu-latest", "windows-2022"]
type: ["unit", "integration", "tool"]
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.11"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11"]') }}
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.12"]')) || fromJSON('["3.8", "3.9", "3.10", "3.12"]') }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
Expand Down
13 changes: 10 additions & 3 deletions slither/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import pstats
import sys
import traceback
from importlib import metadata
from typing import Tuple, Optional, List, Dict, Type, Union, Any, Sequence

from pkg_resources import iter_entry_points, require

from crytic_compile import cryticparser, CryticCompile
from crytic_compile.platform.standard import generate_standard_export
Expand Down Expand Up @@ -166,7 +166,14 @@ def get_detectors_and_printers() -> Tuple[
printers = [p for p in printers_ if inspect.isclass(p) and issubclass(p, AbstractPrinter)]

# Handle plugins!
for entry_point in iter_entry_points(group="slither_analyzer.plugin", name=None):
if sys.version_info >= (3, 10):
entry_points = metadata.entry_points(group="slither_analyzer.plugin")
else:
from pkg_resources import iter_entry_points # pylint: disable=import-outside-toplevel

entry_points = iter_entry_points(group="slither_analyzer.plugin", name=None)

for entry_point in entry_points:
make_plugin = entry_point.load()

plugin_detectors, plugin_printers = make_plugin()
Expand Down Expand Up @@ -298,7 +305,7 @@ def parse_args(
parser.add_argument(
"--version",
help="displays the current version",
version=require("slither-analyzer")[0].version,
version=metadata.version("slither-analyzer"),
action="version",
)

Expand Down
4 changes: 2 additions & 2 deletions slither/utils/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import os
import zipfile
from collections import OrderedDict
from importlib import metadata
from typing import Tuple, Optional, Dict, List, Union, Any, TYPE_CHECKING, Type
from zipfile import ZipFile

from pkg_resources import require

from slither.core.cfg.node import Node
from slither.core.declarations import (
Expand Down Expand Up @@ -161,7 +161,7 @@ def output_to_sarif(
"driver": {
"name": "Slither",
"informationUri": "https://github.com/crytic/slither",
"version": require("slither-analyzer")[0].version,
"version": metadata.version("slither-analyzer"),
"rules": [],
}
},
Expand Down

0 comments on commit 0c10e27

Please sign in to comment.