まずはここから SageMath-10.8_arm64.dmg をダウンロードしてセットアップ。
% sage --help SageMath version 10.8, Release Date: 2025-12-18 Running Sage: file.[sage|py|spyx] -- run given .sage, .py or .spyx file ... /var/tmp/sage-10.8-current/venv/bin/sage: line 197: /Applications/SageMath-10-8.app/Contents/Frameworks/Sage.framework/Versions/10.8/build/bin/sage-site: No such file or directory
なんか怒ってそう。
% sage ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 10.8, Release Date: 2025-12-18 │ │ Using Python 3.13.7. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ (!) we are using libedit readline sage: from Crypto.Util.number import long_to_bytes --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from Crypto.Util.number import long_to_bytes ModuleNotFoundError: No module named 'Crypto' sage:
using libedit readline の警告に関しては、SageMath とは関係なく macOS の Python 側で GNU readline を使ってくれずにターミナルがめちゃくちゃにされる問題が以前起きたので自前の ~/.pythonrc.py でチェックしているもの。
できておきたいこと:
sageからpycryptodomeなどの基本的な CTF 用のモジュールを使えるsage --pip installを使えばよさそう
- emacs で *.sage を編集するときに syntax highlighting と auto-format が効く
R.<x>みたいなのがblackにはきつい
最低限これだけで一旦えびちゃん的には事足りる。
if [ -d "$SAGE_ROOT" ]; then exec "$SAGE_ROOT/build/bin/sage-site" "-h" fi
たぶん SYMLINK=/var/tmp/sage-$VERSION-current (/usr/local/bin/sage) や export SAGE_ROOT="${SAGE_SYMLINK}" で定義されているの経由?
% sage --pip --help Usage: /var/tmp/sage-10.8-current/local/bin/python3 -m pip <command> [options] ...
% sage --pip install pycryptodome Collecting pycryptodome Using cached pycryptodome-3.23.0-cp37-abi3-macosx_10_9_universal2.whl.metadata (3.4 kB) Using cached pycryptodome-3.23.0-cp37-abi3-macosx_10_9_universal2.whl (2.5 MB) Installing collected packages: pycryptodome Successfully installed pycryptodome-3.23.0
じー。sage/build/README.txt には bin: Various scripts needed at build time. Not installed. と書いてありますが??
自前でビルドしてみようかな。
% git clone git@github.com:sagemath/sage.git % cd sage % EXPORT SAGE_ROOT=~/sage/sage % make configure % ./configure % make
make[4]: *** [numpy-SAGE_VENV-no-deps] Error 1 make[3]: *** [/Users/rsk0315/git/sagemath/sage/local/var/lib/sage/venv-python3.14/var/lib/sage/i make[2]: *** [all-start] Error 2 *************************************************************** Error building Sage. The following package(s) may have failed to build (not necessarily during this run of 'make all-start'): * package: numpy-2.3.2 last build time: Feb 22 16:01 log file: /Users/rsk0315/git/sagemath/sage/logs/pkgs/numpy-2.3.2.log It is safe to delete any log files and build directories, but they contain information that is helpful for debugging build problems. WARNING: If you now run 'make' again, the build directory of the same version of the package will, by default, be deleted. Set the environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this. real 65m40.114s user 38m56.325s sys 10m16.381s make[1]: *** [all-start] Error 1 make: *** [all] Error 2
なんかどうでもよくなったので投げ出します。さようなら。
フォーマットをかけたいときだけ R.<x> = ... の行をコメントアウトするみたいなことをして迂回することにします。
環境構築が成功しなかった場合でも「こういうところでうまくいかなくて投げ出した」とかを書いておくと、後々「あ〜」となれるかなと思って残しておきます。 最低限のインストールはできましたが、なかよくはできなかったので失敗です。