1. biolab
  2. Untitled project
  3. orange

Commits

bloodjazman  committed 9dc76e7 Merge

Merged biolab/orange into default

  • Participants
  • Parent commits 29cd0ee, ee9e901
  • Branches default

Comments (0)

Files changed (17)

File install-scripts/callCreateRelease.btm

-@echo off
-set QTVER=qt23-3rdparty
-call createRelease.btm %QTVER >& win-release-create.%QTVER.log
-
-iff %ERRORS != 0 then
-  set subj="Orange for Windows: Error creating %QTVER release installation(s)"
-  echo Error
-else
-  set subj="Orange for Windows: Release installation(s) for %QTVER built"
-endiff
-
-cdd %SCRIPTDIR
-sendmail %MAIL_TO %subj @%SCRIPTDIR\win-release-create.%QTVER.log
-
-rem # copy log(s) to web in any case (success or error)
-set BUILDLOGDIR=%DOWNLOADDIR\buildLogs\winxp
-if not direxist %BUILDLOGDIR mkdir /s %BUILDLOGDIR
-del /eq %BUILDLOGDIR\win-release-*.log
-move /z %SCRIPTDIR\win-release-create.%QTVER.log %BUILDLOGDIR
-move /z %TMPDIR\win-release*.log %BUILDLOGDIR

File install-scripts/callCreateSnapshot.btm

View file
+rem # Required env variables:
+rem #    PUBLISH_URL - url (user@host) of the publish server
+rem #    ID_KEY - identity key file for logging into publish server
+
 @echo off
 set QTVER=qt44-3rdparty
 call createSnapshot.btm %QTVER >& win-snapshot-create.%QTVER.log
 sendmail %MAIL_TO %subj @%SCRIPTDIR\win-snapshot-create.%QTVER.log
 
 rem # copy log(s) to web in any case (success or error)
-set BUILDLOGDIR=%DOWNLOADDIR\buildLogs\winxp
-if not direxist %BUILDLOGDIR mkdir /s %BUILDLOGDIR
-del /eq %BUILDLOGDIR\win-snapshot-*.log
-move /z %SCRIPTDIR\win-snapshot-create.%QTVER.log %BUILDLOGDIR
-move /z %TMPDIR\win-snapshot*.log %BUILDLOGDIR
+rem # create a ftp script for moving the logs
+
+echo cd files/buildLogs/winxp > move.scr
+echo put %SCRIPTDIR%\win-snapshot-create.%QTVER%.log >> move.scr
+echo exit >> move.scr
+
+psftp -i "%ID_KEY%" "%PUBLISH_URL%" -batch -b move.scr

File install-scripts/callRegression.btm

-call updateSetConstants__.btm
-
-pushd
-cd ..
-cvs -d :sspi;username=cvs;password=cvs;hostname=estelle.fri.uni-lj.si:/cvs checkout -P -- regressionTests
-cvs -d :sspi;username=cvs;password=cvs;hostname=estelle.fri.uni-lj.si:/cvs checkout -P -d doc -- orange/doc
-popd
-
-if exist regressionTests.log del regressionTests.log
-
-for %pyver in (%PYTHONVERSIONS) do (
-  echo Python %pyver
-  call regressionTests.btm %pyver >> regressionTests.log
-  flag_on_error
-)
-
-set REGRESDIR=%WEBDOWNLOAD\regressionResults
-if not exist %REGRESDIR mkdir %REGRESDIR
-
-for %d in (modules-output ofb-output reference-output) do (
-  for %res in (crash error new changed random1 random2) do (
-    rem remove old regression reports from web and copy new
-    del /s %REGRESDIR\regressionTests\%d\*.py.win32.?.?.%res.txt
-    copy /s ..\regressionTests\%d\*.py.*.?.?.%res.txt %REGRESDIR\regressionTests\%d
-  )
-)
-
-copy regressionTests.log %REGRESDIR\windows.regress.log
-
-iff %ERRORS != 0 then
-  set subj="Error in regression tests on Windows"
-else
-  set subj="Regression tests on Windows completed successfully"
-endiff
-
-sendmail %MAIL_TO %subj @regressionTests.log
-

