scripted-diff: Specify Python major version explicitly on Windows #28213

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:230803-py-win changing 2 files +4 −4
  1. hebasto commented at 7:48 pm on August 3, 2023: member

    On Windows, it is the accepted practice to use py.exe launcher:

    One of its features is the correct handling of shebang lines like the one we use: #!/usr/bin/env python3.

    However, Windows OS app execution aliases might interfere with the launcher’s behaviour. Such aliases are enabled on Windows 11 by default:

    image

    For example, on a fresh Windows 11 Pro installation with the Python installed from the Chocolatey package manager, one will get the following error:

     0>py -3 test\functional\rpc_signer.py
     12023-08-03T19:41:13.353000Z TestFramework (INFO): PRNG seed is: 2694758731106548661
     22023-08-03T19:41:13.353000Z TestFramework (INFO): Initializing test directory C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3
     32023-08-03T19:41:14.538000Z TestFramework (ERROR): Assertion failed
     4Traceback (most recent call last):
     5  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 140, in try_rpc
     6    fun(*args, **kwds)
     7  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\coverage.py", line 50, in __call__
     8    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
     9                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    10  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\authproxy.py", line 129, in __call__
    11    raise JSONRPCException(response['error'], status)
    12test_framework.authproxy.JSONRPCException: RunCommandParseJSON error: process(py C:\Users\hebasto\bitcoin\test\functional\mocks\signer.py enumerate) returned 9009: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
    13 (-1)
    14
    15During handling of the above exception, another exception occurred:
    16
    17Traceback (most recent call last):
    18  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\test_framework.py", line 131, in main
    19    self.run_test()
    20  File "C:\Users\hebasto\bitcoin\test\functional\rpc_signer.py", line 72, in run_test
    21    assert_raises_rpc_error(-1, 'fingerprint not found',
    22  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 131, in assert_raises_rpc_error
    23    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
    24           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    25  File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 146, in try_rpc
    26    raise AssertionError(
    27AssertionError: Expected substring not found in error message:
    28substring: 'fingerprint not found'
    29error message: 'RunCommandParseJSON error: process(py C:\Users\hebasto\bitcoin\test\functional\mocks\signer.py enumerate) returned 9009: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
    30'.
    312023-08-03T19:41:14.592000Z TestFramework (INFO): Stopping nodes
    322023-08-03T19:41:14.799000Z TestFramework (WARNING): Not cleaning up dir C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3
    332023-08-03T19:41:14.799000Z TestFramework (ERROR): Test failed. Test logging available at C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3/test_framework.log
    342023-08-03T19:41:14.799000Z TestFramework (ERROR):
    352023-08-03T19:41:14.799000Z TestFramework (ERROR): Hint: Call C:\Users\hebasto\bitcoin\test\functional\combine_logs.py 'C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3' to consolidate all logs
    362023-08-03T19:41:14.799000Z TestFramework (ERROR):
    372023-08-03T19:41:14.799000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
    382023-08-03T19:41:14.799000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
    392023-08-03T19:41:14.799000Z TestFramework (ERROR):
    

    This PR resolves this issue by explicitly specifying the Python major version and makes testing of self-compiled binaries more straightforward.

  2. scripted-diff: Specify Python major version explicitly on Windows
    Using `py.exe` launcher might by fragile depending on how Python was
    installed. Specifying the Python version explicitly fixes test errors
    like this:
    ```
    RunCommandParseJSON error: process(py C:\Users\hebasto\bitcoin\test\functional\mocks\signer.py enumerate) returned 9009: Python was not found...
    ```
    
    -BEGIN VERIFY SCRIPT-
    sed -i 's|"py "|"py -3 "|g' $(git grep -l '"py "' -- test/functional)
    -END VERIFY SCRIPT-
    6a7686b446
  3. hebasto added the label Windows on Aug 3, 2023
  4. hebasto added the label Tests on Aug 3, 2023
  5. DrahtBot commented at 7:48 pm on August 3, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK MarcoFalke, stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. ViljoPennanen approved
  7. ViljoPennanen commented at 8:38 pm on August 3, 2023: none
    lgtm
  8. maflcko commented at 5:30 am on August 4, 2023: member
    lgtm ACK 6a7686b44618eabd2f8ee9f1d357cfeb1bce6d91
  9. stickies-v approved
  10. stickies-v commented at 12:01 pm on August 4, 2023: contributor
    utACK 6a7686b44618eabd2f8ee9f1d357cfeb1bce6d91
  11. fanquake merged this on Aug 4, 2023
  12. fanquake closed this on Aug 4, 2023

  13. hebasto deleted the branch on Aug 4, 2023
  14. sidhujag referenced this in commit 32b54945a5 on Aug 9, 2023
  15. bitcoin locked this on Aug 3, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me