How to tell if you're running on windows?

Roy Smith roy at panix.com
Fri Dec 4 16:14:29 EST 2009


In article <mailman.1418.1259956672.2873.python-list at python.org>,
 David Robinow <drobinow at gmail.com> wrote:

> On Fri, Dec 4, 2009 at 1:46 PM, Roy Smith <roy at panix.com> wrote:
> > I'm using 2.5.1.  How can I tell if I'm running on windows?  The
> > obvious answer, platform.system(), gets complicated.  On the python
> > that comes with cygwin, it returns 'CYGWIN_NT-5.2-WOW64', but I've got
> > a native windows build of python where it returns 'Microsoft'.
> >
> > The real problem I'm trying to solve is whether to build a LIBPATH
> > environment variable with ';' or ':' delimiting the entries.  On the
> > cygwin build, os.pathsep returns ':', which isn't really correct.  If
> > you use that, you end up building paths that look like c:foo:c:bar.
> > It should be c:foo;c:bar
> 
> It's not clear to me what you're using LIBPATH for.
> Are you running a cygwin executable from Python? Or a Windows
> executable from cygwin?

Our build and test environment for windows is cygwin.  This is a Python 
test script running a native windows executable using subprocess.Popen().  
The LIBPATH I'm building is for the executable's environment.

We're looking to possibly replace cygwin with MinGW at some point in the 
future.  In the past, we've always equated "cygwin" and "windows" in our 
build scripts, but now that we're thinking MinGW-ish thoughts, that's 
looking like a sub-optimal strategy.

> LIBPATH should be in the format desired by the consumer.



More information about the Python-list mailing list