eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.65k stars 551 forks source link

Poetry support for Python 3.11 with brownie #1702

Closed 0xprofessooor closed 9 months ago

0xprofessooor commented 1 year ago

Environment information

What was wrong?

I am using poetry for my project dependency management. I am using brownie and want to allow the use of Python 3.11. See the following pyproject.toml file snippet:

[tool.poetry.dependencies]
python = ">=3.8,<4"
eth-brownie = "^1.19.3"

However, when I run poetry install or poetry update, I get the following error:

Updating dependencies
Resolving dependencies... (6.0s)

The current project's Python requirement (>=3.8,<4) is not compatible with some of the required packages Python requirement:
  - vyper requires Python >=3.7,<3.11, so it will not be satisfied for Python >=3.11,<4

Because no versions of eth-brownie match >1.19.3,<2.0.0
 and eth-brownie (1.19.3) depends on vyper (0.3.7), eth-brownie (>=1.19.3,<2.0.0) requires vyper (0.3.7).
So, because vyper (0.3.7) requires Python >=3.7,<3.11
 and dojo-compass depends on eth-brownie (^1.19.3), version solving failed.

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For vyper, a possible solution would be to set the `python` property to ">=3.8,<3.11"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

However, eth-brownie==1.19.3 should be compatible with Python 3.11 as of #1655.

How can it be fixed?

I believe this can be fixed by relaxing some of the strict dependencies specified in requirements.txt, which don't necessarily reflect the dependencies specified in the other requirements files. In this case, brownie should also work with vyper=^0.3.7 rather than vyper==0.3.7 (versions 0.3.8 onwards support Python 3.11).

This also relates to #1701 where installation on Python 3.10 fails because the pyyaml requirement is pinned to v5.4.1, when brownie should be able to support v6 too.