py3: typing should not be installed in Python 3
Closed this issue · 14 comments
typing is a standard Sage package but it is also included in Python 3.7 standard library. This module is not compatible with Python > 3.5. For example it breaks pytest
File "/opt/sage/local/lib/python3.7/site-packages/_pytest/assertion/__init__.py", line 6, in <module>
from _pytest.assertion import rewrite
File "/opt/sage/local/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 15, in <module>
from typing import Dict
File "/opt/sage/local/lib/python3.7/site-packages/typing.py", line 1356, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "/opt/sage/local/lib/python3.7/site-packages/typing.py", line 1004, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
FAIL eantic_sage.py (exit status: 1)
We should disable the installation of typing when Sage is built with Python 3.
CC: @antonio-rojas @embray @kiwifb @timokau @infinity0 @isuruf @saraedum @slel @SnarkBoojum @tobihan
Component: packages: standard
Author: Vincent Delecroix
Branch/Commit: 68e941e
Reviewer: Julian Rüth
Issue created by migration from https://trac.sagemath.org/ticket/28499
Description changed:
---
+++
@@ -1 +1,16 @@
-`typing` is a standard Sage package but it is also included in Python 3.7 standard library. This module is not compatible with Python > 3.5 (for example it breaks pytest). We should disable its installation when Sage is built with Python 3.
+`typing` is a standard Sage package but it is also included in Python 3.7 standard library. This module is not compatible with Python > 3.5. For example it breaks pytest
+
+```
+ File "/opt/sage/local/lib/python3.7/site-packages/_pytest/assertion/__init__.py", line 6, in <module>
+ from _pytest.assertion import rewrite
+ File "/opt/sage/local/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 15, in <module>
+ from typing import Dict
+ File "/opt/sage/local/lib/python3.7/site-packages/typing.py", line 1356, in <module>
+ class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
+ File "/opt/sage/local/lib/python3.7/site-packages/typing.py", line 1004, in __new__
+ self._abc_registry = extra._abc_registry
+AttributeError: type object 'Callable' has no attribute '_abc_registry'
+FAIL eantic_sage.py (exit status: 1)
+```
+
+We should disable the installation of typing when Sage is built with Python 3.Author: Vincent Delecroix
Branch: u/vdelecroix/28499
Not a very elegant fix but I think that's just the limitations of SPKGs. So, this looks good to me. I cannot test it because I have no Python 3 SageMath installed. If you're confident that this works, feel free to set this to positive review.
Reviewer: Julian Rüth
CCing a usual suspect for testing Python 3 stuff :)
Works for me on Python 3.
cc-ing packagers for various distros
There is another way. With an spkg-configure.m4, in I believe the third argument to [https://github.com/sagemath/sagetrac-mirror/blob/develop/m4/sage_spkg_configure.m4 SAGE_SPKG_CONFIGURE` you can pass a check for whether the package is even required.
It's not well documented how to do this, but if you set sage_require_typing=no in this check then it won't require installation of the package (it will just be treated as a dummy package).
moving milestone to 9.0 (after release of 8.9)
Changed branch from u/vdelecroix/28499 to 68e941e