File install-scripts/checkSyntax.btm

-@echo off
-alias check=\python%1\python -c "import py_compile; py_compile.compile('%%@REPLACE[\,/,%%1]')"
-
-for %f in (*.py) check %f
-cd orangeCanvas
-for %f in (*.py;*.pyw) check %f
-cd ..\orangeWidgets
-for /r %f in (*.py;*.pyw) check %f
-cd ..

File install-scripts/createCommonAddOns__.btm

View file
   set PYTHON=%PYTHONBASE%%pyver
   %PYTHON\python setup.py build -c mingw32 bdist_wininst > %COMPILELOG
   break_on_error
-rem when compiled:  move /z %TMPDIR\Bioinformatics\dist\*.win32-py%npver.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe
-  move /z %TMPDIR\Bioinformatics\dist\*.win32.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe
+  move /z dist\*.win32.exe %TMPDIR\%PKG_BIOINFORMATICS-py%npver.exe
 
-  REM # publish, add record to stamps_pyd.txt, needed for update from web (accessed by updateFromSVN.bat)  
-  set TMPBINDIR=%TMPDIR\binaries\%pyver\add-ons\Bioinformatics
-  if not direxist %TMPBINDIR mkdir /s %TMPBINDIR
-  
-  cdd %TMPDIR\Bioinformatics\build\lib.win32-%npver
-  for %pydf in (*.pyd) do (
-    copy %pydf %TMPBINDIR
-    set MD5=%@MD5[%pydf]
-    echo add-ons\Bioinformatics\%pydf %MD5 >> %TMPDIR\binaries\%pyver\stamps_pyd.txt
-  )
 )
 
 for %pyver in (%PYTHONVERSIONS_ADDONs) do (
   set PYTHON=%PYTHONBASE%%pyver
   %PYTHON\python setup.py build -c mingw32 bdist_wininst > %COMPILELOG
   rem break_on_error
-  move /z %TMPDIR\Text\dist\*.win32-py%npver.exe %TMPDIR\%PKG_TEXT-py%npver.exe
-
-  REM # publish, add record to stamps_pyd.txt, needed for update from web (accessed by updateFromSVN.bat)  
-  set TMPBINDIR=%TMPDIR\binaries\%pyver\add-ons\Text
-  if not direxist %TMPBINDIR mkdir /s %TMPBINDIR
-
-  cdd %TMPDIR\Text\build\lib.win32-%npver
-  for %pydf in (*.pyd) do (
-    copy %pydf %TMPBINDIR
-    set MD5=%@MD5[%pydf]
-    echo add-ons\Text\%pydf %MD5 >> %TMPDIR\binaries\%pyver\stamps_pyd.txt	  
-  )
+  move /z dist\*.win32-py%npver.exe %TMPDIR\%PKG_TEXT-py%npver.exe
 )

File install-scripts/createCommon__.btm

View file
   REM # Delete existing orangeqt.pyd in TMPDIR (It will be moved into place later)
   if exist %TMPDIR\Orange\orangeqt.pyd del /q %TMPDIR\Orange\orangeqt.pyd
 
-  REM # compress pyd and create stamps_pyd.txt, needed for update from web (accessed by updateFromSVN.bat)
-  set TMPBINDIR=%TMPDIR\binaries\%pyver
-  if not direxist %TMPBINDIR\%pyver mkdir /s %TMPBINDIR
-
   cdd %PYORANGEDIR
   except (*_d.pyd) for %pydf in (*.pyd) do (
     if exist %TMPDIR\Orange\%pydf del /q %TMPDIR\Orange\%pydf
     copy %pydf %TMPDIR\Orange\
-    copy %pydf %TMPBINDIR
-  )
-
-  cdd %TMPBINDIR
-  if exist stamps_pyd.txt del /q stamps_pyd.txt
-  for %pydf in (*.pyd) do (
-    set MD5=%@MD5[%pydf]
-    echo %pydf %MD5 >> stamps_pyd.txt
   )
 
   if direxist %PARTY (
   ) else (
     echo installation file was not built because no 3rd-party software available
   )
