Repository navigation
Fix issues #6-#9 (Cython 3 / numpy 2 build, sdist, version, Read the Docs), add CI - #10
Merged
Merged
Conversation
… source - pyproject.toml declares setuptools, Cython>=3.0.11 and numpy>=1.26 as build requirements, so isolated builds (pip, build) work. - setup.py always compiles som.pyx; the committed som.cpp, generated by Cython 0.29 and broken on Python 3.11+ (longintrepr.h), is removed and ignored. The distutils fallback, gone in Python 3.12, goes with it. - som.pyx drops the comma-separated '# distutils: sources' directive, which Cython 3 reads as one path; setup.py already lists the C++ sources. - MANIFEST.in ships som.pyx, the C++ sources and headers, never som.cpp. - __version__ in sparse_som/__init__.py is the only version, read by setup.py; bumped to 0.6.2. Fixes #6, fixes #7, fixes #8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
The docs install the package from this checkout (autodoc reads the compiled extension's docstrings) instead of the PyPI release, and take their version from its metadata. Fixes #9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
scikit-learn is optional, but its fallback passed the 3D codebook to the distance computation and failed with 'could not interpret dimensions'. The codebook is now reshaped to one row per node (a view) for both paths, which also replaces the in-place shape assignment NumPy 2.5 deprecates, and the fallback returns the same (nodes, samples) array as pairwise_distances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Python 3.12 warns about the invalid '\*' escape sequence on import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Builds the sdist (isolated build), installs it and runs the tests outside the checkout, on Linux for Python 3.9 to 3.14, numpy<2 and Windows; builds the docs as Read the Docs does. macOS is left out until OpenMP is handled there (#3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
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.
Fixes #6, #7, #8 and #9, and adds a test workflow.
Changes
python/pyproject.tomldeclaressetuptools,Cython>=3.0.11andnumpy>=1.26as build requirements.setup.pyalways compilessom.pyx. The committedsom.cpp(Cython 0.29, broken on Python 3.11+) is removed and git-ignored, and thedistutilsfallback, which Python 3.12 no longer has, goes with it.# distutils: sourcesdirective, which Cython 3 reads as one path, is dropped:setup.pyalready lists the C++ sources.MANIFEST.inshipssom.pyx, the C++ sources and the headers, never a generatedsom.cpp.__version__insparse_som/__init__.pyis the only version.setup.pyreads it, and so does Sphinx, through the installed metadata. It is bumped to 0.6.2; nothing is tagged or published..readthedocs.yaml(Ubuntu 24.04, Python 3.12) installs the package from the checkout, because autodoc needs the compiled extension, instead of the PyPI release.requirements.readthedocs.txtis reduced tosphinx.Found along the way:
activation_mapfailed when scikit-learn was not installed (it is optional), withValueError: could not interpret dimensions. The fallback received the 3D codebook. The codebook is now reshaped to one row per node, as a view, on both paths, and the fallback returns the same(nodes, samples)array aspairwise_distances. This also replaces thecodebook.shape = ...assignment that NumPy 2.5 deprecates.\**kwargsdocstrings ofSomClassifierraised aSyntaxWarningon import with Python 3.12+.CI:
.github/workflows/tests.ymlbuilds the sdist in an isolated environment, installs it and runs the tests outside the checkout. It runs on Linux, with Python 3.9 to 3.14 and withnumpy<2, and builds the docs the way Read the Docs does. Windows fails to build with MSVC, whose OpenMP 2.0 does not accept this code (#11), and macOS has the OpenMP problem of #3: both are left out until they build.The development notes in
python/README.mdare updated to match.Verification
Install: the sdist built by
uv build --sdist, which runs in an isolated environment without Cython at runtime, installs and passes all 60 tests (56 existing, 4 new) on:There are no warnings left.
Without scikit-learn:
activation_mapreturns(nodes, samples)forSomandBSom. The new test checks that this matches the sklearn result.Docs:
sphinx-buildonpython/doc/source, with the package installed, builds cleanly and documents the extension's classes.Not checked: an actual Read the Docs build. The project's default branch and version settings are on the RTD dashboard.
OpenMP on macOS (#3) is not addressed here:
-fopenmpis still passed unconditionally on POSIX.🤖 Generated with Claude Code
https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP