Skip to content

Commit

Permalink
sage.misc.package_dir.cython_namespace_package_support: Do not patch …
Browse files Browse the repository at this point in the history
…Cython 3
  • Loading branch information
Matthias Koeppe committed Oct 30, 2023
1 parent 07a2afd commit cf1c6e6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sage/misc/package_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,19 @@ def cython_namespace_package_support():
See https://github.com/cython/cython/issues/2918#issuecomment-991799049
"""
import Cython.Build.Dependencies
import Cython.Build.Cythonize
import Cython.Utils
orig_is_package_dir = Cython.Utils.is_package_dir
Cython.Utils.is_package_dir = Cython.Build.Cythonize.is_package_dir = Cython.Build.Dependencies.is_package_dir = Cython.Utils.cached_function(is_package_or_sage_namespace_package_dir)
try:
from Cython import __version__
if __version__[0] >= '3':
yield
finally:
Cython.Utils.is_package_dir = Cython.Build.Cythonize.is_package_dir = Cython.Build.Dependencies.is_package_dir = orig_is_package_dir
else:
import Cython.Build.Dependencies
import Cython.Build.Cythonize
import Cython.Utils
orig_is_package_dir = Cython.Utils.is_package_dir
Cython.Utils.is_package_dir = Cython.Build.Cythonize.is_package_dir = Cython.Build.Dependencies.is_package_dir = Cython.Utils.cached_function(is_package_or_sage_namespace_package_dir)
try:
yield
finally:
Cython.Utils.is_package_dir = Cython.Build.Cythonize.is_package_dir = Cython.Build.Dependencies.is_package_dir = orig_is_package_dir


def walk_packages(path=None, prefix='', onerror=None):
Expand Down

0 comments on commit cf1c6e6

Please sign in to comment.