rokm · GitHub

@rokm

@rokm

rokm marked this pull request as ready for review

August 3, 2021 20:34

@rokm

bwoodsend

@rokm

bwoodsend

@rokm

The new helper, pyi_utils_append_to_args, reallocates the private
pyi_argv array, appends a copy of given argument to it, and
increments pyi_argc accordingly.
Have the Apple Event handling / argv emulation use this helper
instead of directly manipulating pyi_argv and pyi_argc.
This is a prerequisite for moving Apple Event handling code to
a separate .c file.
Allows retrieval of child_pid outside of the pyi_utils.c.
Have Apple Event handling use this helper instead of directly
accessing child_pid.
This is a prerequisite for moving Apple Event handling code to
a separate .c file.
Apparently the compiler doesn't like us casting from void * pointer
to 32-bit integer. Do an intermediate cast to intptr_t to assure
the compiler that we in fact do know what we are doing here...
Disable it by default; it should be explicitly enabled via
pyi-macos-argv-emulation bootloader flag. This is controlled
by argv_emulation argument to EXE(), which in turn can also
be enabled via --argv-emulation command-line flag.
Enable argv emulation for test_osx_custom_protocol_handler and
test_osx_event_forwarding, because they explicitly test for this
behavior.
Instead of specifying timeout value of 1 second, use kAEDefaultTimeout.
When AESendMessage is called with kAENoReply, the timeout is not
applicable, anyway.
A race condition between parent and child process in onefile
application's during start-up sequence may lead to loss of
Apple Events, if those events are available in the time window
between the point where child_pid becomes valid (i.e., fork() call)
and the point where child process actually becomes able to receive
Apple Events. In that window, attempting to forward the events
results in error -600 (procNotFound).
To work around this, we implement 10 retry attempts spaced apart
0.5 second, for total 5 seconds of retry time.
Split the event handler setup code into explicit installation
function, and implement its uninstallation counterpart. This
in turn simplifies the message pump function which now deals
only with event retrieval and processing.
The argument of message pump function has been changed from
short/long-timeout boolean to direct timeout value.
Add a dummy (no-op) handler for open application ('oapp') event;
just in case if it matters somewhere that it was in fact processed.
It is now safe to have support for argv emulation in onedir
macOS .app bundles, because it needs to be explicitly enabled,
and we can document potential issues when it is used in
combination with UI frameworks.
…mode
The argv-emu event processing swallows the initial activation
event (oapp if opened regularly, odoc/GURL if opened via open
file/URL request). Therefore, if we are performing argv-emu in
onedir mode, we submit our own oapp event to ourselves before
starting python interpreter. This makes onedir app bundles with
argv-emu enabled behave similarly to onefile bundles, where child
process always receives an oapp event (and therefore swallowing
activation event in parent process does not seem to cause any
problems).
This somewhat improves the situation with onedir bundles that have
argv-emu enabled and use Tcl/Tk 8.6.11 on Homebrew python 3.9.6;
instead of consistent crash at startup, we now crash only ocassionally.
Still, we should probably discourage argv-emu being used in
combination with UI frameworks, same as py2app do for their
argv-emulation.
Thoroughly test onedir and onefile bundle variant of Carbon-based
event logger, both with argv-emu enabled and disabled.
Initially, the idea was to implement different loggers to test with
(Carbon-based, tkinter-based, PyQt5-based), but that quickly devolved
into a maze of special handling for high-level toolkits' quirks.
So in the end, we test only with Carbon-based logger, which is
as low-level as it gets, intercepts raw Apple Events, and as such
offers us most insight into what is going on.
The new test_apple_event_handling_carbon effectively supersedes
both older Apple Events tests (test_osx_custom_protocol_handler and
test_osx_event_forwarding), as its corresponding variants test
both argv emulation and event forwarding.
So try to shorten the CI runtime by removing the now-redundant tests.

@rokm

@rokm

This was referenced

Aug 19, 2021

Closed

Closed

@rokm

rokm deleted the macos-argv-emulation branch

August 19, 2021 09:37

@rokm rokm mentioned this pull request

Aug 29, 2021

Merged

@rokm rokm mentioned this pull request

Dec 16, 2021

Merged

@rokm rokm mentioned this pull request

Jan 22, 2022

Merged

bwoodsend added a commit to bwoodsend/pyinstaller that referenced this pull request

Apr 19, 2022
Due to the issues_github_path configuration option not being set and our
previous practice of including the # in :issue:`#number`, all generated links
are set to https://github.com/{group}/{project}/issues/#6089 instead of
pyinstaller#6089
Fixing this requires bumping the sphinx-issues version to fix a bug surrounding
that configuration option (sloria/sphinx-issues#125), refactoring all uses of
:issue:`#number` to :issue:`number` and adjusting the towncrier template to do
likewise.

bwoodsend added a commit that referenced this pull request

Apr 19, 2022
Due to the issues_github_path configuration option not being set and our
previous practice of including the # in :issue:`#number`, all generated links
are set to https://github.com/{group}/{project}/issues/#6089 instead of
#6089
Fixing this requires bumping the sphinx-issues version to fix a bug surrounding
that configuration option (sloria/sphinx-issues#125), refactoring all uses of
:issue:`#number` to :issue:`number` and adjusting the towncrier template to do
likewise.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators

Nov 16, 2022

Read the original on github.com ↗