DEV: Build System and Packaging Update#138
Merged
Merged
Conversation
The setup.py file now includes possible SuiteSparse installation directories in this order: 1. user-defined SUITESPARSE_INCLUDE_DIR/SUITESPARSE_LIBRARY_DIR 2. user's active conda environment path 3. user's homebrew path 4. default system installation paths (MacOS and Debian)
The ruff settings are chosen to closely match those of the numpy and scipy projects. This commit also removes unnecessary excludes from the black settings, because ruff excludes those directories/files by default.
71d209a to
d690595
Compare
This was referenced Jul 30, 2025
Add dev dependencies to pyproject.toml as well.
b37e64a to
1071e11
Compare
Also refer to pyproject.toml for complete author list where appropriate, and add existing authors to overview.rst. Future files should not include the license and full author list, since those are included in LICENSE.txt and pyproject.toml, respectively, but legacy files will retain that information.
Exclude source files *.pyx and *.c from the wheel file since they are not runtime dependencies (see pyproject.toml). Include them in the sdist (via MANIFEST.in) so that users can build from source if desired. Also include test files in the sdist.
Use conda to install into a clean environment in CI and check that sksparse installs correctly.
This commit makes the CI workflows much cleaner. There is now: 1. ci-dev.yml: a workflow that can be run on development branches to test code changes, 2. build-check.yml: a workflow that can be run on the "build-system" branch to test changes to the build system, 3. deploy.yml: a workflow that can be run on releases.
This commit ensures "ruff check" is run on any files to be committed, so that we don't end up with linting errors in CI, or a bunch of tiny commits fixing style errors. It does *not* run "ruff check --fix" or "ruff format", so no files will be changed unless done so explicitly by the developer. Also adds "pre-commit" as a dev dependency.
1071e11 to
1053fd8
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build System Update
This PR updates the build system to use PEP 621
and store project metadata in
pyproject.tomlinstead ofsetup.py.Changes include:
pyproject.tomlsetup.pyto improve reliabilitypkg_resourcesdependency and redundant testdirectory
Description
The project metadata and packaging have not been updated for many years.
The goal of this PR is to modernize the build system and prepare for future
enhancements, such as adding more SuiteSparse module interfaces. It does not
change the existing API or functionality of
scikit-sparse. This PRupdates the packaging and installation to have a unified source of metadata in
pyproject.toml, in preparation for the addition of more SuiteSparse moduleinterfaces like
AMD,COLAMD, etc.The
pyproject.tomlfile now contains all necessary metadata, including projectname, version, description, authors, license, dependencies, and build system
requirements.
Version Bump
The major breaking change is the removal of support for Python 3.9 and earlier,
as well as Numpy < v2.0. As noted in
changes.rst, Python 3.9 will reach itsend of life in October 2025. Numpy will end support for all v1.x versions by
September 2025. SciPy v1.14 (released June 2024) will be supported until the end
of 2026. This change ensures that
scikit-sparseremains compatible with thelatest versions of Python and Numpy, without creating undue burden on us as
maintainers to stay compatible with older versions.
I have bumped the version to
0.5.0to reflect these changes. The versionis now solely managed in
pyproject.toml.sksparse/__init__.pyhas beenupdated to read the version from
pyproject.tomlinstead of hardcoding it.Installation Changes
There is no user-visible change to the installation process, but the underlying
logic has been updated to improve reliability and flexibility.
The installation logic remains in
setup.py, but is now restructured to ensureuser setting of
SUITESPARSE_INCLUDE_DIRandSUITESPARSE_LIBRARY_DIRoverrides any other installation location. Previously, these environment
variables were placed at the end of the include list, leading to potential
issues when users had multiple installation locations for SuiteSparse.
setup.pywill now automatically detect the SuiteSparse library and compile thenecessary Cython code. It will check for the SuiteSparse library in the
following order:
SUITESPARSE_INCLUDE_DIRandSUITESPARSE_LIB_DIR(if set, these will override the default searchpaths)
/opt/homebrew/include/suitesparse)/usr/include/suitesparseon Linux, or/usr/local/include/suitesparseon macOS)This information is reflected in changes to the
README.mdandoverview.rstfiles.
Test Changes
There is one minor change to
test_cholmod.py. Themm_matrixfunctionpreviously used
pkg_resourcesto load a matrix from a file, requiring the testdata to be copied into the package directory. Since
pkg_resourcesis outdatedand not recommended for new code, the function now directly uses the path of the
test file, which is more straightforward and avoids the need for copying test
data into the package directory. This PR removes the redundant
sksparse/testsdirectory. All test files are now located in
tests/.Documentation Changes
Copyright information has been updated to reflect the new year and contributors.
Existing files retain the full license information and author list, but new
files should only include the copyright notice and a reference to the full
license information in
LICENSE.txt, as well as the author list inpyproject.toml.Switch to Ruff from Black
Both the numpy and scipy projects use
rufffor linting and formatting instead ofblack. This PR updatespyproject.tomlwith... roughly the same ruff settings as used in those projects. The CI workflow currently does not run linting/formatting, because there are a number of changes that would be made to existing code to update to at least Python v3.10. I will submit a separate PR with these style updates.CI Workflows
This PR reorganizes the GitHub Actions workflows into 3 parts:
ci_test.yml->deploy.ymlci-dev.yml: Install the development version, runpytestand build the docs.build-test.yml: Build the distribution wheel and sdist, check both for file contents, and install/test.The
deploy.ymlfile has minor updates to reflect the changes to the build system, but is otherwise unchanged.ci-dev.ymlis trigged on pull requests, or manually. Contributors can change this to run on pushes to their local fork feature branches, as necessary.build-test.ymlis triggered on pushes to thebuild-systembranch, or manually.Additional Comments
I have another PR in the works that will add an interface for
AMD, and plans toinclude
COLAMD,CAMD, andCCOLAMDinterfaces in the near future.Looking forward to your feedback and suggestions on this PR!