facebook / buck

A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.
https://buck.build
Apache License 2.0
8.56k stars 1.16k forks source link

Python 3.10: third-party python modules need update (setuptools: No module named 'symbol', pex: cannot import name 'iterable' from 'collections') #2678

Closed rpuntaie closed 2 years ago

rpuntaie commented 2 years ago

I just wanted to install Buck on Archlinux and got the mentioned error. See also https://stackoverflow.com/questions/70836444/no-module-named-symbol

Buck has its own setuptools and would need to do without "symbol" to support systems with Python 3.10: https://github.com/facebook/buck/blob/0e72e40074e1731dd3c9068e5ed23ee10bcc75dd/third-party/py/setuptools/pkg_resources/__init__.py#L32

aadsm commented 2 years ago

This pr might fix it, I didn't actually tried it though, I only read the code: https://github.com/facebook/buck/pull/2680/commits/1e57b5c4ba1812807a90c7b15bcacb9e10fe9ef5

rpuntaie commented 2 years ago

It fixes "No module named 'symbol'", but then

third-party/py/pex/pex/base.py", line 6
ImportError: cannot import name 'Iterable' from 'collections'

I made the title a bit more general.

bigfootjon commented 2 years ago

I think the real solution might be to upgrade the vendored PEX dep

jc65536 commented 2 years ago

It fixes "No module named 'symbol'", but then

third-party/py/pex/pex/base.py", line 6
ImportError: cannot import name 'Iterable' from 'collections'

I made the title a bit more general.

Could be related to this issue: https://github.com/Azure/azure-cli/issues/20444#issuecomment-1009648464

bigfootjon commented 2 years ago

It fixes "No module named 'symbol'", but then

third-party/py/pex/pex/base.py", line 6
ImportError: cannot import name 'Iterable' from 'collections'

I made the title a bit more general.

Could be related to this issue: https://github.com/Azure/azure-cli/issues/20444#issuecomment-1009648464

I believe collections no longer exports Iterable in Python3.10, it is now exported from collections.abc

Ref: https://docs.python.org/3/whatsnew/3.10.html which says:

Remove deprecated aliases to Collections Abstract Base Classes from the collections module. (Contributed by Victor Stinner in bpo-37324.)

aadsm commented 2 years ago

I believe collections no longer exports Iterable in Python3.10, it is now exported from collections.abc

Exactly. I believe that's what @jc65536 was referring to in his comment, where a solution is provided by importing the Iterable from collections.abc instead.

aadsm commented 2 years ago

I think the real solution might be to upgrade the vendored PEX dep

Absolutely, is this something you're planning to work on? If yes, then I'll just cancel my PR, otherwise we can ship this one to unblock people using python 3.10.

bigfootjon commented 2 years ago

Absolutely, is this something you're planning to work on?

I unfortunately don't have a good way to build Buck manually right now in my spare time and I have higher priority things when I'm at work. I want to help fix this but I just don't have the bandwidth :(

I'm happy to review the PR though, unless someone from the Buck team is monitoring this problem.

(I do work at Meta but I don't work anywhere near Buck, I just use Buck in a hobby project)

bigfootjon commented 2 years ago

I went ahead and just patched the import collections and import symbols lines. Upgrading PEX is what should happen, but I don't have the expertise to do so.

bigfootjon commented 2 years ago

@lisroach added support, and I ported this to the OSS version. This should be available in the next weekly release