Skip to content

fix(build): replace removed SourceFileLoader.load_module() in setup.py for python 3.15 - #83

Merged
bogdanp05 merged 1 commit into
valkey-io:mainfrom
Kumzy:fix/python-3.15-load-module
Aug 31, 2026
Merged

bogdanp05 merged 1 commit into
valkey-io:mainfrom
Kumzy:fix/python-3.15-load-module

Conversation

@Kumzy

@Kumzy Kumzy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Hello,

Python 3.15 will remove importlib's load_module(), deprecated since 3.4, so every build from source failed before compilation started with:

AttributeError: 'SourceFileLoader' object has no attribute 'load_module'

I tested it with the rc1 of python 3.15

Documentation about it there: https://docs.python.org/3/deprecations/pending-removal-in-3.15.html

I did not add the 3.15 in pyproject.toml or in the CI workflows as the 3.15 version is still in RC

Copilot AI lite review requested due to automatic review settings August 31, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change correctly replaces a removed/deprecated importlib API with the supported module spec loading approach and is limited in scope.

Pull request overview

Updates the source build process to remain compatible with Python 3.15 by replacing the deprecated/removed importlib.machinery.SourceFileLoader.load_module() usage in setup.py when reading the package version.

Changes:

  • Replace SourceFileLoader(...).load_module() with importlib.util.spec_from_file_location() + module_from_spec() + exec_module().
  • Adjust imports accordingly (import importlib.util instead of import importlib).
File summaries
File Description
setup.py Modernizes the version-loading logic to avoid load_module() removal in Python 3.15.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bogdanp05

Copy link
Copy Markdown
Collaborator

Thanks for the patch! Could you sign off the commit? I'll approve the workflows after

…y for upcoming python 3.15

Signed-off-by: Julien <courtes.julien@gmail.com>
@Kumzy
Kumzy force-pushed the fix/python-3.15-load-module branch from 8827d97 to 0fbf727 Compare August 31, 2026 10:27
@bogdanp05
bogdanp05 merged commit 9299b03 into valkey-io:main Aug 31, 2026
34 checks passed
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.

3 participants