Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,21 @@ clean:
# "c_lib", ".cython_version", "build" in $(SAGE_SRC) are from old sage versions
# Cleaning .so files (and .c and .cpp files associated with .pyx files) is for editable installs.
# Also cython_debug is for editable installs.
#
# NOTE: Editable installs with incremental compilation are now the default.
# - First build: Full editable install with pip install -e
# - Subsequent builds: Incremental compilation with setup.py build_ext --inplace
#
# For manual incremental compilation, use the Sage Python environment:
# cd src && ../sage --python setup.py build_ext --inplace
# This will only recompile changed Cython extensions in place.
# Or use: make sagelib (which will rebuild all of sagelib)
sagelib-clean:
@echo "Deleting Sage library build artifacts..."
if [ -d "$(SAGE_SRC)" ]; then \
(cd "$(SAGE_SRC)" && \
rm -rf c_lib .cython_version cython_debug; \
rm -rf build; find . -name '*.pyc' -o -name "*.so" | xargs rm -f; \
rm -rf build *.egg-info; find . -name '*.pyc' -o -name "*.so" | xargs rm -f; \
rm -f $$(find . -name "*.pyx" | sed 's/\(.*\)[.]pyx$$/\1.c \1.cpp/'); \
cd sage/ext/interpreters/ && rm -f *.so *.c *.h *.py* *.pxd) \
&& (cd "$(SAGE_ROOT)/build/pkgs/sagelib/src/" && rm -rf build); \
Expand Down Expand Up @@ -164,7 +173,7 @@ bdist-clean: clean
distclean: build-clean
$(MAKE) misc-clean
@echo "Deleting all remaining output from build system ..."
rm -rf local
rm -rf local *.egg-info
rm -f src/bin/sage-env-config
rm -f prefix venv

Expand Down
14 changes: 11 additions & 3 deletions build/pkgs/sagelib/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ SITEPACKAGESDIR=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["pur
# does not shadow the namespace package sage during the build.
(cd "$SITEPACKAGESDIR" && rm -f sage/__init__.py)
if [ "$SAGE_EDITABLE" = yes ]; then
# Until https://github.com/sagemath/sage/issues/34209 switches us to PEP 660 editable wheels
export SETUPTOOLS_ENABLE_FEATURES=legacy-editable
sdh_pip_editable_install .
# Check if this is an incremental build by looking for existing editable install
if python3 -c "import importlib.metadata; importlib.metadata.distribution('sagemath-standard')" 2>/dev/null && \
Copy link

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for 'sagemath-standard' distribution but this may not be the correct package name for all configurations. Consider using a more reliable method to detect existing editable installs or make the package name configurable.

Copilot uses AI. Check for mistakes.
python3 -c "import sage; import os; exit(0 if os.path.exists(os.path.join(os.path.dirname(sage.__file__), '..', 'setup.py')) else 1)" 2>/dev/null; then
Copy link

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex inline Python code for detecting setup.py makes the script hard to read and maintain. Consider extracting this logic into a separate function or using a more straightforward file existence check.

Suggested change
python3 -c "import sage; import os; exit(0 if os.path.exists(os.path.join(os.path.dirname(sage.__file__), '..', 'setup.py')) else 1)" 2>/dev/null; then
[ -f "$(python3 -c 'import sage, os; print(os.path.abspath(os.path.join(os.path.dirname(sage.__file__), "..", "setup.py")))' 2>/dev/null)" ]; then

Copilot uses AI. Check for mistakes.
echo "Detected existing editable install - performing incremental build"
# Use setup.py build_ext --inplace for incremental compilation
python3 setup.py build_ext --inplace || sdh_die "Error during incremental build"
Copy link

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using setup.py directly is discouraged in modern Python packaging. Consider using python3 -m build or pip install --no-build-isolation -e . for consistency with modern setuptools practices.

Suggested change
python3 setup.py build_ext --inplace || sdh_die "Error during incremental build"
# Use pip editable install for incremental compilation (modern practice)
sdh_pip_editable_install . || sdh_die "Error during incremental build"

Copilot uses AI. Check for mistakes.
# No need to reinstall - editable install is already in place
else
echo "Performing initial editable install"
sdh_pip_editable_install .
fi

if [ "$SAGE_WHEELS" = yes ]; then
# Additionally build a wheel (for use in other venvs)
Expand Down
3 changes: 2 additions & 1 deletion m4/pyproject_toml_metadata.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Mathematics",
]
requires-python = ">=3.9, <3.13"
requires-python = ">=3.9, <3.14"

[project.urls]
download = "https://doc.sagemath.org/html/en/installation/index.html"
Expand Down
1 change: 1 addition & 0 deletions m4/setup_cfg_metadata.m4
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Mathematics
Loading