Skip to content

Commit

Permalink
Merge pull request #261 from BrillouinMicroscopy/fix/noid/updates
Browse files Browse the repository at this point in the history
chore: update dependencies and CI config
  • Loading branch information
raimund-schluessler authored Jun 4, 2024
2 parents fce710c + 75839db commit 62b6cea
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 73 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check_main_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [macos-latest, ubuntu-latest, windows-latest]
exclude:
# 3.10 on macOS with shapely 1.8.0 is broken, but shapely >1.8.0 breaks the macOS DMG packages
Expand All @@ -35,7 +35,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libegl1-mesa
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libegl1-mesa libxcb-cursor0
# start xvfb in the background
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
- name: Install dependencies for Mac and Linux
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
run: |
bash ./macos_build_app.sh BMicro $(python -m bmicro --version)
- name: Upload build artifacts
if: (runner.os == 'macOS' && matrix.python-version == '3.9')
if: (runner.os == 'macOS' && matrix.python-version == '3.12')
uses: actions/upload-artifact@v3
with:
name: BMicro_macosx
Expand All @@ -102,7 +102,7 @@ jobs:
python win_make_iss.py
iscc /Q win_bmicro.iss
- name: Upload build artifacts
if: (runner.os == 'windows' && matrix.python-version == '3.9')
if: (runner.os == 'windows' && matrix.python-version == '3.12')
uses: actions/upload-artifact@v3
with:
name: BMicro
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/check_stable_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [macos-latest, ubuntu-latest, windows-latest]
exclude:
# 3.10 on macOS with shapely 1.8.0 is broken, but shapely >1.8.0 breaks the macOS DMG packages
Expand All @@ -35,7 +35,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libegl1-mesa libxcb-shape0
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libegl1-mesa libxcb-shape0 libxcb-cursor0
# start xvfb in the background
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
- name: Install dependencies
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
run: |
bash ./macos_build_app.sh BMicro $(python -m bmicro --version)
- name: Upload build artifacts
if: (runner.os == 'macOS' && matrix.python-version == '3.9')
if: (runner.os == 'macOS' && matrix.python-version == '3.12')
uses: actions/upload-artifact@v3
with:
name: BMicro_macosx
Expand All @@ -86,7 +86,7 @@ jobs:
python win_make_iss.py
iscc /Q win_bmicro.iss
- name: Upload build artifacts
if: (runner.os == 'windows' && matrix.python-version == '3.9')
if: (runner.os == 'windows' && matrix.python-version == '3.12')
uses: actions/upload-artifact@v3
with:
name: BMicro
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.9']
python-version: ['3.12']
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ['3.9']
python-version: ['3.12']

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 2 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ version: 2
formats:
- pdf
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.12"
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .

9 changes: 5 additions & 4 deletions bmicro/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def main():
import os
import pkg_resources
from importlib import resources
import sys
import logging

