Skip to content

Remove pkg_resources and fix numpy 2.x / RDKit 2025.09 compat#56

Open
matteoferla wants to merge 2 commits intomasterfrom
pkg_resources-removal
Open

Remove pkg_resources and fix numpy 2.x / RDKit 2025.09 compat#56
matteoferla wants to merge 2 commits intomasterfrom
pkg_resources-removal

Conversation

@matteoferla
Copy link
Owner

Summary

  • Remove pkg_resources (dropped in setuptools 80+): replaced with pathlib.Path and importlib.metadata in branding.py, version.py, and the issue template
  • Modernise _base_dataset_holder.py: legacy importlib.resources API (contents(), read_text(), read_binary(), is_resource()) replaced with modern files() API — eliminates all DeprecationWarnings and ensures compatibility with Python 3.13+
  • Fix numpy 2.x crash in _collapse_ring.py:1102: int(np.where(scores == d)[0]) fails when multiple bonds tie for max score; now takes [0][0] to pick the first
  • Fix test_real_merger: round-trip SMILES through MolFromSmiles to normalise aromaticity perception across RDKit versions

Test results

  • Before: 38 pass, 1 fail, 4 errors
  • After: 41 pass, 0 fail, 2 errors

Remaining 2 errors (test_incorrect, test_pentachromatic) are algorithmic MProVictor.place() failures likely due to RDKit 2025.09 MCS/substructure changes — unrelated to this PR.

- Replace `pkg_resources` with `pathlib.Path` (branding.py) and
  `importlib.metadata` (version.py) — setuptools 80+ dropped it
- Modernise `_base_dataset_holder.py` from legacy `importlib.resources`
  API to `files()` API, eliminating DeprecationWarnings
- Fix `_collapse_ring.py` numpy 2.x crash: `int(np.where(...)[0])` fails
  when multiple indices match; use `[0][0]` to pick the first
- Fix `test_real_merger` SMILES assertion: round-trip through
  MolFromSmiles to normalise aromaticity perception across RDKit versions
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the codebase's dependency management and resource access patterns to ensure compatibility with Python 3.13+, setuptools 80+, numpy 2.x, and RDKit 2025.09. The changes eliminate deprecation warnings and fix crashes caused by API changes in these newer versions.

Changes:

  • Replace deprecated pkg_resources with importlib.metadata.version and pathlib.Path for package metadata and resource access
  • Modernize importlib.resources API from legacy methods (contents(), read_text(), etc.) to the modern files() API
  • Fix numpy 2.x crash when multiple bonds have equal scores by properly indexing the first match
  • Normalize RDKit aromaticity perception differences across versions in test assertions

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
fragmenstein/version.py Replaced pkg_resources.get_distribution() with importlib.metadata.version() for package version retrieval
fragmenstein/branding.py Replaced pkg_resources.resource_string() with pathlib.Path for reading JSON resource file
fragmenstein/demo/_base_dataset_holder.py Modernized from legacy importlib.resources API to files() API for Python 3.13+ compatibility
fragmenstein/monster/_collapse_ring.py Fixed numpy 2.x crash by taking first element when multiple bonds tie for max score
tests/monster_combine.py Added SMILES round-trip normalization to handle RDKit version differences in aromaticity perception
.github/ISSUE_TEMPLATE/custom.md Updated issue template to use importlib.metadata instead of pkg_resources

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matteoferla matteoferla force-pushed the pkg_resources-removal branch from 34fdbfc to 5dbcda2 Compare February 23, 2026 22:28
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