+  type %COMPILELOG%
 )
-
-rem # compile documentation
-REM cdd %SCRIPTDIR\doc
-REM call compileDocumentation.btm
-REM cdd %WEBDOCDIR
-REM winrar a %DOWNLOADDIR\orange-chm.zip *.chm
-REM break_on_error

File install-scripts/createRelease.btm

-REM #input arguments
-REM # %1 - folder with 3rd party software
-REM # %2 - SVN tag of sources to include in the package
-
-call updateSetVariables__.btm release
-set VERSION=%1
-set RELEASE_DATE=%nicedate
-set WIN=orange-win-%VERSION
-set WIN_PYTHON=orange-win-w-python-%VERSION
-set ADDON_BIOINFORMATICS=orangeAddOn-bioinformatics-%VERSION
-set ADDON_TEXT=orangeAddOn-text-%VERSION
-
-rem # update source(s) to revision HEAD
-cdd %TMPDIR
-svn cleanup
-svn update --ignore-externals
-
-rem # build core
-cdd %SCRIPTDIR
-call createCommon__.btm release %1 %WIN %WIN_PYTHON
-break_on_error
-
-rem # build add ons
-rem cdd %SCRIPTDIR
-rem call createCommonAddOns__.btm release %ADDON_BIOINFORMATICS %ADDON_TEXT
-rem break_on_error
-
-rem # if no errors then publish on web (everything at the same time)
-cdd %TMPDIR
-move /z *.exe %DOWNLOADDIR
-
-rem # remember new filenames
-cdd %SCRIPTDIR
-call updateVersionsPy__.btm

File install-scripts/createSnapshot.btm

View file
 rem # input arguments
 rem # %1 - folder with 3rd party software
 rem # - HG repository is updated to head
+rem # Required env variables:
+rem #    PUBLISH_URL - url (user@host) of the publish server
+rem #    ID_KEY - identity key file for logging into publish server
 
 call updateSetVariables__.btm snapshot
 set WIN_SNAPSHOT=orange-win-snapshot-hg-%daystr
 
 break_on_error
 
-rem # build msi file (disabled due to StrictVersion requirement for .msi)
-rem e:\Python27\python.exe setup.py bdist_msi
+move /z dist\Orange-?.*.zip %TMPDIR\%SOURCE_SNAPSHOT
 
-break_on_error
+cd %TMPDIR
+rem # remember new filenames
+call "%SCRIPTDIR\updateVersionsPy__.btm" filenames_win.set
 
 rem # if no errors then publish on web (everything at the same time)
-rem # remove any old files  
-rem # leave 10 latest versions.
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orange-win-snapshot-hg-*.exe'), reverse=True)[30:]]"
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orange-win-w-python-snapshot-hg-*.exe'), reverse=True)[30:]]"
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orangeAddOn-bioinformatics-snapshot-hg-*.exe'), reverse=True)[30:]]"
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orangeAddOn-text-snapshot-hg-*.exe'), reverse=True)[30:]]"
 
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orange-source-snapshot-hg-*.zip'), reverse=True)[10:]]"
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orange-win-snapshot-hg-*.exe'), reverse=True)[10:]]"
-e:\Python27\python.exe -c"import os,glob; [os.remove(f) for f in sorted(glob.glob('%DOWNLOADDIR\orange-win-snapshot-hg-*.msi'), reverse=True)[10:]]"
+rem # Create a ftp batch script "move.scr".
+rem # (problem is sftp does not support an atomic move operation)
 
-rem except (%DOWNLOADDIR\orange*-snapshot-%daystr-*.exe) del %DOWNLOADDIR\orange*-snapshot-????-??-??-*.exe
+echo cd files > move.scr
 
-rem # publish
+for %FILENAME in (*.exe) do (
+	echo put %FILENAME %FILENAME.tmp >> move.scr
+	echo rm %FILENAME >> move.scr
+	echo rename %FILENAME.tmp %FILENAME >> move.scr
+)
 
