starkware-libs / cairo-lang

Apache License 2.0
1.34k stars 263 forks source link

Error running starknet-compile using python 3.10 #27

Open TimNooren opened 2 years ago

TimNooren commented 2 years ago

Hi,

As far as I can tell cairo-lang is not explicitly built/tested for python 3.10, but I just wanted to log this issue:

Running starknet-compile using python 3.10 yields:

Traceback (most recent call last):
  File "/usr/local/bin/starknet-compile", line 7, in <module>
    from starkware.starknet.compiler.compile import main  # noqa
  File "/usr/local/lib/python3.10/site-packages/starkware/starknet/compiler/compile.py", line 7, in <module>
    from starkware.cairo.lang.compiler.assembler import assemble
  File "/usr/local/lib/python3.10/site-packages/starkware/cairo/lang/compiler/assembler.py", line 7, in <module>
    from starkware.cairo.lang.compiler.program import CairoHint, Program
  File "/usr/local/lib/python3.10/site-packages/starkware/cairo/lang/compiler/program.py", line 25, in <module>
    from starkware.starkware_utils.marshmallow_dataclass_fields import IntAsHex
  File "/usr/local/lib/python3.10/site-packages/starkware/starkware_utils/marshmallow_dataclass_fields.py", line 6, in <module>
    from frozendict import frozendict
  File "/usr/local/lib/python3.10/site-packages/frozendict/__init__.py", line 16, in <module>
    class frozendict(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'

frozendict is pinned to version 1.2, released in 2016. In python 3.10 importing abstract base classes from collections directly has been disabled.

oberstet commented 2 years ago

the current release of fronzendict is version 2.1.3, and the mapping issue is fixed there:

(cpy310_2) (base) oberstet@intel-nuci7:~/myproject$ python -c "from frozendict import frozendict"
(cpy310_2) (base) oberstet@intel-nuci7:~/myproject$ pip show frozendict
Name: frozendict
Version: 2.1.3
Summary: A simple immutable dictionary
Home-page: https://github.com/Marco-Sulla/python-frozendict
Author: Marco Sulla
Author-email: marcosullaroma@gmail.com
License: LGPL v3
Location: /home/oberstet/cpy310_2/lib/python3.10/site-packages
Requires: 
Required-by: cairo-lang

why is it version pinned to an exact version rather than eg with an open upper version limit?

it seems, the source of the pinning is

https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/scripts/requirements-gen.txt#L6

and the script to make that into an actual requirements file is

https://github.com/starkware-libs/cairo-lang/blob/master/build.sh

antazoey commented 2 years ago

Any news on this one? I have experienced this as well.

Magicking commented 1 year ago
Hello peeps for the records about support and why it's a good reason to move towards a upper python version: Ver End of life
3.11 Ends in 4 years and 9 months (24 Oct 2027)
3.10 Ends in 3 years and 8 months (04 Oct 2026)
3.9 Ends in 2 years and 8 months (05 Oct 2025)

With this one trick of making the changes towards an upper Python version you gain few years of life, performance, patches and you make more developers and package maintainers happy!