Skip to content

Commit d096743

Browse files
committed
Merge bitcoin#28213: scripted-diff: Specify Python major version explicitly on Windows
6a7686b scripted-diff: Specify Python major version explicitly on Windows (Hennadii Stepanov) Pull request description: 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](https://learn.microsoft.com/en-us/windows/python/faqs#why-does-running-python-exe-open-the-microsoft-store-) with the launcher's behaviour. Such aliases are enabled on Windows 11 by default: ![image](https://github.com/bitcoin/bitcoin/assets/32963518/407837ec-e89a-4bc1-98b1-db983002065a) For example, on a fresh Windows 11 Pro installation with the Python installed from the [Chocolatey](https://community.chocolatey.org/packages/python/3.11.4) package manager, one will get the following error: ``` >py -3 test\functional\rpc_signer.py 2023-08-03T19:41:13.353000Z TestFramework (INFO): PRNG seed is: 2694758731106548661 2023-08-03T19:41:13.353000Z TestFramework (INFO): Initializing test directory C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3 2023-08-03T19:41:14.538000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 140, in try_rpc fun(*args, **kwds) File "C:\Users\hebasto\bitcoin\test\functional\test_framework\coverage.py", line 50, in __call__ return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hebasto\bitcoin\test\functional\test_framework\authproxy.py", line 129, in __call__ raise JSONRPCException(response['error'], status) test_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. (-1) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\hebasto\bitcoin\test\functional\test_framework\test_framework.py", line 131, in main self.run_test() File "C:\Users\hebasto\bitcoin\test\functional\rpc_signer.py", line 72, in run_test assert_raises_rpc_error(-1, 'fingerprint not found', File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 131, in assert_raises_rpc_error assert try_rpc(code, message, fun, *args, **kwds), "No exception raised" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hebasto\bitcoin\test\functional\test_framework\util.py", line 146, in try_rpc raise AssertionError( AssertionError: Expected substring not found in error message: substring: 'fingerprint not found' error 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. '. 2023-08-03T19:41:14.592000Z TestFramework (INFO): Stopping nodes 2023-08-03T19:41:14.799000Z TestFramework (WARNING): Not cleaning up dir C:\Users\hebasto\AppData\Local\Temp\bitcoin_func_test_mldbzzw3 2023-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 2023-08-03T19:41:14.799000Z TestFramework (ERROR): 2023-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 2023-08-03T19:41:14.799000Z TestFramework (ERROR): 2023-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. 2023-08-03T19:41:14.799000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues 2023-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. ACKs for top commit: MarcoFalke: lgtm ACK 6a7686b stickies-v: utACK 6a7686b Tree-SHA512: 5681141e222bc833c6250cb79fe3a1c8e02255eb2c86010bc0f8239afcdfed784ed7788c8579209d931bd357f58d5655cf33ffeb2f46b1879f37cdc30e7a7c91
2 parents f138422 + 6a7686b commit d096743

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/functional/rpc_signer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RPCSignerTest(BitcoinTestFramework):
2121
def mock_signer_path(self):
2222
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py')
2323
if platform.system() == "Windows":
24-
return "py " + path
24+
return "py -3 " + path
2525
else:
2626
return path
2727

test/functional/wallet_signer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ def add_options(self, parser):
2525
def mock_signer_path(self):
2626
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py')
2727
if platform.system() == "Windows":
28-
return "py " + path
28+
return "py -3 " + path
2929
else:
3030
return path
3131

3232
def mock_invalid_signer_path(self):
3333
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'invalid_signer.py')
3434
if platform.system() == "Windows":
35-
return "py " + path
35+
return "py -3 " + path
3636
else:
3737
return path
3838

3939
def mock_multi_signers_path(self):
4040
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'multi_signers.py')
4141
if platform.system() == "Windows":
42-
return "py " + path
42+
return "py -3 " + path
4343
else:
4444
return path
4545

0 commit comments

Comments
 (0)