Skip to content

Commit

Permalink
Merge branch 'master' into fix-python3.12-build
Browse files Browse the repository at this point in the history
  • Loading branch information
gmloose committed Mar 8, 2024
2 parents d359f8f + 6acc665 commit 9b0d480
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
20 changes: 13 additions & 7 deletions bdsf/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,11 @@ def read_image_from_file(filename, img, indir, quiet=False):
import os
import numpy as N
from copy import deepcopy as cp
from distutils.version import StrictVersion
import warnings
try:
from packaging.version import Version
except ImportError:
from distutils.version import StrictVersion as Version

mylog = mylogger.logging.getLogger("PyBDSM."+img.log+"Readfile")
if indir is None or indir == './':
Expand All @@ -1129,10 +1132,10 @@ def read_image_from_file(filename, img, indir, quiet=False):
use_sections = True
except ImportError as err:
import pyfits
if StrictVersion(pyfits.__version__) < StrictVersion('2.2'):
if Version(pyfits.__version__) < Version('2.2'):
old_pyfits = True
use_sections = False
elif StrictVersion(pyfits.__version__) < StrictVersion('2.4'):
elif Version(pyfits.__version__) < Version('2.4'):
old_pyfits = False
use_sections = False
else:
Expand Down Expand Up @@ -1163,10 +1166,10 @@ def read_image_from_file(filename, img, indir, quiet=False):
use_sections = True
except ImportError as err:
import pyfits
if StrictVersion(pyfits.__version__) < StrictVersion('2.2'):
if Version(pyfits.__version__) < Version('2.2'):
old_pyfits = True
use_sections = False
elif StrictVersion(pyfits.__version__) < StrictVersion('2.4'):
elif Version(pyfits.__version__) < Version('2.4'):
old_pyfits = False
use_sections = False
else:
Expand Down Expand Up @@ -1517,7 +1520,10 @@ def write_image_to_file(use, filename, image, img, outdir=None,
def make_fits_image(imagedata, wcsobj, beam, freq, equinox, telescope, xmin=0, ymin=0,
is_mask=False, shape=None):
"""Makes a simple FITS hdulist appropriate for single-channel images"""
from distutils.version import StrictVersion
try:
from packaging.version import Version
except ImportError:
from distutils.version import StrictVersion as Version
try:
from astropy.io import fits as pyfits
use_header_update = False
Expand All @@ -1527,7 +1533,7 @@ def make_fits_image(imagedata, wcsobj, beam, freq, equinox, telescope, xmin=0, y
# Due to changes in the way pyfits handles headers from version 3.1 on,
# we need to check for older versions and change the setting of header
# keywords accordingly.
if StrictVersion(pyfits.__version__) < StrictVersion('3.1'):
if Version(pyfits.__version__) < Version('3.1'):
use_header_update = True
else:
use_header_update = False
Expand Down
7 changes: 5 additions & 2 deletions bdsf/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,17 @@ def write_fits_list(img, filename=None, sort_by='index', objtype='gaul',
""" Write as FITS binary table.
"""
from . import mylogger
from distutils.version import StrictVersion
try:
from packaging.version import Version
except ImportError:
from distutils.version import StrictVersion as Version
try:
from astropy.io import fits as pyfits
use_header_update = False
use_from_columns = True
except ImportError:
import pyfits
if StrictVersion(pyfits.__version__) < StrictVersion('3.1'):
if Version(pyfits.__version__) < Version('3.1'):
use_header_update = True
use_from_columns = False
else:
Expand Down
7 changes: 5 additions & 2 deletions bdsf/psf_vary.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ def __call__(self, img):
from astropy.io import fits as pyfits
old_pyfits = False
except ImportError as err:
from distutils.version import StrictVersion
try:
from packaging.version import Version
except ImportError:
from distutils.version import StrictVersion as Version
import pyfits
if StrictVersion(pyfits.__version__) < StrictVersion('2.2'):
if Version(pyfits.__version__) < Version('2.2'):
old_pyfits = True
else:
old_pyfits = False
Expand Down
7 changes: 5 additions & 2 deletions bdsf/pybdsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,12 @@ def main():
# greater is in common use.
try:
# IPython >= 0.11
from distutils.version import LooseVersion
try:
from packaging.version import Version
except ImportError:
from distutils.version import LooseVersion as Version
from IPython import __version__ as ipython_version
if LooseVersion(ipython_version) < LooseVersion('1.0.0'):
if Version(ipython_version) < Version('1.0.0'):
from IPython.frontend.terminal.embed import InteractiveShellEmbed
else:
from IPython.terminal.embed import InteractiveShellEmbed
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
'Topic :: Scientific/Engineering :: Astronomy'
],
extras_require={
'ishell': ['ipython<8.11', 'matplotlib']
'ishell': [
'ipython!=8.11.*,!=8.12.*,!=8.13.*,!=8.14.*,!=8.15.*',
'matplotlib',
],
},
install_requires=['backports.shutil_get_terminal_size',
'astropy', 'numpy', 'scipy'],
python_requires=">=3.7",
entry_points = {
'console_scripts': [
'pybdsf = bdsf.pybdsf:main [ishell]',
Expand Down

0 comments on commit 9b0d480

Please sign in to comment.