Skip to content

Commit 1d21aa2

Browse files
author
Matthias Koeppe
committed
src/bin/sage-cython: Repurpose as PEP 420 fixer, ship with sagemath-environment
1 parent e5f42fa commit 1d21aa2

2 files changed

Lines changed: 21 additions & 31 deletions

File tree

pkgs/sagemath-environment/pyproject.toml.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ script-files = [
5050
"bin/sage-version.sh",
5151
# Auxiliary script for invoking Python in the Sage environment
5252
"bin/sage-python",
53+
# The following is freshly un-deprecated as a temporary workaround
54+
# for defects in Cython 3.0.x support for PEP 420 implicit namespace packages
55+
"bin/sage-cython",
5356
# Not included:
5457
# - bin/sage-env-config -- installed by sage_conf
5558
# - bin/sage-env-config.in -- not to be installed

src/bin/sage-cython

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
1-
#!/usr/bin/env sage-python
1+
#!/usr/bin/env python
22

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
55
# simply use "cython" directly. We display deprecation messages whenever
66
# "sage-cython" does something different from plain "cython".
77
#
88
# 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
919

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
3421

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
3724

38-
args.insert(0, 'sage-cython')
39-
os.execlp('cython', *args)
25+
with cython_namespace_package_support():
26+
setuptools_main()

0 commit comments

Comments
 (0)