[GRASS-git] [OSGeo/grass] 9dd92f: grass.script: More carefully setup env in create_p...

Vaclav Petras noreply at github.com
Fri Jun 20 12:13:25 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 9dd92f956684722d9ad0ff5f3e724b92cb8e1a5b
      https://github.com/OSGeo/grass/commit/9dd92f956684722d9ad0ff5f3e724b92cb8e1a5b
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2025-06-20 (Fri, 20 Jun 2025)

  Changed paths:
    M general/g.mapsets/tests/conftest.py
    M lib/gis/tests/lib_gis_env_test.py
    M python/grass/experimental/tests/conftest.py
    M python/grass/jupyter/tests/conftest.py
    M python/grass/jupyter/tests/grass_jupyter_session_test.py
    M python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py
    M python/grass/script/core.py
    M python/grass/script/setup.py
    M python/grass/script/tests/grass_script_core_location_test.py
    M python/grass/script/tests/grass_script_setup_test.py
    M python/grass/script/tests/test_script_task.py
    M scripts/v.db.univar/tests/conftest.py
    M scripts/v.dissolve/tests/conftest.py
    M temporal/t.rast.list/tests/conftest.py
    M vector/v.fill.holes/tests/conftest.py

  Log Message:
  -----------
  grass.script: More carefully setup env in create_project (#5854)

Newly, the env in create_project is not set up not only when GISBASE is not set, but also when GISBASE is not in PATH which at this point indicates that tools will not run.

The env setup is done only when needed, so simple XY does not trigger creation of the environment, and so it is more lightweight.

The code to ensure runtime environment is moved to grass.script.setup, broken down and made reusable. The difference for usage in create_project is that os.environ is now always copied even if it already has GISBASE (we saved that copy operation before if GISBASE was already present). The handling of env, however, is consistent with other functions in grass.script.setup.

With faster create_project, I replaced the old gs.core._create_location_xy calls by simple gs.project calls in tests. Removed pylint: disable=protected-access, and removed one variable (constructing the path directly from a string).

A new test is checking the case when overwriting a project and creating an XY one which (for XY project) should also test cleaning GISRC without processing g.proj run.



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