Opened 2 years ago

Closed 2 years ago

#28499 closed defect (fixed)

py3: typing should not be installed in Python 3

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-9.0
Component: packages: standard Keywords: py3
Cc: arojas, embray, fbissey, gh-timokau, infinity0, isuruf, saraedum, slelievre, Snark, thansen Merged in:
Authors: Vincent Delecroix Reviewers: Julian Rüth
Report Upstream: N/A Work issues:
Branch: 68e941e (Commits, GitHub, GitLab) Commit: 68e941e03efecc4e68c1f2bc63469066277d7f16
Dependencies: Stopgaps:

Status badges

Description (last modified by vdelecroix)

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/", line 6, in <module>
    from _pytest.assertion import rewrite
  File "/opt/sage/local/lib/python3.7/site-packages/_pytest/assertion/", line 15, in <module>
    from typing import Dict
  File "/opt/sage/local/lib/python3.7/site-packages/", line 1356, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/opt/sage/local/lib/python3.7/site-packages/", line 1004, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
FAIL (exit status: 1)

We should disable the installation of typing when Sage is built with Python 3.

Change History (11)

comment:1 Changed 2 years ago by vdelecroix

  • Description modified (diff)

comment:2 Changed 2 years ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to u/vdelecroix/28499
  • Cc embray added
  • Commit set to 68e941e03efecc4e68c1f2bc63469066277d7f16
  • Status changed from new to needs_review

New commits:

68e941e28499: do not install typing with Python 3

comment:3 Changed 2 years ago by saraedum

  • Reviewers set to Julian Rüth

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.

comment:4 Changed 2 years ago by saraedum

  • Cc slelievre added

CCing a usual suspect for testing Python 3 stuff :)

comment:5 Changed 2 years ago by saraedum

Or wait for #28041 and GitLab CI will test it automatically.

comment:6 Changed 2 years ago by vdelecroix

  • Status changed from needs_review to positive_review

Works for me on Python 3.

comment:7 Changed 2 years ago by vdelecroix

  • Keywords py3 added
  • Summary changed from typing should not be installed in Python 3 to py3: typing should not be installed in Python 3

comment:8 Changed 2 years ago by slelievre

  • Cc arojas fbissey gh-timokau infinity0 isuruf Snark thansen added

cc-ing packagers for various distros

comment:9 Changed 2 years ago by embray

There is another way. With an spkg-configure.m4, in I believe the third argument to [ 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).

comment:10 Changed 2 years ago by chapoton

  • Milestone changed from sage-8.9 to sage-9.0

moving milestone to 9.0 (after release of 8.9)

comment:11 Changed 2 years ago by vbraun

  • Branch changed from u/vdelecroix/28499 to 68e941e03efecc4e68c1f2bc63469066277d7f16
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.