|
1 | | -#!/usr/bin/env sage-python |
| 1 | +#!/usr/bin/env python |
2 | 2 |
|
3 | | -# This script is a deprecated wrapper around the "cython" program. |
4 | | -# It is deprecated since Issue #27041 (Sage 8.7) because one should |
| 3 | +# This script is a wrapper around the "cython" program. |
| 4 | +# It was deprecated in Issue #27041 (Sage 8.7) because one should |
5 | 5 | # simply use "cython" directly. We display deprecation messages whenever |
6 | 6 | # "sage-cython" does something different from plain "cython". |
7 | 7 | # |
8 | 8 | # A stronger deprecation warning was added in #29923 (Sage 9.2). |
| 9 | +# |
| 10 | +# In Sage 10.3, the deprecated functionality is removed permanently. |
| 11 | +# However, the script is un-deprecated and re-purposed as a temporary workaround |
| 12 | +# for defects in Cython 3.0.x support for PEP 420 implicit namespace packages, |
| 13 | +# see https://github.com/sagemath/sage/pull/36228 |
| 14 | +# |
| 15 | +# This script can be used as a replacement for "cython". |
| 16 | +# For example, to have meson use it, set the environment variable |
| 17 | +# CYTHON to sage-cython./ |
| 18 | +# https://github.com/mesonbuild/meson/blob/e4bbc630b67ef97ad842badd00855e64cff12e13/mesonbuild/envconfig.py#L91 |
9 | 19 |
|
10 | | -import os |
11 | | -import sys |
12 | | -args = sys.argv[1:] |
13 | | - |
14 | | -sys.stderr.write("WARNING: the script sage-cython is deprecated; use cython instead.\n") |
15 | | - |
16 | | -from sage.env import SAGE_SRC |
17 | | - |
18 | | -# args can have length 0, in case we're printing a usage message (see trac 12207) |
19 | | -pyx_file = os.path.abspath(args[-1]) if len(args) else None |
20 | | -include_sage_flags = False |
21 | | - |
22 | | -if pyx_file and pyx_file.startswith(SAGE_SRC): |
23 | | - sys.stderr.write("WARNING: in the future, sage --cython will not add special flags for files in Sage sources.\n") |
24 | | - include_sage_flags = True |
25 | | - |
26 | | -if '-sage' in args: |
27 | | - sys.stderr.write("WARNING: sage --cython -sage is deprecated.\n") |
28 | | - include_sage_flags = True |
29 | | - args.remove('-sage') |
30 | | -elif '-no-sage' in args: |
31 | | - sys.stderr.write("WARNING: sage --cython -no-sage is deprecated, remove the -no-sage flag.\n") |
32 | | - include_sage_flags = False |
33 | | - args.remove('-no-sage') |
| 20 | +from sage.misc.package_dir import cython_namespace_package_support |
34 | 21 |
|
35 | | -if include_sage_flags: |
36 | | - args = ['--embed-positions', '-I%s' % SAGE_SRC] + args |
| 22 | +# console scripts declared in https://github.com/cython/cython/blob/master/setup.py#L68 |
| 23 | +from Cython.Compiler.Main import setuptools_main |
37 | 24 |
|
38 | | -args.insert(0, 'sage-cython') |
39 | | -os.execlp('cython', *args) |
| 25 | +with cython_namespace_package_support(): |
| 26 | + setuptools_main() |
0 commit comments