[GRASS-git] [OSGeo/grass] dd04cf: init: Output value for sys.path in config (#1835)

Vaclav Petras noreply at github.com
Thu Dec 2 12:27:19 PST 2021


  Branch: refs/heads/releasebranch_8_0
  Home:   https://github.com/OSGeo/grass
  Commit: dd04cf3c72156d274c5dfb86f5d6b7f3c8663558
      https://github.com/OSGeo/grass/commit/dd04cf3c72156d274c5dfb86f5d6b7f3c8663558
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M doc/notebooks/basic_example.ipynb
    M doc/notebooks/basic_example_grass_jupyter.ipynb
    M doc/notebooks/grass_jupyter.ipynb
    M doc/notebooks/hydrology.ipynb
    M doc/notebooks/solar_potential.ipynb
    M doc/notebooks/viewshed_analysis.ipynb
    M lib/init/grass.py
    M python/grass/script/setup.py

  Log Message:
  -----------
  init: Output value for sys.path in config (#1835)

With this addition, running grass --config python_path outputs the value needed for sys.path. This is useful in Python
where sys.path needs to be set up correctly before the grass package can be imported.

Instead of having to hardcode the etc/python part of the path, user can (optionally) obtain the full path from the new
parameter resulting in a more general code which requires just passing a result of call stripped from the white spaces.

This is especially interesting in combination with #1838 after which GISBASE environmental variable does not have to be
set up before for importing grass.script package, so setting up sys.path is the only step user needs to do before that.
Additionally, with #1829 (and #1979) the installation path (GISBASE) can be determined automatically from the path
to the grass.script.setup module (file), the executable (if it is called grass), or from a user-provided executable which
was be called (by the user) to obtain python_path.

The new setup method is now used in the notebooks.

This simplifoes usage documentaion in setup.py module. No GISBASE is needed. No explicit error checking
(errors are printed and/or raised automatically). sys.path now needs to be str/unicode.




More information about the grass-commit mailing list