Skip to content

Commit

Permalink
Tolerate literal globs (cythonGH-5942 backport to 3.0.x)
Browse files Browse the repository at this point in the history
  • Loading branch information
eewanco committed Jan 25, 2024
1 parent b9bfa7f commit 8a52ead
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cython/Utils.py
Expand Up @@ -316,7 +316,7 @@ def find_versioned_file(directory, filename, suffix,
assert not suffix or suffix[:1] == '.'
path_prefix = os.path.join(directory, filename)

matching_files = glob.glob(path_prefix + ".cython-*" + suffix)
matching_files = glob.glob(''.join([ '['+c+']' if c in '[]*?' else c for c in path_prefix]) + ".cython-*" + suffix)
path = path_prefix + suffix
if not os.path.exists(path):
path = None
Expand Down
27 changes: 27 additions & 0 deletions tests/run/sys_path_globbed.srctree
@@ -0,0 +1,27 @@
# tag: gh5942

PYTHON setup.py build_ext --inplace
PYTHON -c "from tglob import mytest; mytest()"

######## tglob.pyx ########
def mytest():
assert True

######## setup.py ########
import sys

from Cython.Build.Dependencies import cythonize
from distutils.core import setup, Extension

sys.path.append("[Hello-World]*?")

try:
from __builtin__ import reload
except ImportError:
from importlib import reload
reload(sys) # Magic

setup(
ext_modules=cythonize(["tglob.pyx"], language_level="3"),
)

0 comments on commit 8a52ead

Please sign in to comment.