[Osgeo4w-trac] Re: [osgeo4w] #282: python path getting overwritten
OSGeo4W
trac_osgeo4w at osgeo.org
Fri Mar 30 01:51:09 EDT 2012
#282: python path getting overwritten
--------------------+-------------------------------------------------------
Reporter: lpinner | Owner: maphew
Type: defect | Status: assigned
Priority: minor | Component: Package
Version: | Keywords: python
--------------------+-------------------------------------------------------
Comment(by lpinner):
Replying to [comment:3 maphew]:
> I don't know that we can rely/assume the call order for the batch files
is alphabetical.
I don't think the order is important, I only mentioned it as it was the
OTB pythonpath that was getting overwritten, not the other way around.
Should probably do something similar for all batch files that set
environment variables that might also be set/reset/extended by another
batch file.
> I'll use the second example for now. Long term I'd rather intelligently
only add path items which don't exist already (here and in [wiki:pkg-
shell]), something that appears to be frustratingly hard on Windows.
It's kinda ugly, but what about something like:
{{{
rem Couldn't figure out out to get the output of findstr
rem into a variable, so use errorlevel instead
rem Idea from http://stackoverflow.com/questions/2634959/2-batch-string-
questions
set testpythonpath=%OSGEO4W_ROOT%\apps\Python27
echo %PYTHONPATH%|findstr /i "%testpythonpath%">nul
IF %errorlevel%==0 goto EXIT
IF "%PYTHONPATH%"=="" (
SET PYTHONPATH=%testpythonpath%
) ELSE (
SET PYTHONPATH=%PYTHONPATH%;%testpythonpath%
)
:EXIT
}}}
--
Ticket URL: <http://trac.osgeo.org/osgeo4w/ticket/282#comment:4>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.
More information about the Osgeo4w-trac
mailing list