From 96b6f7d006508a8d53a68d15f7470668f7b93313 Mon Sep 17 00:00:00 2001 From: Martin Urban Date: Sun, 6 Jul 2025 12:00:23 +0200 Subject: [PATCH 1/2] Add high DPI support for the PyMOL openGL widget --- .github/workflows/nightly_wheels.yaml | 200 ++++++++++++++++++++++++++ modules/pmg_qt/pymol_gl_widget.py | 9 +- 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/nightly_wheels.yaml diff --git a/.github/workflows/nightly_wheels.yaml b/.github/workflows/nightly_wheels.yaml new file mode 100644 index 000000000..011056d83 --- /dev/null +++ b/.github/workflows/nightly_wheels.yaml @@ -0,0 +1,200 @@ +#A* ------------------------------------------------------------------- +#B* This file contains source code for running a GitHub automation +#-* related to the build process of the PyMOL computer program +#C* Copyright 2025 by Martin Urban. +#D* ------------------------------------------------------------------- +#E* It is unlawful to modify or remove this copyright notice. +#F* ------------------------------------------------------------------- +#G* Please see the accompanying LICENSE file for further information. +#H* ------------------------------------------------------------------- +#I* Additional authors of this source file include: +#-* +#-* +#-* +#Z* ------------------------------------------------------------------- +name: Build Wheels + +on: + push: + branches: + - unstable + +env: + VCPKG_ROOT: ${{ github.workspace }}/vendor/vcpkg + +jobs: + # ----- Windows build section + build-windows: + strategy: + fail-fast: false + matrix: + win_arch: ['x86', 'x64'] + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Initialize vcpkg + run: | + git clone https://github.com/Microsoft/vcpkg.git vendor/vcpkg + + - name: Setup Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Create virtual environment + run: | + python -m venv .venv + call .venv\Scripts\activate.bat + python -m pip install --upgrade setuptools pip wheel build cibuildwheel + python -m pip install delvewheel + python -m pip install -r requirements.txt + shell: cmd + + - name: Bootstrap vcpkg + run: ${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.bat -disableMetrics + + - name: Last build environment setup steps + run: | + call .venv\Scripts\activate.bat + python automations\my_automator.py setup dev-env + shell: cmd + + - name: Build x86 C extension + if: ${{ matrix.win_arch == 'x86' }} + run: | + ${{ env.VCPKG_ROOT }}/vcpkg install --triplet=x86-windows-static + call .venv\Scripts\activate.bat + set WIN_ARCH=x86 + cibuildwheel . --platform windows --archs x86 + shell: cmd + + - name: Build x64 C extension + if: ${{ matrix.win_arch == 'x64' }} + run: | + ${{ env.VCPKG_ROOT }}/vcpkg install --triplet=x64-windows-static + call .venv\Scripts\activate.bat + set WIN_ARCH=x64 + cibuildwheel . --platform windows --archs AMD64 + shell: cmd + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: PyMOL-wheel-Windows-${{ matrix.win_arch }}-3.11 + path: ./wheelhouse/*.whl + # --- end + + # ----- macOS build section + build-macos: + strategy: + fail-fast: false + matrix: + os: [ macos-13, macos-14 ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Initialize vcpkg + run: | + git clone https://github.com/Microsoft/vcpkg.git vendor/vcpkg + + - name: Setup Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Create virtual environment + run: | + python -m venv .venv + source .venv/bin/activate + python -m pip install wheel setuptools cibuildwheel + python -m pip install -r requirements.txt + + - name: Bootstrap vcpkg + run: ${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh -disableMetrics + + - name: Install vcpkg dependencies + run: | + ${{ env.VCPKG_ROOT }}/vcpkg install + + - name: Last build environment setup steps + run: | + source .venv/bin/activate + python automations/my_automator.py setup dev-env + + - name: Build C extension + run: | + source .venv/bin/activate + python automations/my_automator.py setup dev-env + export ARCH=$(uname -m) + export MACOSX_DEPLOYMENT_TARGET=12.0 + cibuildwheel . + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: PyMOL-wheel-${{ matrix.os }}-3.11 + path: ./wheelhouse/*.whl + # --- end + + # ----- GNU Linux build section + build-gnu-linux: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install git build-essential libxmu-dev libxi-dev libgl-dev libglew-dev libpng-dev libfreetype6-dev libxml2-dev libmsgpack-dev libglm-dev libnetcdf-dev linux-libc-dev autoconf perl + + - name: Initialize vcpkg + run: | + git clone https://github.com/Microsoft/vcpkg.git vendor/vcpkg + + - name: Setup Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Create virtual environment + run: | + python -m venv .venv + source .venv/bin/activate + python -m pip install wheel setuptools cibuildwheel + python -m pip install -r requirements.txt + + - name: Bootstrap vcpkg + run: ${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh -disableMetrics + + - name: Install vcpkg dependencies + run: | + ${{ env.VCPKG_ROOT }}/vcpkg install + + - name: Last build environment setup steps + run: | + source .venv/bin/activate + python automations/my_automator.py setup dev-env + + - name: Build C extension + run: | + source .venv/bin/activate + python automations/my_automator.py setup dev-env + cibuildwheel . + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: PyMOL-wheel-GNU-Linux-3.11 + path: ./wheelhouse/*.whl + # --- end diff --git a/modules/pmg_qt/pymol_gl_widget.py b/modules/pmg_qt/pymol_gl_widget.py index 44b95822a..ac796956d 100644 --- a/modules/pmg_qt/pymol_gl_widget.py +++ b/modules/pmg_qt/pymol_gl_widget.py @@ -63,7 +63,14 @@ def __exit__(self, exc_type, exc_value, traceback): def __init__(self, parent): self.gui = parent - self.fb_scale = 1.0 + app = QtWidgets.QApplication.instance() + if app: + screen = app.primaryScreen() + # use the screen's devicePixelRatio as framebuffer scale factor necessary for PyQt6 high DPI support + self.fb_scale = screen.devicePixelRatio() + else: + # fallback if no QApplication instance is available + self.fb_scale = 1.0 # OpenGL context setup if USE_QOPENGLWIDGET: From 45547918fc50476c57902a0a8d3772e8d53e90cb Mon Sep 17 00:00:00 2001 From: Martin Urban Date: Sun, 6 Jul 2025 12:37:37 +0200 Subject: [PATCH 2/2] Update workflow name and bump version for nightly builds Renamed the GitHub workflow to "Build Nightly Wheels" for better clarity and updated the version in pyproject.toml to "3.1.0.4a1+1" to reflect a nightly build. These changes ensure proper identification of nightly artifacts and align with versioning standards. --- .github/workflows/nightly_wheels.yaml | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightly_wheels.yaml b/.github/workflows/nightly_wheels.yaml index 011056d83..f5feb3dbc 100644 --- a/.github/workflows/nightly_wheels.yaml +++ b/.github/workflows/nightly_wheels.yaml @@ -12,7 +12,7 @@ #-* #-* #Z* ------------------------------------------------------------------- -name: Build Wheels +name: Build Nightly Wheels on: push: @@ -84,7 +84,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: PyMOL-wheel-Windows-${{ matrix.win_arch }}-3.11 + name: PyMOL-wheel-Windows-${{ matrix.win_arch }}-nightly path: ./wheelhouse/*.whl # --- end @@ -140,7 +140,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: PyMOL-wheel-${{ matrix.os }}-3.11 + name: PyMOL-wheel-${{ matrix.os }}-nightly path: ./wheelhouse/*.whl # --- end @@ -195,6 +195,6 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: PyMOL-wheel-GNU-Linux-3.11 + name: PyMOL-wheel-GNU-Linux-nightly path: ./wheelhouse/*.whl # --- end diff --git a/pyproject.toml b/pyproject.toml index e57e73057..f3bb8ccd8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "scikit_build_core.build" [project] name = "pymol-open-source-whl" readme = "README.md" -version = "3.1.0.4" +version = "3.1.0.4a1+1" requires-python = ">=3.10" license = {file = "LICENSE"} #description = """