[GRASS-user] How to avoid Grass84 compiling against the system Python3.6?

Barry Keeling barryfoxbat1 at gmail.com
Sat Mar 23 15:42:26 PDT 2024


Anna, and Hernán (and @grass-users),

Many thanks for your helpful suggestions. In fact you both helped me in 
finding the solution to the issue I've had getting Grass compiled 
against a newer Python than the one in the OpenSuse 15.5 base system. 
Your replies gave me the confidence to pursue building the Grass 
application with Python v3.11, and to use a Python virtual environment 
in doing so.

I'm very happy to report, that today [Sat] I managed to build the latest 
development release Grass from source, and the python-related errors are 
now gone :

System Info :
     GRASS version: 8.4.0dev
     Code revision: exported
     Build date: 2024-03-23
     Build platform: x86_64-pc-linux-gnu
     GDAL: 3.8.4
     PROJ: 9.3.1
     GEOS: 3.12.1
     SQLite: 3.44.0
     Python: 3.11.8
     wxPython: 4.2.1
     Platform: Linux-5.14.21-150500.55.52-default-x86_64-with-glibc2.31

The steps :

1. Build wxPython in a temporary Python v3.11 virtual environment (using 
this as a go by: 
https://wxpython.org/blog/2017-08-17-builds-for-linux-with-pip/index.html ).

      - Note: this was made more difficult because there is a wxPython 
bug relating to setup on OpenSuse (see this link for details :

https://github.com/wxWidgets/Phoenix/issues/1067,

        and specifically this comment by Frank78 : 
https://github.com/wxWidgets/Phoenix/issues/1067#issuecomment-685175041)

2. Create a wheel file, from the wxPython build using pip (still in the 
same venv).

3. Exit that venv, and then activate my usual Python v3.11 venv, 
navigate to the the directory containing the new wxPython wheel and 
install it with pip.

4. Then, still in my usual Python v3.11 venv, change directory to a 
clean instance of the Grass 8.4 development snapshot I'd downloaded 
previously.

5. In the bash console, set the following :  export 
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local:/usr/local/lib64

6. Run the configure command with all the required options, then when 
that finishes successfully ...

7a. set this : export GRASS_RANDOM_SEED=1234

7b. initiate the build with this : make prefix=/usr/local 
PREFIX=/usr/local -j4

8. The build finished :

GRASS GIS 8.4.0dev exported compilation log
--------------------------------------------------
Started compilation: Sat 23 Mar 15:01:20 GMT 2024
--
Errors in:
No errors detected.
--
Finished compilation: Sat 23 Mar 15:05:17 GMT 2024

9. Finally, install to the desired directory location (in this case 
/usr/local/bin and /usr/local/grass84) with this : sudo make install

10. create a desktop launcher that activates the Python3.11 and runs the 
/usr/local/bin/grass executable, all in one go with this setting :

       Exec=/bin/bash -c 'source ~/.venv/py311env/bin/activate && 
/usr/local/bin/grass'

Hopefully the above workflow will be of help to others just beginning to 
attempt compiling Grass on their Linux system.

Once again, thanks Anna, and Hernán.

Regards,

Barry.

On 22/03/2024 14:00, Anna Petrášová wrote:
> There is GRASS_PYTHON variable you can try. Running GRASS in virtual 
> environment should work too.
>
> On Thu, Mar 21, 2024 at 2:39 AM Hernán De Angelis via grass-user 
> <grass-user at lists.osgeo.org> wrote:
>
>     I understand you are using openSUSE Leap. At the moment I cannot
>     check which Python version is offered there as base. Are you sure
>     you cant install a newer version? If that is not possible you
>     could perhaps install a newer version using your own separate
>     local environment, using miniforge, for example.
>
>     I use openSUSE Tumbleweed and always build from source. Python
>     3.11 is the base version now, with 3.12 starting to be rolled in.
>     Perhaps it is not too crazy to try TW?
>
>     Good luck!
>
>     Hernán
>
>     Den tors 21 mars 2024 01:23Barry Keeling via grass-user
>     <grass-user at lists.osgeo.org> skrev:
>
>         Hi @grass-users,
>
>         I posted the following on libera.chat#grass but it seemed like
>         there
>         isn't much activity on there (pls. excuse if I'm wrong on that).
>
>         I spent the day learning how to compile the grass8.4dev
>         source, and
>         managed to get the app to compile, and fire up
>         but there's a glitch, it compiled against the system python
>         which is
>         only v3.6 (not compatible based on REQUIREMENTS file)
>         and I don't know how to point it at python v3.11.
>
>         This is on OpenSuse 15.5 Linux, btw, and though the Grass
>         application
>         windows work well, I get errors in the console related mostly
>         to python,
>         when trying to use the various modules, for example using
>         r.in.png.
>
>         I've tried per-user setting python3 aliased to v3.11 in my
>         .bashrc, but
>         no luck Grass still shows v3.6 in Help/about/system ..
>
>         I'm wondering whether I should use update-alternatives
>         approach, and
>         also wondering whether the problem might be related to
>         wxpython3 being
>         linked to the system python and not v3.11.
>
>         I haven't compiled wxpython separately.
>
>         I'm just hoping someone might be able to point me in the right
>         direction :-)
>
>         Barry
>
>
>         _______________________________________________
>         grass-user mailing list
>         grass-user at lists.osgeo.org
>         https://lists.osgeo.org/mailman/listinfo/grass-user
>
>     _______________________________________________
>     grass-user mailing list
>     grass-user at lists.osgeo.org
>     https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20240323/64bc8c50/attachment.htm>


More information about the grass-user mailing list