From 01ef209420076da036f38f90f3562ed3bd4117b2 Mon Sep 17 00:00:00 2001 From: Thibault Genessay Date: Tue, 1 Mar 2016 12:57:45 +0100 Subject: [PATCH 1/3] Basic Cygwin path detection So that build.py works out of the box with default Cygwin 64 installations --- build.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index c9effa64..9cecfb8b 100755 --- a/build.py +++ b/build.py @@ -85,6 +85,14 @@ doxygenMD5 = { # And the location where they can be downloaded from toolsURL = 'http://wxpython.org/Phoenix/tools' +# Cygwin is needed on Windows. This tool assumes it is installed in +# the default location. Try to at least guess if we are using 32 bit +# or 64 bit builds. +if isWindows: + cygwin_path_32 = 'c:/cygwin' + cygwin_path_64 = 'c:/cygwin64' + cygwin_path = cygwin_path_64 if os.path.isdir(cygwin_path_64) else cygwin_path_32 + #--------------------------------------------------------------------------- def usage(): @@ -240,7 +248,7 @@ def setPythonVersion(args): # TOOLS = os.environ.get('TOOLS') if 'cygdrive' in TOOLS: - TOOLS = runcmd('c:/cygwin/bin/cygpath -w '+TOOLS, True, False) + TOOLS = runcmd(cygwin_path+'/bin/cygpath -w '+TOOLS, True, False) use64flag = '--x64' in args if use64flag: args.remove('--x64') @@ -718,12 +726,12 @@ def _doDox(arg): if isWindows: doxCmd = doxCmd.replace('\\', '/') - doxCmd = runcmd('c:/cygwin/bin/cygpath -u '+doxCmd, True, False) + doxCmd = runcmd(cygwin_path+'/bin/cygpath -u '+doxCmd, True, False) os.environ['DOXYGEN'] = doxCmd os.environ['WX_SKIP_DOXYGEN_VERSION_CHECK'] = '1' d = posixjoin(wxDir(), 'docs/doxygen') d = d.replace('\\', '/') - cmd = 'c:/cygwin/bin/bash.exe -l -c "cd %s && ./regen.sh %s"' % (d, arg) + cmd = '%s/bin/bash.exe -l -c "cd %s && ./regen.sh %s"' % (cygwin_path, d, arg) else: os.environ['DOXYGEN'] = doxCmd os.environ['WX_SKIP_DOXYGEN_VERSION_CHECK'] = '1' From fa690a7e5fa4ff357217864909c531fc996d8ea4 Mon Sep 17 00:00:00 2001 From: Thibault Genessay Date: Tue, 1 Mar 2016 13:01:36 +0100 Subject: [PATCH 2/3] Added shell=True to Popen() on win32 This allows 'dot.exe' to be found when called with 'dot', as long as 'dot.exe' is in the PATH. --- sphinxtools/inheritance.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sphinxtools/inheritance.py b/sphinxtools/inheritance.py index b1dc5318..d2c970bf 100644 --- a/sphinxtools/inheritance.py +++ b/sphinxtools/inheritance.py @@ -269,9 +269,18 @@ class InheritanceDiagram(object): dot_args.extend(['-Tpng', '-o' + outfn]) dot_args.extend(['-Tcmapx', '-o' + mapfile]) + popen_args = { + 'stdout': PIPE, + 'stdin': PIPE, + 'stderr': PIPE + } + + if sys.platform == 'win32': + popen_args['shell'] = True + try: - p = Popen(dot_args, stdout=PIPE, stdin=PIPE, stderr=PIPE) + p = Popen(dot_args, **popen_args) except OSError as err: From 2c630fa5331912b7661527b14758e968aed80a0a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 1 Mar 2016 21:44:16 -0800 Subject: [PATCH 3/3] Move the Cygwin location code into a function Add a note to README about the need for Cygwin --- README.rst | 16 +++++++++++----- build.py | 28 ++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 8058812c..e3b6cf38 100644 --- a/README.rst +++ b/README.rst @@ -55,12 +55,18 @@ decoding errors. For example:: chcp 1252 python build.py ... +In addition, some tasks within the build currently expect to be able to use +Cygwin on Windows (https://www.cygwin.com/) to do its work. If you have +Cygwin installed in one of the default locations (c:\cygwin or c:\cygwin64) +then all is well. If you have it installed somewhere else then you can set +CYGWIN_BASE in the environment and the build tool will use that for the base +dir. -If you just want to do a standard setuptools-style build using setup.py and -are using a full source tarball, then you can stop reading at this point. If -you want to build from a source repository checkout, or need to make changes -and/or to regenerate some of the generated source files, then please continue -reading. +On the other hand, if you just want to do a standard setuptools-style build +using setup.py and are using a full source tarball, then you can stop reading +at this point. If you want to build from a source repository checkout, or +need to make changes and/or to regenerate some of the generated source files, +then please continue reading. Building wxWidgets diff --git a/build.py b/build.py index 9cecfb8b..56309643 100755 --- a/build.py +++ b/build.py @@ -85,13 +85,6 @@ doxygenMD5 = { # And the location where they can be downloaded from toolsURL = 'http://wxpython.org/Phoenix/tools' -# Cygwin is needed on Windows. This tool assumes it is installed in -# the default location. Try to at least guess if we are using 32 bit -# or 64 bit builds. -if isWindows: - cygwin_path_32 = 'c:/cygwin' - cygwin_path_64 = 'c:/cygwin64' - cygwin_path = cygwin_path_64 if os.path.isdir(cygwin_path_64) else cygwin_path_32 #--------------------------------------------------------------------------- @@ -248,7 +241,7 @@ def setPythonVersion(args): # TOOLS = os.environ.get('TOOLS') if 'cygdrive' in TOOLS: - TOOLS = runcmd(cygwin_path+'/bin/cygpath -w '+TOOLS, True, False) + TOOLS = runcmd(getCygwinPath()+'/bin/cygpath -w '+TOOLS, True, False) use64flag = '--x64' in args if use64flag: args.remove('--x64') @@ -715,6 +708,24 @@ def getWafBuildBase(): return base +def getCygwinPath(): + """ + Try to locate the path where cygwin is installed. + + If CYGWIN_BASE is set in the environment then use that. Otherwise look in + default install locations. + """ + if os.environ.get('CYGWIN_BASE'): + return os.environ.get('CYGWIN_BASE') + + for path in ['c:/cygwin', 'c:/cygwin64']: + if os.path.isdir(path): + return path + + return None + + + #--------------------------------------------------------------------------- # Command functions and helpers #--------------------------------------------------------------------------- @@ -725,6 +736,7 @@ def _doDox(arg): doxCmd = os.path.abspath(doxCmd) if isWindows: + cygwin_path = getCygwinPath() doxCmd = doxCmd.replace('\\', '/') doxCmd = runcmd(cygwin_path+'/bin/cygpath -u '+doxCmd, True, False) os.environ['DOXYGEN'] = doxCmd