8000 gh-115554: Improved logic for handling multiple existing py.exe launcher installs by zooba · Pull Request #115793 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115554: Improved logic for handling multiple existing py.exe launcher installs #115793

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

Merged
merged 5 commits into from
Mar 1, 2024

Conversation

zooba
Copy link
Member
@zooba zooba commented Feb 21, 2024

@zooba zooba marked this pull request as ready for review February 22, 2024 23:34
@zooba zooba requested a review from a team as a code owner February 22, 2024 23:34
@zooba zooba added OS-windows needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 23, 2024
Copy link
Member
@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

at a high level I think this makes sense. I can look past the specific api c++ boilerplate for what really seems to just be a way to spell get and set these variables from the whatever-script maybe functionalish installer state machine runtime ultimately running this logic.

My comments are mostly code stuff, I trust that this does what it describes itself as doing. But I'm definitely not a windows installer expert (I last created one over 20 years ago).

// User can deselect the option to include the launcher, but cannot
// change it from the current per user/machine setting.
LONGLONG includeLauncher, includeLauncherAllUsers;
if (FAILED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))) {
Copy link
Member

Choose a reason for hiding this comment

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

The _ in that L" Variable name when most others don't appear use that style it is unfortunate... but i'm guessing this comes from elsewhere in the XML definition or whatnot and is just style would require larger refactoring beyond the scope of this PR better done as its own no-functionality change if ever.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's actually consistent with the other Include_<name> variables, which all refer to a <name>.msi file. It's just none of the others need to be referenced as much because they're all easy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here they are all in a list:

<Variable Name="Include_core" Value="1" />
<Variable Name="Include_exe" Value="1" bal:Overridable="yes" />
<Variable Name="Include_dev" Value="1" bal:Overridable="yes" />
<Variable Name="Include_lib" Value="1" bal:Overridable="yes" />
<Variable Name="Include_test" Value="1" bal:Overridable="yes" />
<Variable Name="Include_doc" Value="1" bal:Overridable="yes" />
<Variable Name="Include_tools" Value="0" bal:Overridable="yes" />
<Variable Name="Include_tcltk" Value="1" bal:Overridable="yes" />
<Variable Name="Include_pip" Value="1" bal:Overridable="yes" />
<Variable Name="Include_launcher" Value="-1" bal:Overridable="yes" />

Copy link
Contributor
@itamaro itamaro left a comment

Choose a reason for hiding this comment

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

this seems a bit convoluted and hard to follow (maybe a combination of installer-toolkit-isms and non-trivial business logic) -- it might benefit from a flowchart!

can you clarify what would be the behavior when both 3.12.1 & 3.11.5 are installed, and we attempt to upgrade both to 3.12.2 & 3.11.8? (arbitrary patch releases)
in particular, I'm curious about the scenario of unattended installations that attempt to upgrade both (and can happen in unspecified order on different machines).

@zooba
Copy link
Member Author
zooba commented Feb 29, 2024

this seems a bit convoluted and hard to follow

Agreed! It hurt my head figuring out the right places to put the logic.

can you clarify what would be the behavior when both 3.12.1 & 3.11.5 are installed, and we attempt to upgrade both to 3.12.2 & 3.11.8? (arbitrary patch releases)

So the important aspect for this change isn't which Python version(s) are installed, but which launcher version. There's only one launcher installer, so there should only ever be one version installed. Multiple is a bad enough error that we now refuse to do anything.

If we assume 3.12.1 and 3.11.5 are installed correctly, then launcher 3.12.1 will be installed. If we then install 3.11.8, it'll compare its launcher 3.11.8 to 3.12.1 and decide that's a downgrade, and so will take the downgrade path in the new code (which deselects the launcher and disables the controls).

If we're installing 3.12.2, it'll compare its launcher 3.12.2 to 3.12.1 and decide it's a major upgrade, and so will select the launcher and update the "launcher for all users" option to match the existing install (but only if the option wasn't specified on the command line, in which case we disable the launcher entirely if they conflict).