-move /z dist\Orange-?.*.zip %DOWNLOADDIR\%SOURCE_SNAPSHOT
-move /z dist\Orange-?.*.msi %DOWNLOADDIR\%WIN_SNAPSHOT.msi
+echo put %SOURCE_SNAPSHOT %SOURCE_SNAPSHOT.tmp >> move.scr
+echo rm  %SOURCE_SNAPSHOT >> move.scr
+echo rename %SOURCE_SNAPSHOT.tmp %SOURCE_SNAPSHOT >> move.scr
 
-cdd %TMPDIR
-move /z *.exe %DOWNLOADDIR
-if not direxist %DOWNLOADDIR\binaries mkdir %DOWNLOADDIR\binaries
-move /sdz binaries %DOWNLOADDIR\binaries
+echo put filenames_win.set filenames_win.set.tmp >> move.scr
+echo rm filenames_win.set >> move.scr
+echo rename filenames_win.set.tmp filenames_win.set >> move.scr
 
-rem # remember new filenames
-cdd %SCRIPTDIR
-call updateVersionsPy__.btm
+echo exit >> move.scr
+
+rem # Finally move all the files
+psftp -i "%ID_KEY%" %PUBLISH_URL% -batch -be -b move.scr
+
+rem # Cleanup
+del /Q *.exe
+del /Q *.zip

File install-scripts/dailyBuild.btm

View file
+cdd E:\orange\scripts
+
+set PATH=C:\putty\bin;%PATH%
+set ID_KEY=%USERPROFILE%\ssh\id_rsa.ppk
+set PUBLISH_URL=download@biolab.si
+
+call updateAndCall.btm
+
+exit

File install-scripts/regressionTests.btm

-pushd
-cd ..
-
-copy o:\%WIN_SNAPSHOT-py%@left[1,%1].%@right[1,%1].exe orange-snap.exe
-break_on_error
-
-orange-snap.exe /S
-break_on_error
-
-cd regressionTests
-c:\python%1\python xtest.py test
-flag_on_error
-
-popd

File install-scripts/updateAndCall.btm

View file
 
 cdd e:\orange\scripts
-
-
-REM # Until orange-install-scripts repo is up this does not yet run
-REM call hg clone https://bitbucket.org/biolab/orange-install-scripts .
-REM call hg pull --update 
+ 
 
 REM call hg clone https://bitbucket.org/biolab/orange snapshot
 cdd snapshot
 copy /q /s snapshot\install-scripts\qt44-3rdparty qt44-3rdparty
 
 call callCreateSnapshot.btm
-shutdown -s

File install-scripts/updateAndCallRegress.btm

-cdd c:\orange\scripts
-"C:\Program Files\cvsnt\cvs.exe" -d :sspi;username=cvso;password=cvs0cvs0;hostname=estelle.fri.uni-lj.si:/cvs update
-call callRegression.btm
-shutdown -s

File install-scripts/updateDoc__.btm

-pushd
-
-cdd %SCRIPTDIR
-del /yqfsx tempdoc
-
-copy /sq %WEBDOCDIR tempdoc
-cd tempdoc
-
-del /qyfsx links.htm path.htm "writing documentation.txt" ofb\formulas\* >& nul:
-
-del %DOWNLOADDIR\orange-doc-snap-*.zip
-"c:\program files\winrar\winrar.exe" a -r %DOWNLOADDIR\orange-doc-snap-%daystr.zip *
-set DOCUMENTATION="orange-doc-snap-%daystr.zip"
-cd  ..
-
-del /yqfsx tempdoc
-
-popd

File install-scripts/updateSetVariables__.btm

View file
 set SCRIPTDIR=%_CWD
 set TMPDIR=%SCRIPTDIR\%1
 set SOURCEDIR=%TMPDIR\source
