Skip to content

Commit

Permalink
Make doc building compatible with py 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Nov 24, 2024
1 parent 3d2e37d commit cb9f8ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions abipy/electrons/ebands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3931,7 +3931,7 @@ def gridplotly(self, e0="fermie", with_dos=True, with_gaps=False, max_phfreq=Non
column_widths=[2, 1]*2, horizontal_spacing=0.02, sharex=False, sharey=True)
# all sub_fig in the same row will share y

for i, (ebands, edos) in enumerate(zip(ebands_list, edos_list), strict=True):
for i, (ebands, edos) in enumerate(zip(ebands_list, edos_list, strict=True)):
# Align bands and DOS.
irow, icol = divmod(i, 2)
band_rcd = PlotlyRowColDesc(irow, icol * 2, nrows, ncols)
Expand Down Expand Up @@ -5077,7 +5077,7 @@ def gridplot(self, what="dos", spin_mode="automatic", e0="fermie",
# don't show the last ax if numeb is odd.
if numeb % ncols != 0: ax_list[-1].axis("off")

for i, ((label, edos), ax) in enumerate(zip(self.edoses_dict.items(), ax_list, strict=True)):
for i, ((label, edos), ax) in enumerate(zip(self.edoses_dict.items(), ax_list, strict=False)):
irow, icol = divmod(i, ncols)

# Here I handle spin and spin_mode.
Expand Down
13 changes: 11 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@
ABIPY_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
sys.path.insert(0, ABIPY_ROOT)

import imp
def load_mod(filepath):
"""To maintain compatibility with py <= 3.12"""
try:
import imp
return imp.load_source(filepath, filepath)
except ModuleNotFoundError:
from importlib.machinery import SourceFileLoader
return SourceFileLoader(filepath, filepath).load_module()


mod_name = os.path.join(ABIPY_ROOT, "abipy", "core", "release.py")
relmod = imp.load_source(mod_name, mod_name)
relmod = load_mod(mod_name)

on_rtd = os.environ.get('READTHEDOCS') == 'True'

Expand Down

0 comments on commit cb9f8ea

Please sign in to comment.