Skip to content

Commit

Permalink
sagemathgh-37290: sagemath-standard: don't require Cython to create s…
Browse files Browse the repository at this point in the history
…dist

The implementation of sage.misc.package_dir.read_distributions uses the
function `Cython.Utils.open_source_file()` to open a file instead of
`io.open()`. This function was introduced in sagemath#29701 (b582789).

The only difference between `open_source_file()` and `io.open()` is that
the former will open the file as binary to check the encoding. But all
our files should be utf-8 so we don't need this trick.

In case I’m mistaken and there is a reason this trick is really
necessary (@mkoeppe?) it seems better to include a version of
open_source_file(), for two main reasons: (a) we don’t pull the whole of
Cython just for a trivial function; (b) changes in Cython don’t affect
sagemath (this is not a documented function of Cython, afaict)

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.

URL: sagemath#37290
Reported by: Gonzalo Tornaría
Reviewer(s): Gonzalo Tornaría, Matthias Köppe
  • Loading branch information
Release Manager committed Feb 11, 2024
2 parents f71381c + 487a02f commit 81a374d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=84c8bfc8a84399d50eac5f0e75672da0e36216ae
md5=1171b0a7cd69002c426fb7b48e9026e4
cksum=2998629640
sha1=6517328415e972b571db0ef97c780ae45bb90745
md5=671ce9d8afcf9ad5faa6a918d7ab2829
cksum=2336342933
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128d437fcc7f3917b314662fdee34aeaab968b67
8dd853eddb146b36c5ce10362ac9b4ca5faf622b
3 changes: 1 addition & 2 deletions src/sage/misc/package_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def read_distribution(src_file):
sage: read_distribution(os.path.join(SAGE_SRC, 'sage', 'graphs', 'graph_decompositions', 'modular_decomposition.py'))
''
"""
from Cython.Utils import open_source_file
with open_source_file(src_file, error_handling='ignore') as fh:
with open(src_file, encoding='utf-8', errors='ignore') as fh:
for line in fh:
# Adapted from Cython's Build/Dependencies.py
line = line.lstrip()
Expand Down

0 comments on commit 81a374d

Please sign in to comment.