-set DOWNLOADDIR=Z:\Volumes\download\
-
-REM # read filenames of current packages
-set /r %DOWNLOADDIR\filenames_win.set
 
 set daystr=%_YEAR-%@format[02,%_MONTH]-%@format[02,%_DAY]
 set nicedate=%_DAY %@INSTR[%@EVAL[3*%_MONTH-3],3,JanFebMarAprMayJunJulAugSepOctNovDec] %_YEAR
 REM # python, packaging and compiling
 set PYTHONBASE=e:\Python
 set PYTHONVERSIONS=26 27
-REM # text mining can not be compiled for Python 23
-set PYTHONVERSIONS_ADDONs=25 26 27
+
+set PYTHONVERSIONS_ADDONs=26 27
 alias python="%PYTHONBASE%27\python.exe"
-set .py="%PYTHONBASE%25\python.exe"
 
 alias nsis="c:\program files\nsis\makensis.exe"
-alias winrar="c:\program files\winrar\winrar.exe"
-alias upx="c:\program files\upx.exe"
 alias cmake="c:\program files\cmake 2.8\bin\cmake.exe"
 set QTVARS="e:\Qt\4.7.3\bin\qtvars.bat"
 call "c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"

File install-scripts/updateVersionsPy__.btm

View file
 @echo off
-set fhandle=%@FILEOPEN[%DOWNLOADDIR\filenames_win.set, write, t]
+set fhandle=%@FILEOPEN[%1, write, t]
 set foo=%@FILEWRITE[%fhandle,VERSION=%VERSION]
 set foo=%@FILEWRITE[%fhandle,RELEASE_DATE=%RELEASE_DATE]
 

File source/orangeqt/setup.py

View file
-#!usr/bin/env python
+#!/usr/bin/env python
 
-import os, sys
+import os
+import sys
+import shlex
+from collections import namedtuple
+from ConfigParser import SafeConfigParser
+
+from setuptools import setup
+
+from distutils.core import Extension
+from distutils import dir_util, spawn, log
+
+import glob
+import numpy
+
+import sipdistutils
 
 try:
-    from setuptools import setup
-    have_setuptools = True
+    from PyQt4 import pyqtconfig
 except ImportError:
-    from distutils.core import setup
-    have_setuptools = False
+    pyqtconfig = None
 
-from distutils.core import Extension
-from distutils import log
+try:
+    from PyQt4.QtCore import PYQT_CONFIGURATION
+except ImportError:
+    PYQT_CONFIGURATION = None
 
-import subprocess
-import glob
-import numpy
+pjoin = os.path.join
 
 NAME                = 'orangeqt-qt'
 DESCRIPTION         = 'orangeqt ploting library'
 VERSION             = '0.0.1a'
 
 
+pyqt_conf = namedtuple(
+    "pyqt_conf",
+    ["sip_flags",
+     "sip_dir"]
+)
 
-import PyQt4.QtCore
+qt_conf = namedtuple(
+    "qt_conf",
+    ["prefix",
+     "include_dir",
+     "library_dir",
+     "framework",
+     "framework_dir"]
+)
 
-from PyQt4 import pyqtconfig 
+config = namedtuple(
+    "config",
+    ["sip",
+     "pyqt_conf",
+     "qt_conf"]
+)
 
-cfg = pyqtconfig.Configuration()
-pyqt_sip_dir = cfg.pyqt_sip_dir
+pyqt_sip_dir = None
+pyqt_sip_flags = None
 