If a second launcher is installed, this typically means one is per-user and one is per-machine, which we can't handle, so we block the launcher install entirely. This will update the checkbox on the main page to say that the launcher has to be uninstalled in order to update.

If no launchers are detected, we update the default options (-1) to what we want for our standard default (i.e. to include the launcher). It's possible to override these on the command line though, so we want to respect those selections.

It's not much of a flowchart, but you can probably imagine "OnPackageDetected" getting called once for every package that's already installed, and "OnDetectionComplete" being called once at the end.

Copy link
Contributor
@itamaro itamaro left a comment

Choose a reason for hiding this comment

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

the Windows installer could probably benefit from an end-to-end test suite, with all the complexity and possible scenarios, but I can't imagine writing such a test suite would be easy, and it'll probably be excruciatingly slow and flaky...

@zooba
Copy link
Member Author
zooba commented Mar 1, 2024

I can't imagine writing such a test suite would be easy, and it'll probably be excruciatingly slow and flaky...

I just tried getting the smoke tests that are part of the installer build to run more reliably (GitHub installs Python on the build machines, so the installers can't really be tested when they're already installed 😅) and yeah, slow and flaky. But we do run the basics through their paces on every release - just not through every possible combination.

However, most combinations shouldn't have interactions, and the problems almost always come up because of preexisting things on peoples' machines, and not because of the installer itself. So it becomes a case of scripting the setup of broken machines so that we can run the test and ... err... yeah... it's a huge amount of work for not actually a lot of benefit.

@zooba zooba merged commit 9b7f253 into python:main Mar 1, 2024
@miss-islington-app
< 8000 details-menu class="dropdown-menu dropdown-menu-sw show-more-popover color-fg-default" style="width:185px" src="" preload > Copy link

Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@zooba zooba deleted the gh-115554 branch March 1, 2024 12:58
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 1, 2024
… launcher installs (pythonGH-115793)

(cherry picked from commit 9b7f253)

Co-authored-by: Steve Dower <steve.dower@python.org>
@miss-islington-app
Copy link

Sorry, @zooba, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 9b7f253b55f10df03d43c8a7c2da40ea523ac7a1 3.11

@bedevere-app
Copy link
bedevere-app bot commented Mar 1, 2024

GH-116200 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 1, 2024
@bedevere-app
Copy link
bedevere-app bot commented Mar 1, 2024

GH-116201 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Mar 1, 2024
zooba added a commit to zooba/cpython that referenced this pull request Mar 1, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows11 Non-Debug 3.x has failed when building commit 9b7f253.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/914/builds/3574) and take a look at the build logs.
  4. Check if the failure is related to this commit (9b7f253) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/914/builds/3574

Failed tests:

  • test_wmi

Failed subtests:

  • test_wmi_query_threads - test.test_wmi.WmiTests.test_wmi_query_threads

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "b:\uildarea\3.x.ware-win11.nondebug\build\Lib\test\test_wmi.py", line 86, in test_wmi_query_threads
    self.assertRegex(t.result(), "ProcessId=")
                     ~~~~~~~~^^
  File "b:\uildarea\3.x.ware-win11.nondebug\build\Lib\concurrent\futures\_base.py", line 456, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "b:\uildarea\3.x.ware-win11.nondebug\build\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "b:\uildarea\3.x.ware-win11.nondebug\build\Lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "b:\uildarea\3.x.ware-win11.nondebug\build\Lib\test\test_wmi.py", line 16, in wmi_exec_query
    return _wmi.exec_query(query)
           ~~~~~~~~~~~~~~~^^^^^^^
BrokenPipeError: [WinError -2147024664] The pipe is being closed

woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
zooba added a commit that referenced this pull request Mar 5, 2024
…her installs (GH-115793)

(cherry picked from commit 9b7f253)

Co-authored-by: Steve Dower <steve.dower@python.org>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0