[GRASS-dev] Handling of Python scripts on MS Windows

Glynn Clements glynn at gclements.plus.com
Tue Feb 4 02:29:55 PST 2014


Markus Metz wrote:

> Other projects such as gimp or libreoffice are AFAICT reasonably
> bundled with Python, without a Python installer.

They aren't attempting to support Python scripts as stand-alone
programs (i.e. something which can be run from the command prompt,
batch files, etc).

A compiled program which "embeds" Python (links against the Python
DSO/DLL) to use Python for "internal" scripting is a much simpler
case. And much less useful.

> > Most of the troubles arise from attempting to use a mixture of a
> > bundled version and a system-wide installation.
> 
> I agree. It seems that the wxGUI always uses the bundled GRASS_PYTHON,
> the reason why the wxGUI works fine without a system-wide Python.

That was done so that the system Python doesn't need to have wxPython
installed. Note that wxpyimgview does something similar: the top-level
script invokes the wxPython program via GRASS_PYTHON explicitly.

But this only works for a closed system which knows what it is
executing. It doesn't help us provide a command-line environment where
Python scripts just work as they should.

> > Which wouldn't be an
> > issue if people didn't attempt to bundle Python.
> 
> Other projects do bundle Python, and there it seems to work just fine.

They don't merely bundle it, they embed it, which is a much simpler
case. The downside is that Python can only be used within a monolithic
GUI application, which isn't how GRASS works.

> I don't understand why we can not also bundle Python, including all
> required Python packages.
> 
> Otherwise, users would need to install Python, wxPython, numpy, scipy,
> matplotlib, datetime themselves (not sure if the list is correct and
> complete).

We can facilitate this in most cases. If there isn't already a Python
installation, we can just install the latest 2.x version from the MSI,
and all required packages. If there is a suitable Python installation,
we can leave that and just install any required packages.

The problem only arises when there is an existing installation which
is unsuitable (incompatible version of Python or additional packages). 
In that situation, either the user has to make a choice or we need to
figure out how to use the launcher.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list