diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-02 22:29:36 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-02 22:29:36 +0200 |
commit | 7ab009e55a5e28ac1c7ea327913ebb36c8c166c2 (patch) | |
tree | f3cc9aba09c05dfc4ba45dd5d31efb21621c2403 | |
parent | ea9d317d805299f146389d2ccce391b97e203559 (diff) | |
download | cython-7ab009e55a5e28ac1c7ea327913ebb36c8c166c2.tar.gz |
Hack around a distutils 3.[5678] bug on Windows for unicode module names.
https://bugs.python.org/issue39432
-rw-r--r-- | Cython/Build/Dependencies.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py index 54079869d..4674b4816 100644 --- a/Cython/Build/Dependencies.py +++ b/Cython/Build/Dependencies.py @@ -973,6 +973,9 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False, exclude_failures=exclude_failures, language=language, aliases=aliases) + + fix_windows_unicode_modules(module_list) + deps = create_dependency_tree(ctx, quiet=quiet) build_dir = getattr(options, 'build_dir', None) @@ -1128,6 +1131,36 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False, return module_list +def fix_windows_unicode_modules(module_list): + # Hack around a distutils 3.[5678] bug on Windows for unicode module names. + # https://bugs.python.org/issue39432 + if sys.platform != "win32": + return + if sys.version_info < (3, 5) or sys.version_info >= (3, 8, 2): + return + + def make_filtered_list(ignored_symbol, old_entries): + class FilteredExportSymbols(list): + # export_symbols for unicode filename cause link errors on Windows + # Cython doesn't need them (it already defines PyInit with the correct linkage) + # so use this class as a temporary fix to stop them from being generated + def __contains__(self, val): + # so distutils doesn't "helpfully" add PyInit_<name> + return val == ignored_symbol or list.__contains__(self, val) + + filtered_list = FilteredExportSymbols(old_entries) + if old_entries: + filtered_list.extend(name for name in old_entries if name != ignored_symbol) + return filtered_list + + for m in module_list: + if not m.name.isascii(): + m.export_symbols = make_filtered_list( + "PyInit_" + m.name.rsplit(".", 1)[-1], + m.export_symbols, + ) + + if os.environ.get('XML_RESULTS'): compile_result_dir = os.environ['XML_RESULTS'] def record_results(func): |