-import sipdistutils
+qt_dir = None
+qt_include_dir = None
+qt_lib_dir = None
+qt_framework = False
+
+# use PyQt4 build time config if provided
+if pyqtconfig is not None:
+    cfg = pyqtconfig.Configuration()
+    pyqt_sip_dir = cfg.pyqt_sip_dir
+    pyqt_sip_flags = cfg.pyqt_sip_flags
+
+    qt_dir = cfg.qt_dir
+    qt_include_dir = cfg.qt_inc_dir
+    qt_lib_dir = cfg.qt_lib_dir
+    qt_framework = bool(cfg.qt_framework)
+    qt_framework_dir = qt_lib_dir
+
+elif PYQT_CONFIGURATION is not None:
+    pyqt_sip_flags = PYQT_CONFIGURATION["sip_flags"]
+
+
+# if QTDIR env is defined use it
+if "QTDIR" in os.environ:
+    qt_dir = os.environ["QTDIR"]
+    if sys.platform == "darwin":
+        if glob(pjoin(qt_dir, "lib", "Qt*.framework")):
+            # This is the standard Qt4 framework layout
+            qt_framework = True
+            qt_framework_dir = pjoin(qt_dir, "lib")
+        elif glob(pjoin(qt_dir, "Frameworks", "Qt*.framework")):
+            # Also worth checking (standard for bundled apps)
+            qt_framework = True
+            qt_framework_dir = pjoin(qt_dir, "Frameworks")
+
+    if not qt_framework:
+        # Assume standard layout
+        qt_framework = False
+        qt_include_dir = pjoin(qt_dir, "include")
+        qt_lib_dir = pjoin(qt_dir, "lib")
+
 
 extra_compile_args = []
 extra_link_args = []
 include_dirs = []
 library_dirs = []
 
+
+def site_config():
+    parser = SafeConfigParser(dict(os.environ))
+    parser.read(["site.cfg",
+                 os.path.expanduser("~/.orangeqt-site.cfg")])
+
+    def get(section, option, default=None, type=None):
+        if parser.has_option(section, option):
+            if type is None:
+                return parser.get(section, option)
+            elif type is bool:
+                return parser.getboolean(section, option)
+            elif type is int:
+                return parser.getint(section, option)
+            else:
+                raise TypeError
+        else:
+            return default
+
+    sip_bin = get("sip", "sip_bin")
+
+    sip_flags = get("pyqt", "sip_flags", default=pyqt_sip_flags)
+    sip_dir = get("pyqt", "sip_dir", default=pyqt_sip_dir)
+
+    if sip_flags is not None:
+        sip_flags = shlex.split(sip_flags)
+    else:
+        sip_flags = []
+
+    prefix = get("qt", "qt_dir", default=qt_dir)
+    include_dir = get("qt", "include_dir", default=qt_include_dir)
+    library_dir = get("qt", "library_dir", default=qt_lib_dir)
+    framework = get("qt", "framework", default=qt_framework, type=bool)
+    framework_dir = get("qt", "framework_dir", default=qt_framework_dir)
+
+    def path_list(path):
+        if path and path.strip():
+            return path.split(os.pathsep)
+        else:
+            return []
+
+    include_dir = path_list(include_dir)
+    library_dir = path_list(library_dir)
+
+    conf = config(
+        sip_bin,
+        pyqt_conf(sip_flags, sip_dir),
+        qt_conf(prefix, include_dir, library_dir,
+                framework, framework_dir)
+    )
+    return conf
+
+site_cfg = site_config()
+
 if sys.platform == "darwin":
     sip_plaftorm_tag = "WS_MACX"
 elif sys.platform == "win32":
 else:
     sip_plaftorm_tag = ""
 
+def which(name):
+    """
+    Return the path of program named 'name' on the $PATH.
+    """
+    if os.name == "nt" and not name.endswith(".exe"):
+        name = name + ".exe"
+
+    for path in os.environ["PATH"].split(os.pathsep):
+        path = os.path.join(path, name)
+        if os.path.isfile(path) and os.access(path, os.X_OK):
+            return path
+
+    return None
+
+
 class PyQt4Extension(Extension):
     pass
 
+
 class build_pyqt_ext(sipdistutils.build_ext):
+    """
+    A build_ext command for building PyQt4 sip based extensions
+    """
     description = "Build a orangeqt PyQt4 extension."
-    
-    user_options = sipdistutils.build_ext.user_options + \
-        [("required", None,  
-          "orangeqt is required (failure to build will raise an error)")]
-        
-    boolean_options = sipdistutils.build_ext.boolean_options + \
-        ["required"]
-    
-    def initialize_options(self):
-        sipdistutils.build_ext.initialize_options(self)
-        self.required = False
-        
+
     def finalize_options(self):
         sipdistutils.build_ext.finalize_options(self)