Expand All @@ -13,9 +13,10 @@ def main():
"""
app = QtWidgets.QApplication(sys.argv)
# set window icon
imdir = pkg_resources.resource_filename("bmicro", "img")
icon_path = os.path.join(imdir, "icon.png")
app.setWindowIcon(QtGui.QIcon(icon_path))
ref = resources.files('bmicro') / 'img'
with resources.as_file(ref) as imdir:
icon_path = os.path.join(imdir, "icon.png")
app.setWindowIcon(QtGui.QIcon(icon_path))

window = BMicro()
window.show()
Expand Down
15 changes: 8 additions & 7 deletions bmicro/gui/calibration/calibration_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib import resources
import logging

from PyQt6 import QtWidgets, QtCore, uic
Expand Down Expand Up @@ -31,9 +31,9 @@ class CalibrationView(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super(CalibrationView, self).__init__(*args, **kwargs)

ui_file = pkg_resources.resource_filename(
'bmicro.gui.calibration', 'calibration_view.ui')
uic.loadUi(ui_file, self)
ref = resources.files('bmicro.gui.calibration') / 'calibration_view.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)

self.mplcanvas = MplCanvas(self.image_widget,
toolbar=('Home', 'Pan', 'Zoom'))
Expand Down Expand Up @@ -422,14 +422,15 @@ def find_peaks(self):
self.refresh_plot()

def show_options(self):
ui_file = pkg_resources.resource_filename(
'bmicro.gui.calibration', 'calibration_options.ui')
self.options_dialog = QtWidgets.QDialog(
self,
QtCore.Qt.WindowType.WindowTitleHint |
QtCore.Qt.WindowType.WindowCloseButtonHint
)
uic.loadUi(ui_file, self.options_dialog)
ref = (resources.files('bmicro.gui.calibration') /
'calibration_options.ui')
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self.options_dialog)
self.options_dialog.setWindowTitle('Calibration options')
self.options_dialog.setWindowModality(
QtCore.Qt.WindowModality.ApplicationModal)
Expand Down
8 changes: 4 additions & 4 deletions bmicro/gui/data/data_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib import resources
import logging

from PyQt6 import uic, QtWidgets
Expand All @@ -24,9 +24,9 @@ class DataView(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super(DataView, self).__init__(*args, **kwargs)

ui_file = pkg_resources.resource_filename(
'bmicro.gui.data', 'data_view.ui')
uic.loadUi(ui_file, self)
ref = resources.files('bmicro.gui.data') / 'data_view.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)

self.mplcanvas = MplCanvas(self.image_preview_widget)
self.preview = self.mplcanvas.get_figure().add_subplot(111)
Expand Down
20 changes: 10 additions & 10 deletions bmicro/gui/evaluation/evaluation_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib import resources
import logging
import numpy as np
import matplotlib
Expand Down Expand Up @@ -43,9 +43,9 @@ class EvaluationView(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super(EvaluationView, self).__init__(*args, **kwargs)

ui_file = pkg_resources.resource_filename(
'bmicro.gui.evaluation', 'evaluation_view.ui')
uic.loadUi(ui_file, self)
ref = resources.files('bmicro.gui.evaluation') / 'evaluation_view.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)

self.mplcanvas = MplCanvas(self.image_widget,
toolbar=('Home', 'Pan', 'Zoom'))
Expand Down Expand Up @@ -314,16 +314,16 @@ def on_click_image(self, event):

def open_image_spectrum(self):
if self.image_spectrum_dialog is None:
ui_file = pkg_resources.resource_filename(
'bmicro.gui.evaluation', 'spectrum_view.ui')
self.image_spectrum_dialog = QtWidgets.QDialog(
self,
QtCore.Qt.WindowType.WindowTitleHint |
QtCore.Qt.WindowType.WindowCloseButtonHint |
QtCore.Qt.WindowType.WindowMaximizeButtonHint |
QtCore.Qt.WindowType.WindowMinimizeButtonHint
)
uic.loadUi(ui_file, self.image_spectrum_dialog)
ref = resources.files('bmicro.gui.evaluation') / 'spectrum_view.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self.image_spectrum_dialog)
self.image_spectrum_dialog\
.setWindowTitle('Camera image & spectrum')
self.image_spectrum_dialog.setWindowModality(
Expand Down Expand Up @@ -630,9 +630,9 @@ def refresh_plot(self):
# horizontal axis
image_map = data[tuple(dslice)]
image_map = np.rot90(image_map)
extent = np.nanmin(positions[idx[0]][tuple(dslice)]),\
np.nanmax(positions[idx[0]][tuple(dslice)]),\
np.nanmin(positions[idx[1]][tuple(dslice)]),\
extent = np.nanmin(positions[idx[0]][tuple(dslice)]), \
np.nanmax(positions[idx[0]][tuple(dslice)]), \
np.nanmin(positions[idx[1]][tuple(dslice)]), \
np.nanmax(positions[idx[1]][tuple(dslice)])
if isinstance(self.image_map, matplotlib.image.AxesImage):
self.image_map.set_data(image_map)
Expand Down
8 changes: 4 additions & 4 deletions bmicro/gui/extraction/extraction_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib import resources
import logging

from PyQt6 import QtWidgets, QtCore, uic
Expand Down Expand Up @@ -28,9 +28,9 @@ class ExtractionView(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super(ExtractionView, self).__init__(*args, **kwargs)

ui_file = pkg_resources.resource_filename(
'bmicro.gui.extraction', 'extraction_view.ui')
uic.loadUi(ui_file, self)
ref = resources.files('bmicro.gui.extraction') / 'extraction_view.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)

self.mode = MODE_DEFAULT
self.current_frame = 0
Expand Down
27 changes: 15 additions & 12 deletions bmicro/gui/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pathlib
import pkg_resources
from importlib import resources
import hashlib
import signal
import sys
Expand All @@ -8,15 +8,15 @@
import numpy as np

from PyQt6 import QtWidgets, uic, QtCore, QtGui
from PyQt6.QtWidgets import QFileDialog, QMessageBox,\
from PyQt6.QtWidgets import QFileDialog, QMessageBox, \
QVBoxLayout, QWidget, QCheckBox, QHBoxLayout, QLabel, QLineEdit
from PyQt6.QtCore import QSize

from bmlab.session import Session
from bmlab.file import is_source_file
from bmlab.models.setup import AVAILABLE_SETUPS
from bmlab.models import EvaluationModel
from bmlab.controllers import PeakSelectionController, ExportController,\
from bmlab.controllers import PeakSelectionController, ExportController, \
EvaluationController

from . import data
Expand Down Expand Up @@ -64,11 +64,14 @@ def __init__(self, *args, **kwargs):

""" Initializes BMicro."""
super(BMicro, self).__init__(*args, **kwargs)
ui_file = pkg_resources.resource_filename('bmicro.gui', 'main.ui')
uic.loadUi(ui_file, self)
ref = resources.files('bmicro.gui') / 'main.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)
QtCore.QCoreApplication.setApplicationName('BMicro')

self.imdir = pkg_resources.resource_filename("bmicro", "img")
ref = resources.files('bmicro') / 'img'
with resources.as_file(ref) as imdir:
self.imdir = imdir

self.tabWidget.currentChanged.connect(self.update_ui)

Expand Down Expand Up @@ -200,14 +203,14 @@ def close_file(self):
self.reset_ui()

def on_action_export_file(self):
ui_file = pkg_resources.resource_filename(
'bmicro.gui', 'export_configuration.ui')
self.export_dialog = QtWidgets.QDialog(
self,
QtCore.Qt.WindowType.WindowTitleHint |
QtCore.Qt.WindowType.WindowCloseButtonHint
)
uic.loadUi(ui_file, self.export_dialog)
ref = resources.files('bmicro.gui') / 'export_configuration.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self.export_dialog)
self.export_dialog.setWindowTitle('Export configuration')
self.export_dialog.setWindowModality(
QtCore.Qt.WindowModality.ApplicationModal)
Expand Down Expand Up @@ -402,16 +405,16 @@ def on_action_about(self):
f"BMicro {bmicroversion}", about_text)

def on_action_batch_evaluation(self):
ui_file = pkg_resources.resource_filename(
'bmicro.gui', 'batch_evaluation.ui')
self.batch_dialog = QtWidgets.QDialog(
self,
QtCore.Qt.WindowType.WindowTitleHint |
QtCore.Qt.WindowType.WindowCloseButtonHint |
QtCore.Qt.WindowType.WindowMaximizeButtonHint |
QtCore.Qt.WindowType.WindowMinimizeButtonHint
)
uic.loadUi(ui_file, self.batch_dialog)
ref = resources.files('bmicro.gui') / 'batch_evaluation.ui'
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self.batch_dialog)
self.batch_dialog.setWindowTitle('Batch evaluation')
self.batch_dialog.setWindowModality(
QtCore.Qt.WindowModality.ApplicationModal)
Expand Down
9 changes: 5 additions & 4 deletions bmicro/gui/peak_selection/peak_selection_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib import resources
import logging

from PyQt6 import QtWidgets, uic
Expand Down Expand Up @@ -27,9 +27,10 @@ class PeakSelectionView(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super(PeakSelectionView, self).__init__(*args, **kwargs)

ui_file = pkg_resources.resource_filename(
'bmicro.gui.peak_selection', 'peak_selection_view.ui')
uic.loadUi(ui_file, self)
ref = (resources.files('bmicro.gui.peak_selection') /
'peak_selection_view.ui')
with resources.as_file(ref) as ui_file:
uic.loadUi(ui_file, self)

self.mplcanvas = MplCanvas(self.image_widget,
toolbar=('Home', 'Pan', 'Zoom'))
Expand Down
2 changes: 0 additions & 2 deletions build-recipes/hook-skimage.py

This file was deleted.

5 changes: 0 additions & 5 deletions build-recipes/macos_build_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# Any additional requirements for building the application
# There seems to be an issue with the scipy wheels for 1.8.0:
# https://github.com/scipy/scipy/issues/15552
scipy<1.8.0
pyinstaller>=5.0
shapely<1.8.1

4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ipython
matplotlib
numpy
scipy
sphinx==4.2.0
sphinx
sphinxcontrib.bibtex>=2.0
sphinx_rtd_theme==1.0
sphinx_rtd_theme
Loading

0 comments on commit 62b6cea

Please sign in to comment.