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/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): 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
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: