prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  web3 import errors in Python 3.12
  * Version: 6.13.0
  * Python: 3.12, inside a venv
  * OS: linux (but is probably applicable to other platforms as well)
  * `pip freeze` output:
  
  ```
  aiohttp==3.9.1
  aiosignal==1.3.1
  attrs==23.2.0
  bitarray==2.9.2
  certifi==2023.11.17
  charset-normalizer==3.3.2
  cytoolz==0.12.2
  eth-abi==4.2.1
  eth-account==0.10.0
  eth-hash==0.5.2
  eth-keyfile==0.7.0
  eth-keys==0.4.0
  eth-rlp==1.0.0
  eth-typing==3.5.2
  eth-utils==2.3.1
  frozenlist==1.4.1
  hexbytes==0.3.1
  idna==3.6
  jsonschema==4.20.0
  jsonschema-specifications==2023.12.1
  lru-dict==1.2.0
  multidict==6.0.4
  parsimonious==0.9.0
  protobuf==4.25.1
  pycryptodome==3.19.1
  pyunormalize==15.1.0
  referencing==0.32.1
  regex==2023.12.25
  requests==2.31.0
  rlp==4.0.0
  rpds-py==0.16.2
  toolz==0.12.0
  typing_extensions==4.9.0
  urllib3==2.1.0
  web3==6.13.0
  websockets==12.0
  yarl==1.9.4
  ```
  
  ### What was wrong?
  
  In certain situations, web3 will raise ImportErrors on python 3.12 if the `setuptools` package is not installed. _In particular, this happens inside a  fresh Python 3.12 venv._ The `setuptools` package automatically installs the `pkg_resources` package, which is used in web3 [here](https://github.com/ethereum/web3.py/blob/8f853f5841fd62187bce0c9f17be75627104ca43/web3/__init__.py#L25). This used to work fine in older Python versions. However, according to the [new changes in 3.12](https://docs.python.org/3/whatsnew/3.12.html):
  
  > gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.
  
  This means that the pkg_resources package is no longer accessible which causes this error.
  
  Among other things, this scenario can occur inside tox tests for projects that have the `web3` package installed and are configured to test against 3.12. This causes such tests to immediately fail because of the ImportError. The workaround, installing setuptools after the venv created, causes unnecessarily long test times, adding about 3 minutes to the run time.
  
  ### How can it be fixed?
  
  Given that web3's use of setuptools/pkg_resources is limited to just getting the version number, this should be trivial to fix. Why not open the file with built-in functions such as `open()` and parse it for the version number? I don't think that `web3` should continue to depend on setuptools.
  
  </issue>
  <code>
  [start of web3/__init__.py]
  1 from eth_account import Account  # noqa: E402,
  2 import pkg_resources
  3 
  4 from web3.main import (
  5     AsyncWeb3,
  6     Web3,
  7 )
  8 from web3.providers.async_rpc import (  # noqa: E402
  9     AsyncHTTPProvider,
  10 )
  11 from web3.providers.eth_tester import (  # noqa: E402
  12     EthereumTesterProvider,
  13 )
  14 from web3.providers.ipc import (  # noqa: E402
  15     IPCProvider,
  16 )
  17 from web3.providers.rpc import (  # noqa: E402
  18     HTTPProvider,
  19 )
  20 from web3.providers.websocket import (  # noqa: E402
  21     WebsocketProvider,
  22     WebsocketProviderV2,
  23 )
  24 
  25 __version__ = pkg_resources.get_distribution("web3").version
  26 
  27 __all__ = [
  28     "__version__",
  29     "AsyncWeb3",
  30     "Web3",
  31     "HTTPProvider",
  32     "IPCProvider",
  33     "WebsocketProvider",
  34     "WebsocketProviderV2",
  35     "EthereumTesterProvider",
  36     "Account",
  37     "AsyncHTTPProvider",
  38 ]
  39
  [end of web3/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/web3/__init__.py b/web3/__init__.py
  --- a/web3/__init__.py
  +++ b/web3/__init__.py
  @@ -1,5 +1,15 @@
  -from eth_account import Account  # noqa: E402,
  -import pkg_resources
  +from eth_account import Account  # noqa: E402
  +import sys
  +
  +if sys.version_info.major == 3 and sys.version_info.minor < 8:
  +    import pkg_resources
  +
  +    __version__ = pkg_resources.get_distribution("web3").version
  +else:
  +    from importlib.metadata import version
  +
  +    __version__ = version("web3")
  +
   
   from web3.main import (
       AsyncWeb3,
  @@ -22,7 +32,6 @@
       WebsocketProviderV2,
   )
   
  -__version__ = pkg_resources.get_distribution("web3").version
   
   __all__ = [
       "__version__",
  
verification_info: {"golden_diff": "diff --git a/web3/__init__.py b/web3/__init__.py\n--- a/web3/__init__.py\n+++ b/web3/__init__.py\n@@ -1,5 +1,15 @@\n-from eth_account import Account  # noqa: E402,\n-import pkg_resources\n+from eth_account import Account  # noqa: E402\n+import sys\n+\n+if sys.version_info.major == 3 and sys.version_info.minor < 8:\n+    import pkg_resources\n+\n+    __version__ = pkg_resources.get_distribution(\"web3\").version\n+else:\n+    from importlib.metadata import version\n+\n+    __version__ = version(\"web3\")\n+\n \n from web3.main import (\n     AsyncWeb3,\n@@ -22,7 +32,6 @@\n     WebsocketProviderV2,\n )\n \n-__version__ = pkg_resources.get_distribution(\"web3\").version\n \n __all__ = [\n     \"__version__\",\n", "issue": "web3 import errors in Python 3.12\n* Version: 6.13.0\r\n* Python: 3.12, inside a venv\r\n* OS: linux (but is probably applicable to other platforms as well)\r\n* `pip freeze` output:\r\n\r\n```\r\naiohttp==3.9.1\r\naiosignal==1.3.1\r\nattrs==23.2.0\r\nbitarray==2.9.2\r\ncertifi==2023.11.17\r\ncharset-normalizer==3.3.2\r\ncytoolz==0.12.2\r\neth-abi==4.2.1\r\neth-account==0.10.0\r\neth-hash==0.5.2\r\neth-keyfile==0.7.0\r\neth-keys==0.4.0\r\neth-rlp==1.0.0\r\neth-typing==3.5.2\r\neth-utils==2.3.1\r\nfrozenlist==1.4.1\r\nhexbytes==0.3.1\r\nidna==3.6\r\njsonschema==4.20.0\r\njsonschema-specifications==2023.12.1\r\nlru-dict==1.2.0\r\nmultidict==6.0.4\r\nparsimonious==0.9.0\r\nprotobuf==4.25.1\r\npycryptodome==3.19.1\r\npyunormalize==15.1.0\r\nreferencing==0.32.1\r\nregex==2023.12.25\r\nrequests==2.31.0\r\nrlp==4.0.0\r\nrpds-py==0.16.2\r\ntoolz==0.12.0\r\ntyping_extensions==4.9.0\r\nurllib3==2.1.0\r\nweb3==6.13.0\r\nwebsockets==12.0\r\nyarl==1.9.4\r\n```\r\n\r\n### What was wrong?\r\n\r\nIn certain situations, web3 will raise ImportErrors on python 3.12 if the `setuptools` package is not installed. _In particular, this happens inside a  fresh Python 3.12 venv._ The `setuptools` package automatically installs the `pkg_resources` package, which is used in web3 [here](https://github.com/ethereum/web3.py/blob/8f853f5841fd62187bce0c9f17be75627104ca43/web3/__init__.py#L25). This used to work fine in older Python versions. However, according to the [new changes in 3.12](https://docs.python.org/3/whatsnew/3.12.html):\r\n\r\n> gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.\r\n\r\nThis means that the pkg_resources package is no longer accessible which causes this error.\r\n\r\nAmong other things, this scenario can occur inside tox tests for projects that have the `web3` package installed and are configured to test against 3.12. This causes such tests to immediately fail because of the ImportError. The workaround, installing setuptools after the venv created, causes unnecessarily long test times, adding about 3 minutes to the run time.\r\n\r\n### How can it be fixed?\r\n\r\nGiven that web3's use of setuptools/pkg_resources is limited to just getting the version number, this should be trivial to fix. Why not open the file with built-in functions such as `open()` and parse it for the version number? I don't think that `web3` should continue to depend on setuptools.\n", "before_files": [{"content": "from eth_account import Account  # noqa: E402,\nimport pkg_resources\n\nfrom web3.main import (\n    AsyncWeb3,\n    Web3,\n)\nfrom web3.providers.async_rpc import (  # noqa: E402\n    AsyncHTTPProvider,\n)\nfrom web3.providers.eth_tester import (  # noqa: E402\n    EthereumTesterProvider,\n)\nfrom web3.providers.ipc import (  # noqa: E402\n    IPCProvider,\n)\nfrom web3.providers.rpc import (  # noqa: E402\n    HTTPProvider,\n)\nfrom web3.providers.websocket import (  # noqa: E402\n    WebsocketProvider,\n    WebsocketProviderV2,\n)\n\n__version__ = pkg_resources.get_distribution(\"web3\").version\n\n__all__ = [\n    \"__version__\",\n    \"AsyncWeb3\",\n    \"Web3\",\n    \"HTTPProvider\",\n    \"IPCProvider\",\n    \"WebsocketProvider\",\n    \"WebsocketProviderV2\",\n    \"EthereumTesterProvider\",\n    \"Account\",\n    \"AsyncHTTPProvider\",\n]\n", "path": "web3/__init__.py"}]}