-        self.sip_opts = self.sip_opts + ["-k", "-j", "1", "-t", 
-                        sip_plaftorm_tag, "-t",
-                        "Qt_" + PyQt4.QtCore.QT_VERSION_STR.replace('.', '_')]
-        if self.required is not None:
-            self.required = True
+        self.sip_opts = self.sip_opts + \
+                        site_cfg.pyqt_conf.sip_flags + \
+                        ["-j", "1"]  # without -j1 it does not build (??)
 
     def build_extension(self, ext):
         if not isinstance(ext, PyQt4Extension):
             return
-        cppsources = [source for source in ext.sources if source.endswith(".cpp")]
-        if not os.path.exists(self.build_temp):
-            os.makedirs(self.build_temp)
+
+        cppsources = [source for source in ext.sources
+                      if source.endswith(".cpp")]
+
+        dir_util.mkpath(self.build_temp, dry_run=self.dry_run)
+
+        # Run moc on all header files.
         for source in cppsources:
             header = source.replace(".cpp", ".h")
             if os.path.exists(header):
                 moc_file = os.path.basename(header).replace(".h", ".moc")
-                call_arg = ["moc", "-o", os.path.join(self.build_temp, moc_file), header]
-                log.info("Calling: " + " ".join(call_arg))
-                try:
-                    subprocess.call(call_arg)
-                except OSError:
-                    raise OSError("Could not locate 'moc' executable.")
-        ext.extra_compile_args = ext.extra_compile_args + ["-I" + self.build_temp]
+                out_file = os.path.join(self.build_temp, moc_file)
+                call_arg = ["moc", "-o", out_file, header]
+                spawn.spawn(call_arg, dry_run=self.dry_run)
+
+        # Add the temp build directory to include path, for compiler to find
+        # the created .moc files
+        ext.include_dirs = ext.include_dirs + [self.build_temp]
+
         sipdistutils.build_ext.build_extension(self, ext)
-    
-    def run(self):
-        try:
-            sipdistutils.build_ext.run(self)
-        except Exception as ex:
-            if self.required:
-                raise
-            else:
-                log.info("Could not build orangeqt extension (%r)\nSkipping." % ex)
+
+    def _find_sip(self):
+        if site_cfg.sip:
+            log.info("Using sip at %r (from .cfg file)" % site_cfg.sip)
+            return site_cfg.sip
+
+        # Try the base implementation
+        sip = sipdistutils.build_ext._find_sip(self)
+        if os.path.isfile(sip):
+            return sip
+
+        log.warn("Could not find sip executable at %r." % sip)
+
+        # Find sip on $PATH
+        sip = which("sip")
+
+        if sip:
+            log.info("Found sip on $PATH at: %s" % sip)
+            return sip
+
+        return sip
 
     # For sipdistutils to find PyQt4's .sip files
     def _sip_sipfiles_dir(self):
-        return pyqt_sip_dir
+        if site_cfg.pyqt_conf.sip_dir:
+            return site_cfg.pyqt_conf.sip_dir
+
+        if os.path.isdir(pyqt_sip_dir):
+            return pyqt_sip_dir
+
+        log.warn("The default sip include directory %r does not exist" %
+                 pyqt_sip_dir)
+
+        path = os.path.join(sys.prefix, "share/sip/PyQt4")
+        if os.path.isdir(path):
+            log.info("Found sip include directory at %r" % path)
+            return path
+
+        return "."
 
 
 def get_source_files(path, ext="cpp", exclude=[]):
     return files
 
 
-# Used Qt4 libs
-qt_libs = ["QtCore", "QtGui", "QtOpenGL"]
+# Used Qt4 libraries
+qt_libs = ["QtCore", "QtGui"]
 
