On Windows, it is the accepted practice to use py.exe
launcher:
- https://learn.microsoft.com/en-us/windows/python/faqs#what-is-py-exe-
- https://docs.python.org/3/using/windows.html#python-launcher-for-windows
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:
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.