Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PyQt5 #610

Merged
merged 1 commit into from
Sep 11, 2020
Merged

Add support for PyQt5 #610

merged 1 commit into from
Sep 11, 2020

Conversation

eloquence
Copy link
Member

@eloquence eloquence commented Sep 4, 2020

Status

Ready for review

Description of Changes

Fixes #607.

Uses the appropriate Qt version:

  • Qt4 on Qubes 4.0
  • Qt5 on Qubes 4.1, or if SDW_UPDATER_QT=5 is set
  • Qt4 on other operating systems.

Adds PyQt5 to dev-requirements.txt (renamed from test-requirements.txt for consistency with https://github.com/freedomofpress/securedrop-workstation/blob/main/dev-requirements.txt).

NOTE: Once this PR is merged, the Qt5 version of the UI will need to be regenerated along with the Qt4 version every time sdw_updater.ui is modified, using pyuic5.

Test plan

Qubes 4.0

  1. Copy this branch into dom0 in a provisioned Qubes 4.0 SDW development or staging environment
  2. Run the updater via python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater runs as before.
  1. Run the updater via SDW_UPDATER_QT=5 python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater fails to run because Qt 5 is not installed.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via python3 launcher/sdw-notify.py
  • Observe that the update alert is shown as before.

Qubes 4.1 (nightly)

  1. Copy this branch into dom0 in a provisioned Qubes 4.1-nightly SDW development or staging environment
  2. Run the updater via python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater runs to completion with no graphical errors.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via python3 launcher/sdw-notify.py
  • Observe that the update alert is shown.

Development environment

  1. Activate a virtualenv and install the Qt5 requirements via pip install --require-hashes -r launcher/qt5-requirements.txt
  2. Run the updater via SDW_UPDATER_QT=5 python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater starts (you won't be able to run it), and that your terminal indicates that Qt5 is used.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via SDW_UPDATER_QT=5 python3 launcher/sdw-notify.py
  • Observe that the update alert is shown. (NB: The notifier checks for process contention with make, so if nothing appears, that may be because you have a dev env running -- check sdw-notify.log in ~/.securedrop_launcher if in doubt)

@eloquence eloquence marked this pull request as ready for review September 9, 2020 01:11
Copy link
Contributor

@emkll emkll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eloquence, tested in both Qubes 4.1 and 4.0.3, and very pleased to report that the changes changes work as expected 🎉

Changes work well in Qubes 4.0. In 4.1 I did observe a popup (see below) , but these changes are very likely unrelated to the changes introduced here. I will add a note in #600
whonix-rpc-error

A couple of comments inline

Test plan

Qubes 4.0

  1. Copy this branch into dom0 in a provisioned Qubes 4.0 SDW development or staging environment
  2. Run the updater via python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater runs as before.
  1. Run the updater via SDW_UPDATER_QT=5 python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater fails to run because Qt 5 is not installed.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via python3 launcher/sdw-notify.py
  • Observe that the update alert is shown as before.

Qubes 4.1 (nightly)

  1. Copy this branch into dom0 in a provisioned Qubes 4.1-nightly SDW development or staging environment
  2. Run the updater via python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater runs to completion with no graphical errors.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via python3 launcher/sdw-notify.py
  • Observe that the update alert is shown.

Development environment

  1. Activate a virtualenv and install the Qt5 requirements via pip install --require-hashes -r launcher/qt5-requirements.txt
  2. Run the updater via SDW_UPDATER_QT=5 python3 launcher/sdw-launcher.py --skip-delta 0
  • Observe that the updater starts (you won't be able to run it), and that your terminal indicates that Qt5 is used.
  1. Remove the file ~/.securedrop_launcher/sdw-last-updated
  2. Ensure that your system uptime is at least 30 minutes.
  3. Run the notify script via SDW_UPDATER_QT=5 python3 launcher/sdw-notify.py
  • Observe that the update alert is shown. (NB: The notifier checks for process contention with make, so if nothing appears, that may be because you have a dev env running -- check sdw-notify.log in ~/.securedrop_launcher if in doubt)

Activate a virtualenv and intall the requirements using the following
command:

pip install --require-hashes -r qt5-requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these requirements strictly required here? In my dev vm (Debian 10) I can run the launcher with QT4 and QT5 outside a virtualenv with no dependencies, using system-level qt packages. Is there a reason we should treat qt5 as a special case and track requirements ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason I think this may make sense is so that we all use a predictable version of PyQt during development, with a defined hash, which could be important during debugging. (For now it will fetch the same version as we use with securedrop-client, but ideally it should match whatever is shipped with Qubes 4.1.) This was not an option for PyQt4, which is no longer available via pypi.org, but it is an option for PyQt5.

We could consolidate test-requirements.txt and qt5-requirements.txt into a single dev-requirements.txt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we aren't shipping/packaging/locking the PyQT dependency in dom0, I don't see the value in locking for development environment consistency (especially since we are using OS level packages)
However, locking for testing consistency makes sense here (since it will run both on developer machines but also in CI). Adding it to test-requirements (and optionally renaming, no strong preference here) sounds like a good approach to me

Copy link
Member Author

@eloquence eloquence Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored accordingly. I cheated by not updating all requirements but only inserting the up-to-date PyQt5 requirements into dev-requirements.txt. (Updating all requirements will pull in a new version of black that'll require formatting changes.) Once this PR lands I think it'd be good idea to do a requirements refresh for both preflight updater & main repo requirements.

Comment on lines +127 to +128
except ValueError:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest is telling me that these two lines don't have test coverage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a bad-file-format fixture for this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fd6b824

Also adds PyQt5 to shared requirements file and renames it to
dev-requirements.txt for consistency.
Copy link
Contributor

@emkll emkll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @eloquence . Successfully went though another test plan in both 4.0.3 (Fedora 25) and 4.1 (Fedora 32) using RPMs (opened #611 to track F32 build issues). I didn't see the error I initially reported, but we are tracking that issue separately anyways.
Given the changes here and the comprehensive test coverage, the impact to the Fedora 25 logic is very minimal.

@@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emkll emkll merged commit b180a5a into main Sep 11, 2020
@emkll emkll deleted the 607-qt5 branch September 11, 2020 19:12
cfm pushed a commit that referenced this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port preflight updater to Qt5
2 participants