From f37d57fb3d1d7a4b57397b7af3a166635e5c74b9 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Tue, 18 Apr 2023 15:55:00 -0400 Subject: [PATCH 1/2] Squashed commit of the following: commit d14cb7478a2571ef6bdd677ed707ed5cd2df678f Merge: fb122b3 d07618a Author: Chris Billington Date: Tue Apr 18 13:14:45 2023 +1000 Merge pull request #96 from labscript-suite/high-dipi Set some Qt settings to play nicer on High DPI displays commit fb122b3ab3b218ebefe412e724fa7c5cffcb4cc6 Merge: 87de9cd 1568793 Author: David Meyer Date: Wed Apr 12 21:19:24 2023 -0400 Merge pull request #94 from dihm/shot_utils Moving `get_shot_globals` function from runmanager to labscript_utils. commit 87de9cda44410716e73b02855e34d1e981155a05 Merge: 29ac288 835bbe8 Author: David Meyer Date: Wed Apr 12 20:22:57 2023 -0400 Merge pull request #97 from labscript-suite/dragdroptab-fix Fix issue with dragdroptab - convert float coords to int commit 29ac28808c6ad7aee11b93823c34dd597ec08cfe Author: David Meyer Date: Wed Apr 12 19:45:40 2023 -0400 Update python version support commit 5f2775e359e0900492f36c751393cc62d77dfb57 Merge: c38b661 90f486d Author: David Meyer Date: Wed Apr 12 17:10:05 2023 -0400 Merge pull request #98 from dihm/update-workflow Sync workflow commit 90f486dfc82e9b3791d1e894fa83af48f2075620 Author: David Meyer Date: Wed Apr 12 17:06:41 2023 -0400 Sync workflow commit 835bbe8c03b6a4ad5aca3f9544293eff64df3353 Author: chrisjbillington Date: Sat Apr 8 21:00:52 2023 +1000 Fix issue with dragdroptab - convert float coords to int QPoint no longer auto converts float arguments, resulting in an error commit d07618a20da8dcc8a4ae85d59ce82bc9fac49e8f Author: chrisjbillington Date: Sat Apr 8 20:37:17 2023 +1000 Set some Qt settings to play nicer on High DPI displays `labscript_utils.splash` is the first place a `QApplication` gets created for all of our apps. So setting these settings there applies them to all our applications, although they are also needed for the splash screen itself to be scaled better on High DPI displays. `AA_EnableHighDpiScaling` scales all pixel metrics to the device pixel ratio - so this means curved edges and padding and whatnot get scaled up, as well as the size of some pixmaps. `AA_UseHighDpiPixmaps` means to use high DPI pixmaps for icons etc, directly, rather than rendering them at the lower resolution and then scaling them up (not sure why anyone would want the latter behaviour). Strangely, high resolution pixmaps *are* used when `AA_EnableHighDpiScaling` is *off*. It's only when it is turned on that they get downscaled and then upscaled again and end up blocky. commit 15687931199338df4568df4387d5901cacafd6fb Author: David Meyer Date: Mon Mar 13 10:21:39 2023 -0400 Moving `get_shot_globals` function from runmanager to labscript_utils. This will allow us to break lyse's dependency on runmanager. --- .github/workflows/release.yml | 89 +++++++++++------------- labscript_utils/qtwidgets/dragdroptab.py | 4 +- labscript_utils/shot_utils.py | 37 ++++++++++ labscript_utils/splash.py | 9 +++ setup.cfg | 2 + 5 files changed, 92 insertions(+), 49 deletions(-) create mode 100644 labscript_utils/shot_utils.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acd1c06..3e00491 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,25 +37,29 @@ jobs: strategy: matrix: include: - # - { os: ubuntu-latest, python: '3.10', arch: x64 } - # - { os: ubuntu-latest, python: '3.9', arch: x64 } - - { os: ubuntu-latest, python: '3.8', arch: x64 } - # - { os: ubuntu-latest, python: '3.7', arch: x64 } - - # - { os: macos-latest, python: '3.10', arch: x64 } - # - { os: macos-latest, python: '3.9', arch: x64 } - # - { os: macos-latest, python: '3.8', arch: x64 } - # - { os: macos-latest, python: '3.7', arch: x64 } - - # - { os: windows-latest, python: '3.10', arch: x64 } - # - { os: windows-latest, python: '3.9', arch: x64 } - # - { os: windows-latest, python: '3.8', arch: x64 } - # - { os: windows-latest, python: '3.7', arch: x64 } - - # - { os: windows-latest, python: '3.10', arch: x86 } - # - { os: windows-latest, python: '3.9', arch: x86 } - # - { os: windows-latest, python: '3.8', arch: x86 } - # - { os: windows-latest, python: '3.7', arch: x86 } + - { os: ubuntu-latest, python: '3.11', arch: x64, conda: true} + # - { os: ubuntu-latest, python: '3.10', arch: x64, conda: true } + # - { os: ubuntu-latest, python: '3.9', arch: x64, conda: true } + # - { os: ubuntu-latest, python: '3.8', arch: x64, conda: true } + # - { os: ubuntu-latest, python: '3.7', arch: x64, conda: true } + + # - { os: macos-11, python: '3.11', arch: x64, conda: true } + # - { os: macos-11, python: '3.10', arch: x64, conda: true } + # - { os: macos-11, python: '3.9', arch: x64, conda: true } + # - { os: macos-11, python: '3.8', arch: x64, conda: true } + # - { os: macos-11, python: '3.7', arch: x64, conda: true } + + # - { os: windows-latest, python: '3.11', arch: x64, conda: true } + # - { os: windows-latest, python: '3.10', arch: x64, conda: true } + # - { os: windows-latest, python: '3.9', arch: x64, conda: true } + # - { os: windows-latest, python: '3.8', arch: x64, conda: true } + # - { os: windows-latest, python: '3.7', arch: x64, conda: true } + + # - { os: windows-latest, python: '3.11', arch: x86, conda: false } # conda not yet available + # - { os: windows-latest, python: '3.10', arch: x86, conda: true } + # - { os: windows-latest, python: '3.9', arch: x86, conda: true } + # - { os: windows-latest, python: '3.8', arch: x86, conda: true } + # - { os: windows-latest, python: '3.7', arch: x86, conda: true } if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch') steps: @@ -95,6 +99,7 @@ jobs: path: ./dist - name: Set Variables for Conda Build + if: matrix.conda shell: bash run: | if [ $NOARCH == true ]; then @@ -105,37 +110,36 @@ jobs: echo "CONDA_BUILD_ARGS=$CONDA_BUILD_ARGS" >> $GITHUB_ENV - name: Install Miniconda - # We need https://github.com/conda-incubator/setup-miniconda/pull/189 in order - # to be able to install 32-bit miniconda on Windows. Once setup-miniconda 2.1.2 - # is released with this fix, can change to @v2. - uses: conda-incubator/setup-miniconda@1a875d105ac03256664b54c882c8c374ce617ef6 + if: matrix.conda + uses: conda-incubator/setup-miniconda@v2 with: auto-update-conda: true python-version: ${{ matrix.python }} architecture: ${{ matrix.arch }} miniconda-version: "latest" - - name: Workaround conda-build incompatibility with xcode >12 + - name: Workaround conda-build incompatibility with xcode 12+ if: runner.os == 'macOS' uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: 11.7 - name: Conda package (Unix) - if: runner.os != 'Windows' + if: (matrix.conda && runner.os != 'Windows') shell: bash -l {0} run: | conda install -c labscript-suite setuptools-conda setuptools-conda build $CONDA_BUILD_ARGS . - name: Conda Package (Windows) - if: runner.os == 'Windows' + if: (matrix.conda && runner.os == 'Windows') shell: cmd /C CALL {0} run: | conda install -c labscript-suite setuptools-conda && ^ setuptools-conda build %CONDA_BUILD_ARGS% --croot ${{ runner.temp }}\cb . - name: Upload Artifact + if: matrix.conda uses: actions/upload-artifact@v3 with: name: conda_packages @@ -161,7 +165,7 @@ jobs: if: env.PURE == 'false' uses: RalfG/python-wheels-manylinux-build@v0.4.2 with: - python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' + python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311' pre-build-command: 'git config --global --add safe.directory "*"' - name: Upload Artifact @@ -189,45 +193,34 @@ jobs: name: conda_packages path: ./conda_packages - - name: Publish on TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.testpypi }} - repository_url: https://test.pypi.org/legacy/ - - name: Get Version Number if: github.event.ref_type == 'tag' run: | VERSION="${GITHUB_REF/refs\/tags\/v/}" echo "VERSION=$VERSION" >> $GITHUB_ENV - - name: Create GitHub Release + - name: Create GitHub Release and Upload Release Asset if: github.event.ref_type == 'tag' - id: create_release - uses: actions/create-release@latest + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.event.ref }} - release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} draft: true prerelease: ${{ contains(github.event.ref, 'rc') }} + files: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz - - name: Upload Release Asset - if: github.event.ref_type == 'tag' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish on TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz - asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz - asset_content_type: application/gzip + user: __token__ + password: ${{ secrets.testpypi }} + repository-url: https://test.pypi.org/legacy/ - name: Publish on PyPI if: github.event.ref_type == 'tag' - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi }} diff --git a/labscript_utils/qtwidgets/dragdroptab.py b/labscript_utils/qtwidgets/dragdroptab.py index f554718..691170a 100644 --- a/labscript_utils/qtwidgets/dragdroptab.py +++ b/labscript_utils/qtwidgets/dragdroptab.py @@ -316,7 +316,9 @@ def updateCurrentTime(self, current_time): if dy * (target_pos_y - new_pos_y) < 0: new_pos_y = target_pos_y - self.limbo_position = QPoint(new_pos_x, new_pos_y) + self.limbo_position = QPoint( + int(round(new_pos_x)), int(round(new_pos_y)) + ) else: self.limbo.animation_over() self.limbo = None diff --git a/labscript_utils/shot_utils.py b/labscript_utils/shot_utils.py new file mode 100644 index 0000000..aaccced --- /dev/null +++ b/labscript_utils/shot_utils.py @@ -0,0 +1,37 @@ +##################################################################### +# # +# __init__.py # +# # +# Copyright 2013, Monash University # +# # +# This file is part of the labscript suite (see # +# http://labscriptsuite.org) and is licensed under the Simplified # +# BSD License. See the license.txt file in the root of the project # +# for the full license. # +# # +##################################################################### + +import h5py +import numpy as np + +def get_shot_globals(filepath): + """Returns the evaluated globals for a shot, for use by labscript or lyse. + Simple dictionary access as in dict(h5py.File(filepath).attrs) would be fine + except we want to apply some hacks, so it's best to do that in one place.""" + params = {} + with h5py.File(filepath, 'r') as f: + for name, value in f['globals'].attrs.items(): + # Convert numpy bools to normal bools: + if isinstance(value, np.bool_): + value = bool(value) + # Convert null HDF references to None: + if isinstance(value, h5py.Reference) and not value: + value = None + # Convert numpy strings to Python ones. + # DEPRECATED, for backward compat with old files. + if isinstance(value, np.str_): + value = str(value) + if isinstance(value, bytes): + value = value.decode() + params[name] = value + return params \ No newline at end of file diff --git a/labscript_utils/splash.py b/labscript_utils/splash.py index 3aecf8a..e00c892 100644 --- a/labscript_utils/splash.py +++ b/labscript_utils/splash.py @@ -29,6 +29,15 @@ Qt = QtCore.Qt +# Set auto high-DPI scaling - this ensures pixel metrics are scaled +# appropriately so that we don't get a weird mix of large fonts and small +# everything else on High DPI displays: +QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) +# Use high res pixmaps if available, instead of rendering at low resolution and +# upscaling: +QtWidgets.QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True) + + class Splash(QtWidgets.QFrame): w = 250 h = 230 diff --git a/setup.cfg b/setup.cfg index 4fa4a89..399299e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,8 @@ classifiers = Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 [options] zip_safe = False From 8b5997c2d09db4efec8c367705851ead0ab5ac68 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Wed, 10 May 2023 10:05:04 +1000 Subject: [PATCH 2/2] pyzmq 25 compatibility Handle a new keyword argument to `Context.socket` in our subclass. --- labscript_utils/ls_zprocess.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/labscript_utils/ls_zprocess.py b/labscript_utils/ls_zprocess.py index 802e229..f3f2021 100644 --- a/labscript_utils/ls_zprocess.py +++ b/labscript_utils/ls_zprocess.py @@ -18,7 +18,7 @@ import zprocess import zprocess.process_tree -from zprocess.security import SecureContext +from zprocess.security import SecureContext, SecureSocket from labscript_utils.labconfig import LabConfig from labscript_utils import dedent import zprocess.zlog @@ -248,10 +248,19 @@ def instance(cls): # Super required to call unbound class method of parent class: return super(Context, cls).instance(shared_secret=config['shared_secret']) - def socket(self, *args, **kwargs): - config = get_config() - kwargs['allow_insecure'] = config['allow_insecure'] - return SecureContext.socket(self, *args, **kwargs) + def socket(self, socket_type, socket_class=None, **kwargs): + # socket_class kwarg introduced in pyzmq 25. Pass it through if it was given, + # otherwise don't. + if socket_class is not None: + kwargs['socket_class'] = socket_class + # Only insert our security-related args to the socket if we know it's going to + # be a SecureSocket. If caller has explicitly requested a different socket type + # (e.g since pyzmq 25, ThreadAuthenticator sets up an internal socket by calling + # `Context.socket(..., socket_class=zmq.Socket)), then don't.` + if socket_class is None or issubclass(socket_class, SecureContext): + config = get_config() + kwargs['allow_insecure'] = config['allow_insecure'] + return SecureContext.socket(self, socket_type=socket_type, **kwargs) def Lock(*args, **kwargs): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy