contributing: Replace manual env exports with generate-then-source pattern#7200
contributing: Replace manual env exports with generate-then-source pattern#7200wenzeslaus wants to merge 1 commit intoOSGeo:mainfrom
Conversation
…ttern Instead of requiring command substitution on every test invocation, document a pattern where resolved paths are written to a .grass_build_env file once and sourced before each pytest call. Add the generated file to .gitignore.
|
So finally, you're reinventing the .env convention, but with another file name? There exist some tooling to help preventing .env commuting. There's also some conventions for how to name other production, staging, etc. .env files. Why not try that? There's even some pytest plugins for that |
|
I meant to open as draft. What was your suggestion for .env? |
|
For the name, either |
|
I'm not sure if I understand what you think should happen next with .env. How do you think it should work with pytest? From what I understood so far, PYTHONPATH needs to be set from outside, pytest-dotenv seems to deal with variables, not path, which fits with .env, but does not allow the modification of sys.path we need. LD_LIBRARY_PATH needs to be set up before the process starts for the library loading automation to work. PATH works, but if we can't import from the grass package, it is not that useful. A conftest.py file in repo root would help, but we can have that. pytest plugins need to be importable, so no help there either. The only thing I can see that pytest's pythonpath and addopts may work together. Did you consider this in the past? [tool.pytest.ini_options]
pythonpath = ["python/grass/tests"]
addopts = "-p grass_test_env" # Exists
ls python/grass/tests/grass_test_env.py |
|
In the pythonpath+addopts scenario, the |
Instead of requiring command substitution on every test invocation,
document a pattern where resolved paths are written to a .grass_build_env
file once and sourced before each pytest call. Add the generated file
to .gitignore.