Skip to content

Replace deprecated distutils usage (removed in Python 3.12)#2550

Merged
k9ert merged 2 commits intocryptoadvance:masterfrom
abhishek-8081:fix/remove-deprecated-distutils
Apr 2, 2026
Merged

Replace deprecated distutils usage (removed in Python 3.12)#2550
k9ert merged 2 commits intocryptoadvance:masterfrom
abhishek-8081:fix/remove-deprecated-distutils

Conversation

@abhishek-8081
Copy link
Copy Markdown
Contributor

Fixes #2549

distutils was deprecated in Python 3.10 and fully removed in Python 3.12. This PR removes both usages from the codebase:

Changes

  1. server.py: Removed from distutils.core import setup — this import was not used anywhere in the file.

  2. util/common.py: Replaced from distutils.util import strtobool with an inline implementation inside the existing str2bool() function. The behavior is exactly the same — it accepts the same true values (y, yes, t, true, on, 1) and false values (n, no, f, false, off, 0) and raises ValueError for anything else.

Without this fix, Specter will crash on startup with ModuleNotFoundError: No module named 'distutils' if run on Python 3.12+.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 13, 2026

Deploy Preview for specter-desktop-docs canceled.

Name Link
🔨 Latest commit 7d5ee98
🔍 Latest deploy log https://app.netlify.com/projects/specter-desktop-docs/deploys/69ce66fb20c03400089b6c2a

Copy link
Copy Markdown
Contributor

@al-munazzim al-munazzim left a comment

Choose a reason for hiding this comment

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

Clean Python 3.12+ compatibility fix. Replaces distutils.strtobool (removed in 3.12) with equivalent inline logic in str2bool(). The accepted values match the original strtobool behavior exactly.

LGTM ✅

@k9ert k9ert force-pushed the fix/remove-deprecated-distutils branch from 85a5b2c to c3defba Compare March 20, 2026 15:55
@k9ert
Copy link
Copy Markdown
Contributor

k9ert commented Mar 20, 2026

@abhishek-8081 Black is failing! Can you run black?!

abhishek-8081 and others added 2 commits April 2, 2026 14:54
- server.py: removed unused 'from distutils.core import setup' import
- util/common.py: replaced distutils.util.strtobool with an inline
  implementation in str2bool() that has the same behavior

Fixes cryptoadvance#2549
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@k9ert k9ert force-pushed the fix/remove-deprecated-distutils branch from 5e4f6c6 to 7d5ee98 Compare April 2, 2026 12:54
Copy link
Copy Markdown
Contributor

@al-munazzim al-munazzim left a comment

Choose a reason for hiding this comment

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

Clean fix — inlined strtobool logic matches the original distutils.util.strtobool behavior exactly, and the unused server.py import removal is correct. Black and unit tests passing. LGTM. 👍

@k9ert k9ert merged commit b6c230d into cryptoadvance:master Apr 2, 2026
9 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.

Code uses distutils which is removed in Python 3.12+

3 participants