Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/pyinstaller/pyinstaller_github.spec
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ hiddenimports += collect_submodules('hdf5plugin')
hiddenimports += collect_submodules('fisx')
hiddenimports += collect_submodules('PyMca5.PyMcaGui.PyMcaQt')
hiddenimports += collect_submodules('PyMca5.PyMcaGui.pymca')
hiddenimports += collect_submodules('multiprocessing')
hiddenimports += collect_submodules('multiprocessing.spawn')

my_binaries = []

Expand Down
11 changes: 10 additions & 1 deletion src/PyMca5/PyMcaGui/physics/xrf/ElementsInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -30,7 +30,16 @@
__contact__ = "sole@esrf.fr"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
import sys
import logging
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
from PyMca5.PyMcaGui import PyMcaQt as qt
from PyMca5.PyMcaPhysics.xrf import ElementHtml
from PyMca5.PyMcaPhysics.xrf import Elements
Expand Down
10 changes: 9 additions & 1 deletion src/PyMca5/PyMcaGui/physics/xrf/PeakIdentifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -32,6 +32,14 @@
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
import sys
import logging
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
from PyMca5.PyMcaGui import PyMcaQt as qt
from PyMca5.PyMcaPhysics import Elements
from PyMca5.PyMcaGui.plotting import PyMca_Icons
Expand Down
11 changes: 10 additions & 1 deletion src/PyMca5/PyMcaGui/pymca/EdfFileSimpleViewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2022 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -28,7 +28,16 @@
__contact__ = "sole@esrf.fr"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
import sys
import logging
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
from PyMca5.PyMcaGui import PyMcaQt as qt

QTVERSION = qt.qVersion()
Expand Down
10 changes: 9 additions & 1 deletion src/PyMca5/PyMcaGui/pymca/Mca2Edf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -32,6 +32,14 @@
import os
import numpy
import time
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass

from PyMca5.PyMcaGui import PyMcaQt as qt
QTVERSION = qt.qVersion()
Expand Down
10 changes: 9 additions & 1 deletion src/PyMca5/PyMcaGui/pymca/PyMcaBatch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -36,6 +36,14 @@
import atexit
import logging
import traceback
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
from glob import glob
from contextlib import contextmanager
try:
Expand Down
10 changes: 9 additions & 1 deletion src/PyMca5/PyMcaGui/pymca/PyMcaMain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2025 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -32,6 +32,14 @@
import sys, getopt
import traceback
import logging
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
if sys.platform == 'win32':
import ctypes
from ctypes.wintypes import MAX_PATH
Expand Down
12 changes: 10 additions & 2 deletions src/PyMca5/PyMcaGui/pymca/PyMcaPostBatch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -31,8 +31,16 @@
import sys
import os
import logging
if __name__== '__main__':
# this is to avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
_logger = logging.getLogger(__name__)
if __name__ == "__main__":
if __name__ == "__main__":
# We are going to read. Disable file locking.
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
_logger.info("%s set to %s" % ("HDF5_USE_FILE_LOCKING",
Expand Down
10 changes: 9 additions & 1 deletion src/PyMca5/PyMcaGui/pymca/QStackWidget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2026 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -35,6 +35,14 @@
import numpy
import weakref
import logging
if __name__== '__main__':
# avoid issues if some module or dependency tries to use multiprocessing in frozen binaries
if getattr(sys, "frozen", False):
try:
import multiprocessing
multiprocessing.freeze_support()
except Exception:
pass
_logger = logging.getLogger(__name__)

if __name__ == "__main__":
Expand Down
21 changes: 14 additions & 7 deletions src/PyMca5/PyMcaIO/HDF5Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import logging
import posixpath
from queue import Empty
import multiprocessing
from operator import itemgetter


_logger = logging.getLogger(__name__)
try:
import multiprocessing
_MULTIPROCESS = True
except Exception:
_logger.info("multiprocessing not available")
_MULTIPROCESS = False
from operator import itemgetter


def get_hdf5_group_keys(file_path, data_path=None):
Expand All @@ -24,9 +27,13 @@ def get_hdf5_group_keys(file_path, data_path=None):


def safe_hdf5_group_keys(file_path, data_path=None):
return run_in_subprocess(
get_hdf5_group_keys, file_path, data_path=data_path, default=list()
)
if _MULTIPROCESS:
return run_in_subprocess(
get_hdf5_group_keys, file_path, data_path=data_path, default=list()
)
else:
_logger.warning("multiprocessing not available")
return get_hdf5_group_keys(file_path, data_path)


def run_in_subprocess(target, *args, context=None, default=None, **kwargs):
Expand Down