[GRASS-git] [OSGeo/grass] 33967f: grass.script: Add pack to create_project (#6415)

Vaclav Petras noreply at github.com
Wed Oct 1 12:55:48 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 33967f9115602449e04574f0c042223bab0e4218
      https://github.com/OSGeo/grass/commit/33967f9115602449e04574f0c042223bab0e4218
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2025-10-01 (Wed, 01 Oct 2025)

  Changed paths:
    M lib/init/grass.py
    M python/grass/app/cli.py
    A python/grass/app/tests/conftest.py
    M python/grass/app/tests/grass_app_cli_test.py
    M python/grass/grassdb/create.py
    A python/grass/grassdb/tests/conftest.py
    A python/grass/grassdb/tests/grass_grassdb_create_from_pack_test.py
    A python/grass/grassdb/tests/grass_grassdb_create_xy.py
    M python/grass/script/core.py
    M python/grass/script/tests/conftest.py
    M python/grass/script/tests/grass_script_core_location_test.py
    A python/grass/script/tests/grass_script_create_project_pack_test.py

  Log Message:
  -----------
  grass.script: Add pack to create_project (#6415)

This adds another parameter to create_project called pack which allows for creating a project from raster pack files (requires the recent fix from #6408 for the complete CRS info including the computational region addition). Additionally, it refactors general CRS string handling from grass.py so that the pack code is available in the command line, but also that the general handling is available in the Python API.

Because grass/script/core.py can't take any more code, the underlying code is in grass.grassdb.create. This includes both the new functions and refactored code (the code reuses pieces of the XY project creation). Tests are included for the create_project level and separate tests for the underlying grass.grassdb.create level. The new functions include private functions (some of them used in create_project) and public functions (but somewhat internal in grass.grassdb).

The new add/create region function uses the general terms used now in g.region JSON API (#6407), so it is less dependent on the keys in the internal region format.

As part of the refactoring, this moves handling of a general CRS string (aka geostring) from the main executable (grass.py) script to the library, so that library function has the one, universal parameter feature and the CLI has the pack without adding CLI specific code to support pack in CLI.

A new translatable intro error message is now produced in the command line when project creation fails to. The text serves as an into to whatever comes afterwards from the exception (e.g. GDAL output).

Similarly to the main grass.py CLI, this adds the CRS string parameter to the experimental subcommand run. Since the create_function now supports this universal, CLI-friendly way, the addition is just about passing the parameter from command line to the function, so it is easy to add with benefits mostly for testing at this point.

This is adding a separate fixture for grass.app which is the same as the one added to grass.script, but having the fixture at the grass package level interfered with session setups in the grass.app tests. The grass.app fixture is using grass.tools while the grass.script one is written with run_command, so that also makes them different and aligns well with grass.script not using the grass.tools API.

For tests of the subcommands, this uses the standard pytest output capturing fixture, but it also runs the same tests with the subcommand package to capture stdout on Windows in a more reliable way because otherwise srid is not in the JSON from g.proj in the test. We skip rather than xfail the capdf tests on Windows since the issues don't seem to be in our code since subprocess way works just fine, but we use subprocess on all platform for simplicity.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list