From fcb6030335deee22b16a75f1f5581cda01e5471d Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 20 Apr 2015 02:45:57 +0000 Subject: [PATCH] #640: * make it easier to switch compiler: the BAT files tell the setup.py which compiler to use * support for building the cairo workaround code using msvc git-svn-id: https://xpra.org/svn/Xpra/trunk@9064 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/setup.py | 70 +++++++++++++++++++++----------- src/win32/MAKE-INSTALLER.BAT | 8 ++-- src/win32/PY34_MINGW32_BUILD.BAT | 1 + src/win32/PY34_MSVC_BUILD.BAT | 1 + 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/setup.py b/src/setup.py index 66e9b396c5..4097c2a099 100755 --- a/src/setup.py +++ b/src/setup.py @@ -77,7 +77,10 @@ def get_status_output(*args, **kwargs): has_pkg_config = False #we don't support building with "pkg-config" on win32 with python2: if PKG_CONFIG and (PYTHON3 or not WIN32): - has_pkg_config = get_status_output([PKG_CONFIG, "--version"])[0]==0 + pkg_config_version = get_status_output([PKG_CONFIG, "--version"]) + has_pkg_config = pkg_config_version[0]==0 and pkg_config_version[1] + if has_pkg_config: + print("found pkg-config version: %s" % pkg_config_version[1]) def pkg_config_ok(*args, **kwargs): if not has_pkg_config: @@ -980,23 +983,28 @@ def glob_recurse(srcdir): nvenc_bin_dir = nvenc_path + "\\bin\\win32\\release" nvenc_lib_names = [] #not linked against it, we use dlopen! - # Same for PyGTK: + # Same for PyGTK / GTK3: # http://www.pygtk.org/downloads.html - gtk2_path = "C:\\Python27\\Lib\\site-packages\\gtk-2.0" - python_include_path = "C:\\Python27\\include" - gtk2runtime_path = os.path.join(gtk2_path, "runtime") - gtk2_lib_dir = os.path.join(gtk2runtime_path, "bin") - gtk2_base_include_dir = os.path.join(gtk2runtime_path, "include") - - pygtk_include_dir = os.path.join(python_include_path, "pygtk-2.0") - atk_include_dir = os.path.join(gtk2_base_include_dir, "atk-1.0") - gtk2_include_dir = os.path.join(gtk2_base_include_dir, "gtk-2.0") - gdkpixbuf_include_dir = os.path.join(gtk2_base_include_dir, "gdk-pixbuf-2.0") - glib_include_dir = os.path.join(gtk2_base_include_dir, "glib-2.0") - cairo_include_dir = os.path.join(gtk2_base_include_dir, "cairo") - pango_include_dir = os.path.join(gtk2_base_include_dir, "pango-1.0") - gdkconfig_include_dir = os.path.join(gtk2runtime_path, "lib", "gtk-2.0", "include") - glibconfig_include_dir = os.path.join(gtk2runtime_path, "lib", "glib-2.0", "include") + if PYTHON3: + GTK3_DIR = "C:\\GTK3" + GTK_INCLUDE_DIR = os.path.join(GTK3_DIR, "include") + else: + gtk2_path = "C:\\Python27\\Lib\\site-packages\\gtk-2.0" + python_include_path = "C:\\Python27\\include" + gtk2runtime_path = os.path.join(gtk2_path, "runtime") + gtk2_lib_dir = os.path.join(gtk2runtime_path, "bin") + GTK_INCLUDE_DIR = os.path.join(gtk2runtime_path, "include") + #gtk2 only: + gdkconfig_include_dir = os.path.join(gtk2runtime_path, "lib", "gtk-2.0", "include") + glibconfig_include_dir = os.path.join(gtk2runtime_path, "lib", "glib-2.0", "include") + pygtk_include_dir = os.path.join(python_include_path, "pygtk-2.0") + gtk2_include_dir = os.path.join(GTK_INCLUDE_DIR, "gtk-2.0") + + atk_include_dir = os.path.join(GTK_INCLUDE_DIR, "atk-1.0") + gdkpixbuf_include_dir = os.path.join(GTK_INCLUDE_DIR, "gdk-pixbuf-2.0") + glib_include_dir = os.path.join(GTK_INCLUDE_DIR, "glib-2.0") + cairo_include_dir = os.path.join(GTK_INCLUDE_DIR, "cairo") + pango_include_dir = os.path.join(GTK_INCLUDE_DIR, "pango-1.0") #END OF HARDCODED SECTION ########################################################### @@ -1341,6 +1349,19 @@ def add_gui_exe(*args): build_xpra_conf(dist) + #FIXME: ugly workaround for building the ugly pycairo workaround on win32: + #the win32 py-gi installers don't have development headers for pycairo + #so we hardcode them here instead... + #(until someone fixes the win32 builds properly) + PYCAIRO_DIR = "C:\\pycairo-1.10.0" + def pycairo_pkgconfig(*pkgs_options, **ekw): + if "pycairo" in pkgs_options: + kw = pkgconfig("cairo", **ekw) + add_to_keywords(kw, 'include_dirs', PYCAIRO_DIR) + checkdirs(PYCAIRO_DIR) + return kw + return exec_pkgconfig(*pkgs_options, **ekw) + #hard-coded pkgconfig replacement for visual studio: #(normally used with python2 / py2exe builds) def VC_pkgconfig(*pkgs_options, **ekw): @@ -1411,11 +1432,17 @@ def add_keywords(path_dirs=[], inc_dirs=[], lib_dirs=[], libs=[], noref=True, no elif "pygobject-2.0" in pkgs_options[0]: dirs = (python_include_path, pygtk_include_dir, atk_include_dir, gtk2_include_dir, - gtk2_base_include_dir, gdkconfig_include_dir, gdkpixbuf_include_dir, + GTK_INCLUDE_DIR, gdkconfig_include_dir, gdkpixbuf_include_dir, glib_include_dir, glibconfig_include_dir, cairo_include_dir, pango_include_dir) add_to_keywords(kw, 'include_dirs', *dirs) checkdirs(*dirs) + elif "cairo" in pkgs_options: + add_to_keywords(kw, 'include_dirs', GTK_INCLUDE_DIR, cairo_include_dir) + add_to_keywords(kw, 'libraries', "cairo") + checkdirs(cairo_include_dir) + elif "pycairo" in pkgs_options: + kw = pycairo_pkgconfig(*pkgs_options, **ekw) else: sys.exit("ERROR: unknown package config: %s" % str(pkgs_options)) if debug_ENABLED: @@ -1438,12 +1465,7 @@ def add_keywords(path_dirs=[], inc_dirs=[], lib_dirs=[], libs=[], noref=True, no #the win32 py-gi installers don't have development headers for pycairo #so we hardcode them here instead... #(until someone fixes the win32 builds properly) - def pkgconfig(*pkgs_options, **ekw): - if "pycairo" in pkgs_options: - kw = exec_pkgconfig("cairo", **ekw) - add_to_keywords(kw, 'include_dirs', "C:\\pycairo-1.10.0") - return kw - return exec_pkgconfig(*pkgs_options, **ekw) + pkgconfig = pycairo_pkgconfig remove_packages(*external_excludes) diff --git a/src/win32/MAKE-INSTALLER.BAT b/src/win32/MAKE-INSTALLER.BAT index 7b128f2d43..060a044593 100644 --- a/src/win32/MAKE-INSTALLER.BAT +++ b/src/win32/MAKE-INSTALLER.BAT @@ -67,8 +67,8 @@ if NOT "%VC%"=="" ( ECHO *************************************************************** ECHO ****** build cython pyd files inplace -ECHO %PYTHON_EXE% -OO setup.py build_ext --inplace ^> build-xpra.log -%PYTHON_EXE% -OO setup.py build_ext --inplace > build-xpra.log +ECHO %PYTHON_EXE% -OO setup.py build_ext --inplace %COMPILER_ARGS% ^> build-xpra.log +%PYTHON_EXE% -OO setup.py build_ext --inplace %COMPILER_ARGS% > build-xpra.log if %errorlevel% NEQ 0 ( ECHO "build error, see build-xpra.log" GOTO ERROR @@ -90,8 +90,8 @@ SET PYTHONPATH=%PYGTK%;%GTK%\lib;%GTK%\bin;%PYTHON%\Lib\site-packages\;%DIR%;%PY SET PATH=%PATH%;%GSTREAMER%\sdk\bin;%GSTREAMER%\bin SET PY2EXE_ARGS=%BUILD_ARGS% IF %SHOW_DEPENDENCIES% NEQ 0 SET PY2EXE_ARGS=%BUILD_ARGS% -x -ECHO %PYTHON_EXE% -OO setup.py py2exe %PY2EXE_ARGS% ^> py2exe-xpra.log -%PYTHON_EXE% -OO setup.py py2exe %PY2EXE_ARGS% > py2exe-xpra.log +ECHO %PYTHON_EXE% -OO setup.py py2exe %COMPILER_ARGS% %PY2EXE_ARGS% ^> py2exe-xpra.log +%PYTHON_EXE% -OO setup.py py2exe %COMPILER_ARGS% %PY2EXE_ARGS% > py2exe-xpra.log if %errorlevel% NEQ 0 ( ECHO "py2exe error, see py2exe-xpra.log" GOTO ERROR diff --git a/src/win32/PY34_MINGW32_BUILD.BAT b/src/win32/PY34_MINGW32_BUILD.BAT index 91879f70d2..2a059e176a 100644 --- a/src/win32/PY34_MINGW32_BUILD.BAT +++ b/src/win32/PY34_MINGW32_BUILD.BAT @@ -1,4 +1,5 @@ set PYTHON=C:\Python34 set PATH=%PATH%;C:\MinGW\bin set PKG_CONFIG_PATH=C:\MinGW\lib\pkgconfig;C:\MinGW\msys\1.0\local\lib\pkgconfig;C:\MinGW\msys\1.0\lib\pkgconfig +set COMPILER_ARGS=--compiler=mingw32 win32\MAKE-INSTALLER.BAT /silent diff --git a/src/win32/PY34_MSVC_BUILD.BAT b/src/win32/PY34_MSVC_BUILD.BAT index 62038d08f4..252407e13c 100644 --- a/src/win32/PY34_MSVC_BUILD.BAT +++ b/src/win32/PY34_MSVC_BUILD.BAT @@ -1,2 +1,3 @@ set PYTHON=C:\Python34 +set COMPILER_ARGS=--compiler=msvc win32\MAKE-INSTALLER.BAT /silent