Skip to content

Add Python 3.13 support - #40

Open
sidnarayanan wants to merge 1 commit into
MolecularAI:mainfrom
EdisonScientific:modern-python
Open

Add Python 3.13 support#40
sidnarayanan wants to merge 1 commit into
MolecularAI:mainfrom
EdisonScientific:modern-python

Conversation

@sidnarayanan

Copy link
Copy Markdown

Hi, I was trying to use aizynthfinder in a Python 3.13 environment and ran into the version pin. I can open a follow-up PR to that repo if this one is accepted and released.

The main changes were:

  • Conditionally pin numpy and rdkit if python>3.12
  • Deal with a numpy 2 data type issue and a function signature change in rdkit 2024+
  • Some test case targets changed in rdkit 2024+

* Bump python upper bound to <3.14 in pyproject.toml and env-dev.yml.
* Use per-Python-version pins for numpy and rdkit so 3.9-3.12 users
  keep numpy<2 / rdkit ^2023.9.1 (no degradation), while 3.13 picks
  up numpy>=2.1 / rdkit>=2024.9.1 (the first versions with cp313
  wheels).
* SCScore._make_fingerprint: use DataStructs.ConvertToNumpyArray
  instead of np.array(bitvect, dtype=float). The latter segfaults
  under rdkit>=2026 + numpy>=2.
* TemplateMolecule.atom_properties: swallow Boost.Python.ArgumentError
  from RDKit getters whose signatures changed in rdkit>=2024
  (e.g. Atom.GetValence now requires a ValenceType arg).
* Mark a handful of template/hash tests xfail on Python 3.13 because
  rdkit>=2024 produces different fingerprint hashes / template SMARTS
  for those inputs.

Tests: 287 pass / 0 fail on Python 3.12 (baseline preserved);
282 pass / 6 xfail / 3 xpass on Python 3.13.

@CKannas CKannas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for your work to make reaction-utils to work for Python 3.13 and newer.

There are some points we should address to make this working for all supported combinations.

Comment thread pyproject.toml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To correctly support Python 3.9 to 3.13, the following version restrictions must be placed:

  • RDKit:
    • For Python >=3.9,<3.13 it should be >=2023.9.1,<2024.9.1.
    • For Python >=3.13,<3.14 it should be >=2024.9.1, because from 2024.9.1 Python 3.13 is supported (2025.9.1 and newer support 3.14 )
  • SciPy:
    • For Python >=3.9,<3.13 it should be >=1.11.4,<1.14.1.
    • For Python >=3.13,<3.14 it should be >=1.14.1.
  • NumPy:
    • For Python >=3.9,<3.13 it should be >=1.0.0,<2.0.0.
    • For Python >=3.13,<3.14 it should be >=2.0.0, RDKit >= 2024.9.1 supports NumPy 2.0.
  • ONNXRuntime:
    • For Python >=3.9,<3.12 it should be <1.17.0.
    • For Python >=3.12 it should be >=1.17.0.

Comment thread rxnutils/chem/template.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

GetValence was introduced in RDKit 2025.03.1.

Comment thread tests/test_template.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fingerprint changes are valid from RDKit 2025.9.2.
The valence error for Al is valid from RDKit 2024.9.1.
The chirality of the two molecules is the same only from RDKit 2024.9.3.

Comment thread env-dev.yml
dependencies:
- python>=3.9,<3.13
- python>=3.9,<3.14
- poetry>=1.2.0,<2.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it will be best to pin poetry to 2.4.0.

Suggested change
- poetry>=1.2.0,<2.0
- poetry=2.4.0

@CKannas CKannas added the enhancement New feature or request label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants