Skip to content

Conversation

@cxzhong
Copy link
Contributor

@cxzhong cxzhong commented Aug 17, 2025

Fix #40612 #40548, I try to add the incremental building property to the sagelib for setuptools>=79, and use pip install -e . to install sagelib. @orlitzky I have fixed the problem last time I discussed in #40548 .

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@github-actions
Copy link

github-actions bot commented Aug 17, 2025

Documentation preview for this PR (built with commit 4503938; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@cxzhong cxzhong marked this pull request as ready for review August 17, 2025 19:46
Copilot AI review requested due to automatic review settings August 17, 2025 19:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements incremental building for setuptools>=79 to improve build times for editable installs of sagelib. The change adds logic to detect existing editable installations and perform incremental compilation instead of full reinstallation on subsequent builds.

  • Adds support for Python 3.13 in project metadata
  • Implements incremental build detection and compilation for editable installs
  • Updates build system documentation and cleanup procedures

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
m4/setup_cfg_metadata.m4 Adds Python 3.13 classifier
m4/pyproject_toml_metadata.m4 Adds Python 3.13 support and updates version requirement
build/pkgs/sagelib/spkg-install.in Implements incremental build logic for editable installs
Makefile Updates cleanup procedures and adds documentation for incremental builds

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.
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 && \
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.
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
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.
@cxzhong cxzhong closed this Aug 18, 2025
@cxzhong cxzhong deleted the Incremental-building branch August 18, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use PEP660 to editable install

1 participant