Skip to content

Remove gensim dependency to fix Python 3.14 build - #27

Merged
rsgoncalves merged 2 commits into
rsgoncalves:mainfrom
robin-atlasbio:remove-gensim-dependency
Jun 23, 2026
Merged

Remove gensim dependency to fix Python 3.14 build#27
rsgoncalves merged 2 commits into
rsgoncalves:mainfrom
robin-atlasbio:remove-gensim-dependency

Conversation

@robin-atlasbio

Copy link
Copy Markdown
Contributor

Summary

  • Removes the gensim dependency by inlining the two trivial regex functions that text2term actually uses from it (strip_non_alphanum and strip_multiple_whitespaces)
  • Both functions are simple re.sub calls — the gensim originals just add a to_unicode() call which is a no-op for str input on Python 3
  • This eliminates a heavy transitive dependency tree (gensim pulls in numpy, scipy, smart-open, etc.) and fixes installation on Python 3.14 where gensim fails to build due to native extension compilation issues

Changes

  • text2term/onto_utils.py: Replace from gensim.parsing import ... with two local function definitions using the same regex patterns
  • pyproject.toml: Remove gensim~=4.3.2 from dependencies

text2term only uses two functions from gensim: `strip_non_alphanum` and
`strip_multiple_whitespaces`. Both are trivial regex substitutions. Inlining
them removes the heavy gensim dependency (which pulls in numpy, scipy,
smart-open, etc. and fails to build on Python 3.14 due to native extensions).

The inlined implementations are exact equivalents of the gensim originals
(gensim's versions just call `utils.to_unicode(s)` first, which is a no-op
for str input on Python 3).
@robin-atlasbio robin-atlasbio changed the title Remove gensim dependency Remove gensim dependency to fix Python 3.14 build Feb 11, 2026
@codecov

codecov Bot commented Feb 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.80%. Comparing base (cae1a62) to head (23ce7cb).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
+ Coverage   86.74%   86.80%   +0.06%     
==========================================
  Files          16       16              
  Lines        1305     1311       +6     
  Branches      208      208              
==========================================
+ Hits         1132     1138       +6     
  Misses        118      118              
  Partials       55       55              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rsgoncalves
rsgoncalves merged commit 20e7232 into rsgoncalves:main Jun 23, 2026
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.

2 participants