-
-if cfg.qt_framework:
-    extra_compile_args = ["-F%s" % cfg.qt_lib_dir]
-    extra_link_args = ["-F%s" % cfg.qt_lib_dir]
+if site_cfg.qt_conf.framework:
+    framework_dir = site_cfg.qt_conf.framework_dir
+    extra_compile_args = ["-F%s" % framework_dir]
+    extra_link_args = ["-F%s" % framework_dir]
     for lib in qt_libs:
-        include_dirs += [os.path.join(cfg.qt_lib_dir,
+        include_dirs += [os.path.join(framework_dir,
                                       lib + ".framework", "Headers")]
         extra_link_args += ["-framework", lib]
-#    extra_link_args += ["-framework", "OpenGL"]
     qt_libs = []
 else:
-    include_dirs = [cfg.qt_inc_dir] + \
-                   [os.path.join(cfg.qt_inc_dir, lib) for lib in qt_libs]
-    library_dirs += [cfg.qt_lib_dir]
+    include_dirs = [site_cfg.qt_conf.include_dir] + \
+                   [pjoin(site_cfg.qt_conf.include_dir, lib)
+                    for lib in qt_libs]
+    library_dirs += [site_cfg.qt_conf.library_dir]
 
 if sys.platform == "win32":
     # Qt libs on windows have a 4 added
 
 include_dirs += [numpy.get_include(), "./"]
 
-orangeqt_ext = PyQt4Extension("orangeqt",
-                              ["orangeqt.sip"] + get_source_files("", "cpp",
-                               exclude=["canvas3d.cpp", "plot3d.cpp", "glextensions.cpp"]
-                               ),
-                              include_dirs=include_dirs,
-                              extra_compile_args=extra_compile_args + \
-                                                   ["-DORANGEQT_EXPORTS"],
-                              extra_link_args=extra_link_args,
-                              libraries = qt_libs,
-                              library_dirs=library_dirs
-                             )
+orangeqt_ext = PyQt4Extension(
+    "orangeqt",
+    ["orangeqt.sip"] + get_source_files(
+        "", "cpp",
+        exclude=["canvas3d.cpp", "plot3d.cpp", "glextensions.cpp"]
+     ),
+    include_dirs=include_dirs,
+    extra_compile_args=extra_compile_args + \
+                         ["-DORANGEQT_EXPORTS"],
+    extra_link_args=extra_link_args,
+    libraries=qt_libs,
+    library_dirs=library_dirs
+)
 
 ENTRY_POINTS = {
     'orange.addons': (
     ),
 }
 
+
 def setup_package():
-    setup(name = NAME,
-          description = DESCRIPTION,
-          version = VERSION,
-          author = AUTHOR,
-          author_email = AUTHOR_EMAIL,
-          url = URL,
-          license = LICENSE,
-          ext_modules = [orangeqt_ext],
+    setup(name=NAME,
+          description=DESCRIPTION,
+          version=VERSION,
+          author=AUTHOR,
+          author_email=AUTHOR_EMAIL,
+          url=URL,
+          license=LICENSE,
+          ext_modules=[orangeqt_ext],
           cmdclass={"build_ext": build_pyqt_ext},
-          entry_points = ENTRY_POINTS,
+          entry_points=ENTRY_POINTS,
           )
 
 if __name__ == '__main__':

File source/orangeqt/site.cfg.example

View file
+###################
+# sip configuration
+###################
+
+[sip]
+#sip_bin = /usr/local/bin/sip
+
+
+#####################
+# PyQt4 configuration
+#####################
+
+[pyqt4]
+
+## Directory where PyQt4's .sip interface files are installed
+#sip_dir = /usr/local/share/sip
+
+## sip flags used to build PyQt4
+#sip_flags = -t Qt_4_8_5
+
+
+
+###################
+# Qt4 configuration
+###################
+
+[qt4]
+
+## Base Qt installation dir (QTDIR can be passed by env vars)
+#prefix = %(QTDIR)
+#include_dir = %(qt_dir)/include
+#library_dir = %(qt_dir)/lib
+
+## OSX specific; will override the default include/library dirs
+#framework = true
+#framework_dir = %(qt_dir)/lib