materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.52k stars 864 forks source link

Python 3.9 support #1983

Closed sheerluck closed 4 years ago

sheerluck commented 4 years ago

Describe the bug pymatgen fails to build with Python 3.9.0

pymatgen/util/coord_cython.c:22836:25: error: «PyTypeObject» {aka «struct _typeobject»} has no member named «tp_print»
22836 |   __pyx_type___pyx_array.tp_print = 0;

To Reproduce Steps to reproduce the behavior:

  1. build with Python 3.9.0
  2. See error

Desktop (please complete the following information):

shyuep commented 4 years ago

This is related to the fact that numpy and cython does not exist in Python 3.9 yet. See https://github.com/pandas-dev/pandas/issues/32045 . Just keep pymatgen to python3.7 and 3.8 for now.

mkhorton commented 4 years ago

FYI for this, it looks like tp_print has been removed in Python 3.9, since it hasn't been used for since Python 3.0. I see that the coord_cython.c committed in the repo was last built 2 years ago, it's possible just re-building it with any newer Cython might fix it.

shyuep commented 4 years ago

I recompiled it. Not sure if it will fix it.

mkhorton commented 4 years ago

Thanks, I'm testing now. Looks like we might have the same issue in linear_assignment.c (presumably neighbors.c too)

shyuep commented 4 years ago

Ok, I rebuilt those. Perhaps we should add some code in tasks.py to regenerate those C files prior to each release using the latest cython?

mkhorton commented 4 years ago

Ok, pymatgen seems to build and work fine for me now.

Python 3.9 support in general is still spotty for now though, neither numpy, pandas or matplotlib have pre-built wheels available yet.

Perhaps we should add some code in tasks.py to regenerate those C files prior to each release using the latest cython?

Probably not a bad idea. I'm not that familiar with Cython. It seems like these changes are quite rare.