diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 01ce9ce1f..dc8090f7a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 diff --git a/doc/source/conf.py b/doc/source/conf.py index 718ec107d..3bd555f2c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -56,7 +56,7 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinxcontrib.programoutput', - "nbsphinx" + 'nbsphinx' ] # Set the theme to sphinx_rtd_theme when *not* building on Read The Docs. diff --git a/meson.build b/meson.build index d1cf0b927..f813632db 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('FabIO', 'c', 'cython', license: 'MIT', meson_version: '>= 0.60', - version: run_command('src/fabio/_version.py', + version: run_command(['version.py', '--wheel'], check:true).stdout().strip(), ) @@ -13,6 +13,7 @@ if meson.backend() != 'ninja' endif cc = meson.get_compiler('c') +cy = meson.get_compiler('cython') m_dep = cc.find_library('m', required : false) if m_dep.found() add_project_link_arguments('-lm', language : 'c') @@ -23,4 +24,11 @@ py_mod = import('python') py = py_mod.find_installation() py_dep = py.dependency() +py.install_sources([ + 'version.py', +], + pure: false, # Will be installed next to binaries + subdir: 'fabio' # Folder relative to site-packages to install to +) + subdir('src/fabio') diff --git a/package/debian12/control b/package/debian12/control index 902418651..f2ed41c7b 100644 --- a/package/debian12/control +++ b/package/debian12/control @@ -7,6 +7,9 @@ Priority: extra Build-Depends: cython3, debhelper, dh-python, + devscripts, + python3-tomli, + python3-mesonpy, python3-all-dev, python3-pil, python3-lxml, @@ -18,10 +21,7 @@ Build-Depends: cython3, python3-sphinxcontrib.programoutput, python3-sphinx-rtd-theme, python3-h5py, - python3-tomli, - python3-mesonpy, help2man, - devscripts, python3-pyqt5, python3-matplotlib, bitshuffle, diff --git a/src/fabio/__init__.py b/src/fabio/__init__.py index bca92785a..486a4e8ec 100644 --- a/src/fabio/__init__.py +++ b/src/fabio/__init__.py @@ -28,7 +28,7 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "GPLv3+" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "21/06/2023" +__date__ = "15/03/2024" __status__ = "stable" import sys @@ -39,8 +39,7 @@ logging.basicConfig() import os -from ._version import __date__ as date # noqa -from ._version import version, version_info, hexversion, strictversion # noqa +from .version import __date__ as date, version, version_info, hexversion, strictversion # noqa from . import fabioformats as _fabioformats # provide a global fabio API diff --git a/src/fabio/app/eiger2crysalis.py b/src/fabio/app/eiger2crysalis.py index 623e3f83f..70a6846f5 100644 --- a/src/fabio/app/eiger2crysalis.py +++ b/src/fabio/app/eiger2crysalis.py @@ -38,7 +38,7 @@ __author__ = "Jerome Kieffer" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" __licence__ = "MIT" -__date__ = "23/02/2023" +__date__ = "15/03/2024" __status__ = "production" FOOTER = """To import your files as a project: @@ -401,7 +401,7 @@ def treat_mask(self, full=False): ":param full: complete/slow mask analysis" if self.progress: self.progress.update(self.progress.max_value - 1, "Generate mask") - dummy_value = numpy.cast[self.mask.dtype](-1) + dummy_value = numpy.asarray(-numpy.ones(1), dtype=self.mask.dtype)[-1] #-1 in the given datatype mask = (self.mask==dummy_value).astype(numpy.int8) esperantoimage.EsperantoImage.DUMMY = 1 new_mask = self.geometry_transform(esperantoimage.EsperantoImage(data=mask).data) diff --git a/src/fabio/cbfimage.py b/src/fabio/cbfimage.py index 6f66bb268..c0795f939 100644 --- a/src/fabio/cbfimage.py +++ b/src/fabio/cbfimage.py @@ -245,7 +245,7 @@ def read(self, fname, frame=None, check_MD5=True, only_raw=False): return binary_data if ("Content-MD5" in self.header) and check_MD5: - ref = numpy.string_(self.header["Content-MD5"]) + ref = numpy.bytes_(self.header["Content-MD5"]) obt = md5sum(binary_data) if ref != obt: logger.error("Checksum of binary data mismatch: expected %s, got %s" % (ref, obt)) @@ -294,14 +294,14 @@ def write(self, fname): b"Content-Type: application/octet-stream;", b' conversions="x-CBF_BYTE_OFFSET"', b'Content-Transfer-Encoding: BINARY', - numpy.string_("X-Binary-Size: %d" % (len(binary_blob))), + numpy.bytes_("X-Binary-Size: %d" % (len(binary_blob))), b"X-Binary-ID: 1", - numpy.string_('X-Binary-Element-Type: "%s"' % (dtype)), + numpy.bytes_('X-Binary-Element-Type: "%s"' % (dtype)), b"X-Binary-Element-Byte-Order: LITTLE_ENDIAN", b"Content-MD5: " + md5sum(binary_blob), - numpy.string_("X-Binary-Number-of-Elements: %d" % (dim1 * dim2)), - numpy.string_("X-Binary-Size-Fastest-Dimension: %d" % dim1), - numpy.string_("X-Binary-Size-Second-Dimension: %d" % dim2), + numpy.bytes_("X-Binary-Number-of-Elements: %d" % (dim1 * dim2)), + numpy.bytes_("X-Binary-Size-Fastest-Dimension: %d" % dim1), + numpy.bytes_("X-Binary-Size-Second-Dimension: %d" % dim2), b"X-Binary-Size-Padding: 1", b"", self.STARTER + binary_blob, @@ -354,22 +354,22 @@ class CIF(dict): keys are always unicode (str in python3) values are bytes """ - EOL = [numpy.string_(i) for i in ("\r", "\n", "\r\n", "\n\r")] - BLANK = [numpy.string_(i) for i in (" ", "\t")] + EOL - SINGLE_QUOTE = numpy.string_("'") - DOUBLE_QUOTE = numpy.string_('"') - SEMICOLUMN = numpy.string_(';') - DOT = numpy.string_('.') + EOL = [numpy.bytes_(i) for i in ("\r", "\n", "\r\n", "\n\r")] + BLANK = [numpy.bytes_(i) for i in (" ", "\t")] + EOL + SINGLE_QUOTE = numpy.bytes_("'") + DOUBLE_QUOTE = numpy.bytes_('"') + SEMICOLUMN = numpy.bytes_(';') + DOT = numpy.bytes_('.') START_COMMENT = (SINGLE_QUOTE, DOUBLE_QUOTE) - BINARY_MARKER = numpy.string_("--CIF-BINARY-FORMAT-SECTION--") - HASH = numpy.string_("#") - LOOP = numpy.string_("loop_") + BINARY_MARKER = numpy.bytes_("--CIF-BINARY-FORMAT-SECTION--") + HASH = numpy.bytes_("#") + LOOP = numpy.bytes_("loop_") UNDERSCORE = ord("_") - QUESTIONMARK = numpy.string_("?") - STOP = numpy.string_("stop_") - GLOBAL = numpy.string_("global_") - DATA = numpy.string_("data_") - SAVE = numpy.string_("save_") + QUESTIONMARK = numpy.bytes_("?") + STOP = numpy.bytes_("stop_") + GLOBAL = numpy.bytes_("global_") + DATA = numpy.bytes_("data_") + SAVE = numpy.bytes_("save_") def __init__(self, _strFilename=None): """ @@ -416,7 +416,7 @@ def loadCIF(self, _strFilename, _bKeepComment=False): else: raise RuntimeError("CIF.loadCIF: what is %s type %s" % (_strFilename, type(_strFilename))) if _bKeepComment: - self._parseCIF(numpy.string_(infile.read())) + self._parseCIF(numpy.bytes_(infile.read())) else: self._parseCIF(CIF._readCIF(infile)) if own_fd: @@ -454,13 +454,13 @@ def _readCIF(cls, instream): if "read" not in dir(instream): raise RuntimeError("CIF._readCIF(instream): I expected instream to be an opened file,\ here I got %s type %s" % (instream, type(instream))) - out_bytes = numpy.string_("") + out_bytes = numpy.bytes_("") for sLine in instream: - nline = numpy.string_(sLine) + nline = numpy.bytes_(sLine) pos = nline.find(cls.HASH) if pos >= 0: if cls.isAscii(nline): - out_bytes += nline[:pos] + numpy.string_(os.linesep) + out_bytes += nline[:pos] + numpy.bytes_(os.linesep) if pos > 80: logger.warning("This line is too long and could cause problems in PreQuest: %s", sLine) else: @@ -535,7 +535,7 @@ def _splitCIF(cls, bytes_text): idx += 1 + bytes_text[idx + 1:].find(cls.SINGLE_QUOTE) if idx >= len(bytes_text) - 1: fields.append(bytes_text[1:-1].strip()) - bytes_text = numpy.string_("") + bytes_text = numpy.bytes_("") finished = True break @@ -552,7 +552,7 @@ def _splitCIF(cls, bytes_text): idx += 1 + bytes_text[idx + 1:].find(cls.DOUBLE_QUOTE) if idx >= len(bytes_text) - 1: fields.append(bytes_text[1:-1].strip()) - bytes_text = numpy.string_("") + bytes_text = numpy.bytes_("") finished = True break @@ -594,7 +594,7 @@ def _splitCIF(cls, bytes_text): bytes_text = bytes_text[end_binary:].strip() else: fields.append(bytes_text) - bytes_text = numpy.string_("") + bytes_text = numpy.bytes_("") break return fields diff --git a/src/fabio/eigerimage.py b/src/fabio/eigerimage.py index c3c505614..8bd02be72 100644 --- a/src/fabio/eigerimage.py +++ b/src/fabio/eigerimage.py @@ -2,7 +2,7 @@ # # Project: FabIO X-ray image reader # -# Copyright (C) 2010-2016 European Synchrotron Radiation Facility +# Copyright (C) 2010-2024 European Synchrotron Radiation Facility # Grenoble, France # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -45,7 +45,7 @@ __contact__ = "jerome.kieffer@esrf.fr" __license__ = "MIT" __copyright__ = "ESRF" -__date__ = "05/07/2022" +__date__ = "15/03/2024" import logging logger = logging.getLogger(__name__) @@ -184,7 +184,7 @@ def write(self, fname): for i, ds in enumerate(self.dataset): if ds is None: # we are in a trouble - data = numpy.atleast_2d(numpy.NaN) + data = numpy.atleast_2d(numpy.nan) elif isinstance(ds, h5py.Dataset): data = numpy.atleat_2d(ds[()]) else: diff --git a/src/fabio/fabioimage.py b/src/fabio/fabioimage.py index 7a617e3a1..5244fe7ed 100644 --- a/src/fabio/fabioimage.py +++ b/src/fabio/fabioimage.py @@ -816,6 +816,7 @@ def _compressed_stream(self, fobj.seek(0) elif self._need_a_seek_to_read and mode[0] == "r": fo = python_uncompress(fname, mode) + print(fname, mode, fo) fobj = fabioutils.BytesIO(fo.read(), fname, mode) else: fobj = python_uncompress(fname, mode) diff --git a/src/fabio/meson.build b/src/fabio/meson.build index 0a2a9f328..215855f27 100644 --- a/src/fabio/meson.build +++ b/src/fabio/meson.build @@ -6,7 +6,6 @@ subdir('test') subdir('utils') py.install_sources([ - '_version.py', 'adscimage.py', 'binaryimage.py', 'bruker100image.py', diff --git a/src/fabio/nexus.py b/src/fabio/nexus.py index 4916bcbba..51d418c25 100644 --- a/src/fabio/nexus.py +++ b/src/fabio/nexus.py @@ -29,11 +29,11 @@ """ -__author__ = "Jerome Kieffer" +__author__ = "Jérôme Kieffer" __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "28/04/2021" +__date__ = "15/03/2024" __status__ = "production" __docformat__ = 'restructuredtext' @@ -44,7 +44,7 @@ import time import numpy from .fabioutils import exists -from ._version import version +from .version import version logger = logging.getLogger(__name__) try: diff --git a/src/fabio/sparseimage.py b/src/fabio/sparseimage.py index f249b2ca8..30a7eaddb 100644 --- a/src/fabio/sparseimage.py +++ b/src/fabio/sparseimage.py @@ -3,7 +3,7 @@ # Project: X-ray image reader # https://github.com/silx-kit/fabio # -# Copyright 2020-2021(C) European Synchrotron Radiation Facility, Grenoble, France +# Copyright 2020-2024(C) European Synchrotron Radiation Facility, Grenoble, France # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -37,7 +37,7 @@ __contact__ = "jerome.kieffer@esrf.fr" __license__ = "MIT" __copyright__ = "2020 ESRF" -__date__ = "09/02/2023" +__date__ = "15/03/2024" import logging logger = logging.getLogger(__name__) @@ -183,7 +183,7 @@ def read(self, fname, frame=None): self.dummy = self.intensity.dtype.type(nx_data["dummy"][()]) except KeyError: if self.intensity.dtype.char in numpy.typecodes['AllFloat']: - self.dummy = numpy.NaN + self.dummy = numpy.nan else: self.dummy = 0 diff --git a/src/fabio/utils/deprecation.py b/src/fabio/utils/deprecation.py index 32945b759..b809a0187 100644 --- a/src/fabio/utils/deprecation.py +++ b/src/fabio/utils/deprecation.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# Copyright (c) 2016-2024 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,15 +24,16 @@ # ###########################################################################*/ """Bunch of useful decorators""" -__authors__ = ["Jerome Kieffer", "H. Payno", "P. Knobel"] +__authors__ = ["Jérôme Kieffer", "H. Payno", "P. Knobel"] __license__ = "MIT" -__date__ = "18/12/2020" +__date__ = "15/03/2024" import logging import functools import traceback import re -from .. import _version + +from ..version import calc_hexversion, hexversion as ref_hexversion depreclog = logging.getLogger("fabio.DEPRECATION") @@ -54,7 +55,7 @@ def hexversion_fromstring(string): releaselevel = result[3] if releaselevel is None: releaselevel = 0 - return _version.calc_hexversion(major, minor, micro, releaselevel, serial=0) + return calc_hexversion(major, minor, micro, releaselevel, serial=0) def deprecated(func=None, reason=None, replacement=None, since_version=None, @@ -154,7 +155,7 @@ def deprecated_warning(type_, name, reason=None, replacement=None, deprecated_since = hexversion else: deprecated_since = _CACHE_VERSIONS[deprecated_since] - log_as_debug = _version.hexversion < deprecated_since + log_as_debug = ref_hexversion < deprecated_since else: log_as_debug = False diff --git a/src/fabio/_version.py b/version.py similarity index 97% rename from src/fabio/_version.py rename to version.py index 797650585..3474fb902 100755 --- a/src/fabio/_version.py +++ b/version.py @@ -4,7 +4,7 @@ # Project: X-ray image reader # https://github.com/silx-kit/fabio # -# Copyright (C) 2015-2023 European Synchrotron Radiation Facility, Grenoble, France +# Copyright (C) 2015-2024 European Synchrotron Radiation Facility, Grenoble, France # # Principal author: Jérôme Kieffer (Jerome.Kieffer@ESRF.eu) # @@ -58,7 +58,7 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "07/08/2023" +__date__ = "15/03/2024" __status__ = "production" __docformat__ = 'restructuredtext' __all__ = ["date", "version_info", "strictversion", "hexversion", "debianversion", @@ -75,8 +75,8 @@ "beta": "b", "candidate": "rc"} -MAJOR = 2023 -MINOR = 11 +MAJOR = 2024 +MINOR = 3 MICRO = 0 RELEV = "dev" # <16 SERIAL = 0 # <16