Declare setuptools dependency for pymorphy2's pkg_resources import by webzuweb · Pull Request #152 · natasha/natasha · GitHub
Skip to content

Declare setuptools dependency for pymorphy2's pkg_resources import - #152

Merged
kuk merged 1 commit into
natasha:masterfrom
webzuweb:fix/pkg-resources-dependency
Sep 27, 2026
Merged

kuk merged 1 commit into
natasha:masterfrom
webzuweb:fix/pkg-resources-dependency

Conversation

@webzuweb

Copy link
Copy Markdown
Contributor

Description

pymorphy2 discovers its dictionaries via pkg_resources entry points (pymorphy2/analyzer.py: _iter_entry_points), but pymorphy2 does not declare setuptools as a dependency. On installations without setuptools this raises:

ModuleNotFoundError: No module named 'pkg_resources'

when natasha constructs a MorphVocab (which calls _lang_dict_paths). pkg_resources ships with setuptools.

Fix

Declare setuptools as a runtime dependency in install_requires, so the transitive pymorphy2 → pkg_resources import keeps working regardless of the environment.

Tests

Added tests/test_dependencies.py:

  • test_pkg_resources_available — asserts pkg_resources is importable.
  • test_pymorphy2_entry_point_discovery — exercises the exact entry-point path that imports pkg_resources.

Closes #146.

…t working

pymorphy2 discovers dictionaries via pkg_resources entry points, but it
does not declare setuptools as a dependency. On installations without
setuptools this raises 'ModuleNotFoundError: No module named pkg_resources'
when natasha constructs a MorphVocab. Declare setuptools as a runtime
dependency and add regression tests.

Closes natasha#146.
@kuk
kuk merged commit afae1e2 into natasha:master Sep 27, 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.

ModuleNotFoundError: No module named 'pkg_resources'

2 participants