Skip to content

grass.script: Scan GRASS_ADDON_BASE in get_commands() - #7031

Open
saket0187 wants to merge 11 commits into
OSGeo:mainfrom
saket0187:get-installed-extensions
Open

saket0187 wants to merge 11 commits into
OSGeo:mainfrom
saket0187:get-installed-extensions

Conversation

@saket0187

Copy link
Copy Markdown
Contributor

This PR addresses issue mentioned in #3885

I have tested and verified that the output now includes installed extensions in the returned set.

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but the user's expectation would probably be also looking at GRASS_ADDON_PATH here.

https://grass.osgeo.org/grass-devel/manuals/variables.html

@github-actions github-actions Bot added Python Related code is in Python libraries labels Feb 3, 2026
@saket0187
saket0187 requested a review from wenzeslaus February 3, 2026 06:13
@wenzeslaus

Copy link
Copy Markdown
Member

Given this is based on a feature request, there is no test coverage. There are some g.extension tests where you can add this as an additional step conforming that GRASS_ADDON_BASE actually works. For GRASS_ADDON_PATH, it seems like the best solution is to create pytest-based test and create couple scripts in different dirs.

@github-actions github-actions Bot added module general tests Related to Test Suite labels Feb 5, 2026
@saket0187
saket0187 force-pushed the get-installed-extensions branch from 222b167 to 0e44f4a Compare February 6, 2026 09:33
@saket0187

Copy link
Copy Markdown
Contributor Author

I have added a few lines to scripts/g.extension/tests/g_extension_test.py. Since conftest.py already configures GRASS_ADDON_BASE, I thought using that setup would be enough. I have also added a test in python/grass/script/tests/grass_script_core_get_commands_test.py that creates dummy executables to confirm get_commands() correctly scans the paths specified in GRASS_ADDON_PATH.

Do let me know if anything is incorrect or if any changes are needed.

@wenzeslaus The Windows 2022 build is failing due to HTTP 404 errors, which appears unrelated to my changes; my local tests are passing successfully.

Comment thread python/grass/script/tests/grass_script_core_get_commands_test.py Outdated
Comment thread python/grass/script/tests/grass_script_core_get_commands_test.py Outdated
Comment thread python/grass/script/tests/grass_script_core_get_commands_test.py Outdated
Comment thread python/grass/script/core.py Outdated

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytest has a single test, no? Rework it to yield session instead of tools.

@saket0187

Copy link
Copy Markdown
Contributor Author

Currently there's only one test file right now (excluding conftest.py), But I have simplified the fixture to yield session directly which is good to have if we add some tests later. I moved the Tools logic into the test itself; shouldn't make much difference performance-wise since it's just used once.

wenzeslaus
wenzeslaus previously approved these changes Feb 7, 2026

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great now. Thank you.

We should merge only after the Windows CI is back since this actually needs the Windows check.

@echoix

echoix commented Oct 12, 2026

Copy link
Copy Markdown
Member

The windows extensions build server isn't updated to be able to build for 8.5 (released) and 8.6 (dev).

So your test will still continue to fail for the time being.

from grass.tools import Tools


@pytest.mark.skipif(sys.platform.startswith("win"), reason="Temporarily disable tests.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about keeping the test disabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

wenzeslaus
wenzeslaus previously approved these changes Oct 19, 2026

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code change still holds and it is mergeable.

The behavior update is cross-platform, so we don't need to hold this because of the Windows CI failures, no?

@saket0187
saket0187 requested a review from wenzeslaus October 19, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

general libraries module Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants