Repository navigation
CMake: Create grass.bat and add scripts to PATH - #6383
Conversation
|
Would prepending GRASS_PYDIR to sys.path: Line 2098 in 92dc5b8 be an alternative to versioning the file name? |
|
Hm, regardless, we should prepend. I'll adjust my PR. We could also import in more low level way to avoid the version. |
No, it doesn't work. Still trying to self-import because the main script name is the same as the package name. |
|
It's OK on UN*X because the main script is |
Oh, too bad. Not sure what to do, it is not ideal to re-add the version to the main executive. |
This PR doesn't change anything for UN*X. |
I understand it is only for Win. If you will do scripting on Win, wouldn't |
For Python scripting, yes |
|
If I understand correctly, the situation now is:
This looks platform-appropriate to me. Anyway, I made the change with prepend in #6393. In my local test on Linux, it seems that
|
wenzeslaus
left a comment
There was a problem hiding this comment.
I would be for merging the versioned part of this PR right now. If we want to make it better in the future, we can refine #6393, use importlib, or the __main__.py file Python mechanics.
The scripts part is not clear to me. With Autotools we don't have separate scripts on Linux, but we may have them for Windows. I don't know what is the exact reasoning behind that. It is clear that Linux just treats all the executables the same, while more care is needed to run a Python script on Windows.
|
I made even further changes to #6393 and it works for me on Linux with grass.py. I would give it a try before merging the version piece here. We may still want to avoid the failed import with the "versioned" file, but we don't have to, because that's handled gracefully with #6393. #6393 needs a review. Edit: #6393 is now merged. |
Testing the main without this PR. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Getting the same error: I'm renaming |
|
First Windows conda packages: https://grass-conda.isnew.info/ |
wenzeslaus
left a comment
There was a problem hiding this comment.
It is disappointing that the rename is needed since my tests on Linux with conda seemed to show it works. I'm for renaming anyway, though, because it is more robust solution. The Python script is not touched by anything user related. Python imports don't use it and executable is the .bat file, so the name is internal.
The rest looks reasonable. The scripts on path is a confusion which we are hopefully finally addressing by this.
Suggested commit message (please check; PR description out of date at this point):
Rename the Windows startup script from grass.py to grass_main.py to avoid a name collision with the grass Python package, which caused import grass to fail because Python treated the script itself as the grass module/package.
Generate grass.bat from lib/init/grass.bat.in during the CMake build and install it to bin, and resolve GISBASE relative to the script location instead of baking in the build-tree path.
Always add the script directory to PATH when it exists so Windows batch wrappers in scripts/ are reachable. Non-Windows behavior is unchanged because it was already behaving that way.
|
Hmm... I'm not sure why @wenzeslaus any ideas? |
|
The r.coin failed test seems to be failing because of « missing » r.stats. |
Yes
No, it uses its own template |
|
Also note that what we build as « osgeo4w » here is not using the same scripts and all as what is actually shipped by « osgeo4w », some differences being in the unit (paths and bat file names), among others. Fixing CI might still cause problems in the nightlies of osgeo4w |
|
Before going too far, I launched a rerun |
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE set directly. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs the runtime path tests and a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE taken from the one versioned directory there. The test and the workflow were drafted with Claude Code.
The conda-forge package is built with CMake and MSVC, but no CI job compiles that way: the OSGeo4W job uses MinGW. Add a Windows job with conda-forge dependencies which builds GRASS and runs the runtime path tests and a new test of the database drivers through the DBMI protocol. The test uses column counts and values which text-mode pipes alter and inserts rows one by one, so it covers the driver failures reported in OSGeo#8291. The Windows launcher is not produced by the CMake build yet (OSGeo#6383), so the tests run from the build tree with GISBASE taken from the one versioned directory there. The test and the workflow were drafted with Claude Code.
Add a workflow which builds GRASS with MSVC and dependencies from conda-forge, the way the conda-forge package is built, and runs the same pytest passes as the OSGeo4W job. The OSGeo4W job builds with MinGW, so until now nothing compiled the MSVC-specific code paths before a release (OSGeo#8291 and the regressions fixed in OSGeo#8308, OSGeo#8309, OSGeo#8310, OSGeo#8311, OSGeo#8312 were all found by building main with MSVC by hand). The CMake build does not produce the Windows launcher yet (OSGeo#6383), so the tests run from the build tree with GISBASE, PYTHONPATH and PATH set by the workflow. PATH is reduced to the conda environment, GRASS and Windows: the ctypes loader registers every PATH entry as a DLL directory, and the runner image has over a hundred of them, several with their own copies of the GDAL dependencies, which made the GRASS libraries fail to load in fresh processes. Tests which fail only in this job are deselected with the reasons listed in the workflow: the launcher test, two test markers which assume the MinGW C runtime or Python 3.12, and two tool failures (r.in.pdal access violation, g.remove after g.copy) to be fixed separately. Written with Claude Code.
Add a workflow which builds GRASS with MSVC and dependencies from conda-forge, the way the conda-forge package is built, and runs the same pytest passes as the OSGeo4W job. The OSGeo4W job builds with MinGW, so until now nothing compiled the MSVC-specific code paths before a release (OSGeo#8291 and the regressions fixed in OSGeo#8308, OSGeo#8309, OSGeo#8310, OSGeo#8311, OSGeo#8312 were all found by building main with MSVC by hand). The CMake build does not produce the Windows launcher yet (OSGeo#6383), so the tests run from the build tree with GISBASE, PYTHONPATH and PATH set by the workflow. PATH is reduced to the conda environment, GRASS and Windows: the ctypes loader registers every PATH entry as a DLL directory, and the runner image has over a hundred of them, several with their own copies of the GDAL dependencies, which made the GRASS libraries fail to load in fresh processes. Tests which fail only in this job are deselected with the reasons listed in the workflow: the launcher test, two test markers which assume the MinGW C runtime or Python 3.12, and two tool failures (r.in.pdal access violation, g.remove after g.copy) to be fixed separately. Written with Claude Code.
This PR
grass.pytograss<VERSION>.pyto avoidgrass.batfromlib/init/grass.bat.in, andscriptstoPATHfor batch files.