Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
There was a problem hiding this comment.
ACK bce6387
Tested on master (share/rpcauth/__pycache__ was generated when running rpcauth-test.py) and on the PR branch (share/rpcauth/__pycache__ was not generated).
Maybe it's doing this for contrib/devtools/test-security-check.py and test-symbol-check.py as well?
BrandonOdiwuor
left a comment
There was a problem hiding this comment.
Tested ACK bce6387
|
Friendly ping @stickies-v @maflcko :) |
|
CI is green and the diff looks reasonable, so I guess it is harmless and fine. Did you try setting the source dir read-only, and it passes with this change? |
Yes, it does. However, such a test is not very useful because Python just silently skips writing the bytecode cache if there are no write permissions. A more useful test can be conducted on a branch, which performs a full migration to CMake and cleans up all |
stickies-v
left a comment
There was a problem hiding this comment.
Concept ACK, the performance benefits of caching bytecode are irrelevant here so keeping a clean source dir seems preferable.
As an alternative approach, might it make more sense to use pycache_prefix so we can address this concern globally instead of just for this file, and in the build system code instead of leaking this into non-build system code? And that way we can keep the (in this case negligible) performance benefits of caching bytecode?
| with open(config_path, encoding="utf8") as config_file: | ||
| config.read_file(config_file) | ||
| sys.path.insert(0, os.path.dirname(config['environment']['RPCAUTH'])) | ||
| sys.dont_write_bytecode = True |
I did consider it. I have to admit that I failed to find a solution that touches only the build system code and works in all scenarios, including running functional tests individually. |
This change prevents writing `share/rpcauth/__pycache__/*.pyc`, which is especially useful for out-of-source builds when the source directory is supposed to be read-only.
bce6387 to
c91a10b
Compare
|
Addressed @stickies-v's #30533 (comment). |
I'm also not sure that's something we should be doing? Python programs creating pycache files is expected Python behaviour, and we can't control if/how/when users run Python programs. Users who wish to do so can easily avoid this caching behaviour in a multitude of ways, the shortest of which is running In that, vein, I think my preferred approach for git diff on c91a10bdiff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 3d04498369..43c4d25ed7 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -438,7 +438,7 @@ if BUILD_BITCOIN_TX
$(PYTHON) $(top_builddir)/test/util/test_runner.py
endif
@echo "Running test/util/rpcauth-test.py..."
- $(PYTHON) $(top_builddir)/test/util/rpcauth-test.py
+ $(PYTHON) -X pycache_prefix=/tmp/pycache/ $(top_builddir)/test/util/rpcauth-test.py
if TARGET_WINDOWS
else
if ENABLE_BENCH
diff --git a/test/util/rpcauth-test.py b/test/util/rpcauth-test.py
index 931eb80960..8a7ff26dcb 100755
--- a/test/util/rpcauth-test.py
+++ b/test/util/rpcauth-test.py
@@ -21,7 +21,6 @@ class TestRPCAuth(unittest.TestCase):
with open(config_path, encoding="utf8") as config_file:
config.read_file(config_file)
sys.path.insert(0, os.path.dirname(config['environment']['RPCAUTH']))
- sys.dont_write_bytecode = True
self.rpcauth = importlib.import_module('rpcauth')
def test_generate_salt(self):
All that said, this is a small change and I don't want to block progress. It's a small and reasonable diff, and easily reverted/changed in the future. I suppose it's more of a philosophical concern. |
|
Closing until the migration to CMake is complete. |

This change prevents writing
share/rpcauth/__pycache__/*.pyc, which is especially useful for out-of-source builds when the source directory is supposed to be read-only.Also see #19385 (comment).
I believe that performance concerns can be disregarded in this case.