Remove pkg_resources and fix numpy 2.x / RDKit 2025.09 compat#56
Open
matteoferla wants to merge 2 commits intomasterfrom
Open
Remove pkg_resources and fix numpy 2.x / RDKit 2025.09 compat#56matteoferla wants to merge 2 commits intomasterfrom
matteoferla wants to merge 2 commits intomasterfrom
Conversation
- 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
There was a problem hiding this comment.
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_resourceswithimportlib.metadata.versionandpathlib.Pathfor package metadata and resource access - Modernize
importlib.resourcesAPI from legacy methods (contents(),read_text(), etc.) to the modernfiles()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.
34fdbfc to
5dbcda2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg_resources(dropped in setuptools 80+): replaced withpathlib.Pathandimportlib.metadatainbranding.py,version.py, and the issue template_base_dataset_holder.py: legacyimportlib.resourcesAPI (contents(),read_text(),read_binary(),is_resource()) replaced with modernfiles()API — eliminates allDeprecationWarnings and ensures compatibility with Python 3.13+_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 firsttest_real_merger: round-trip SMILES throughMolFromSmilesto normalise aromaticity perception across RDKit versionsTest results
Remaining 2 errors (
test_incorrect,test_pentachromatic) are algorithmicMProVictor.place()failures likely due to RDKit 2025.09 MCS/substructure changes — unrelated to this PR.