def generate_code(self, config): sip_install_dir = os.path.join(config.default_sip_dir, "skia") module_install_dir = os.path.join(config.default_mod_dir, "skia") for module in self.MODULES: # Calculate SIP module folder and scan for .sip files module_dir = os.path.join(self.SIP_DIR, module) sipconfig.inform("Processing {}...".format(module_dir)) # Calculate module paths sip_file = os.path.join(module_dir, "{}.sip".format(module)) build_dir = os.path.join(self.BUILD_DIR, module) build_file = os.path.join(build_dir, "{}.sbf".format(module)) # Creating paths if not os.path.exists(build_dir): os.makedirs(build_dir) # Execute 'sip' command cmd = [ config.sip_bin, "-c", build_dir, "-b", build_file, sip_file ] if subprocess.call(cmd): sipconfig.error(sip_file) sys.exit(1) # Generate module Makefile sipconfig.inform("Generating Makefile for '{}'...".format(module)) makefile = sipconfig.SIPModuleMakefile( config, build_file, dir=build_dir, install_dir=module_install_dir, installs=[(sip_file, os.path.join(sip_install_dir, module))], makefile=os.path.join(build_dir, "Makefile") ) makefile.extra_lib_dirs = [config.skia_libs_dir] makefile.extra_include_dirs = config.skia_includes makefile.extra_libs = config.skia_libs makefile.extra_lflags = ["-framework ApplicationServices"] makefile.generate() # Generate parent Makefile sipconfig.inform("Generating main Makefile...") sipconfig.ParentMakefile( configuration=config, subdirs=[os.path.join(self.BUILD_DIR, m) for m in self.MODULES], installs=[(f, config.skia_mod_dir) for f in self.package_installs], ).generate()
def mk_clean_dir(name): """Create a clean (ie. empty) directory. name is the name of the directory. """ try: shutil.rmtree(name) except: pass try: os.makedirs(name) except: sipconfig.error("Unable to create the %s directory." % name)
def check_qscintilla(): """See if QScintilla can be found and what its version is. """ # Find the QScintilla header files. sciglobal = os.path.join(opts.qsciincdir, "Qsci", "qsciglobal.h") if os.access(sciglobal, os.F_OK): # Get the QScintilla version string. _, sciversstr = sipconfig.read_version(sciglobal, "QScintilla", "QSCINTILLA_VERSION", "QSCINTILLA_VERSION_STR") if glob.glob(os.path.join(opts.qscilibdir, "*qscintilla2*")): # Because we include the Python bindings with the C++ code we can # reasonably force the same version to be used and not bother about # versioning. if sciversstr != "2.10.8": sipconfig.error( "QScintilla %s is being used but the Python bindings 2.10.8 are being built. Please use matching versions." % sciversstr) sipconfig.inform("QScintilla %s is being used." % sciversstr) else: sipconfig.error( "The QScintilla library could not be found in %s. If QScintilla is installed then use the -o argument to explicitly specify the correct directory." % opts.qscilibdir) else: sipconfig.error( "Qsci/qsciglobal.h could not be found in %s. If QScintilla is installed then use the -n argument to explicitly specify the correct directory." % opts.qsciincdir)
def check_qscintilla(): """See if QScintilla can be found and what its version is. """ # Find the QScintilla header files. sciglobal = os.path.join(opts.qsciincdir, "Qsci", "qsciglobal.h") if os.access(sciglobal, os.F_OK): # Get the QScintilla version string. _, sciversstr = sipconfig.read_version(sciglobal, "QScintilla", "QSCINTILLA_VERSION", "QSCINTILLA_VERSION_STR") if glob.glob(os.path.join(opts.qscilibdir, "*qscintilla2*")): # Because we include the Python bindings with the C++ code we can # reasonably force the same version to be used and not bother about # versioning. if sciversstr != "2.9.1": sipconfig.error("QScintilla %s is being used but the Python bindings 2.9.1 are being built. Please use matching versions." % sciversstr) sipconfig.inform("QScintilla %s is being used." % sciversstr) else: sipconfig.error("The QScintilla library could not be found in %s. If QScintilla is installed then use the -o argument to explicitly specify the correct directory." % opts.qscilibdir) else: sipconfig.error("Qsci/qsciglobal.h could not be found in %s. If QScintilla is installed then use the -n argument to explicitly specify the correct directory." % opts.qsciincdir)
except: pyqt4 = None try: import pyqtconfig as pyqt3 except: pyqt3 = None if pyqt4 is not None: pyqt = pyqt4.Configuration() qt_data_dir = pyqt.qt_data_dir elif pyqt3 is not None: pyqt = pyqt3.Configuration() qt_data_dir = pyqt.qt_dir else: sipconfig.error("Unable to find either PyQt v3 or v4.") # This must be kept in sync with Python/configure.py, qscintilla.pro, # example-Qt4Qt5/application.pro and designer-Qt4Qt5/designer.pro. QSCI_API_MAJOR = 12 # Initialise the globals. sip_min_version = 0x040c00 if sys.platform == "win32": qsci_define = "QSCINTILLA_DLL" else: qsci_define = ""
def main(argv): """Create the configuration module module. argv is the list of command line arguments. """ try: optlist, args = getopt.getopt(argv[1:], "hcd:gj:kn:o:ruv:w") except getopt.GetoptError: usage() global opt_pyqmmpmoddir, opt_pyqmmpsipdir global opt_qmmpincdir, opt_qmmplibdir global opt_static, opt_debug, opt_concat, opt_releasegil, opt_split global opt_tracing, opt_verbose """ for opt, arg in optlist: if opt == "-h": usage(0) elif opt == "-c": opt_concat = 1 elif opt == "-d": opt_pyqmmpmoddir = arg elif opt == "-g": opt_releasegil = 1 elif opt == "-j": try: opt_split = int(arg) except: usage() elif opt == "-k": opt_static = 1 elif opt == "-n": opt_qmmpincdir = arg elif opt == "-o": opt_qmmplibdir = arg elif opt == "-r": opt_tracing = 1 elif opt == "-u": opt_debug = 1 elif opt == "-v": opt_pyqmmpsipdir = arg elif opt == "-w": opt_verbose = 1 if args: usage() """ # check_license() sipconfig.inform("SIP %s is being used." % pyqtcfg.sip_version_str) # Check SIP is new enough. if pyqtcfg.sip_version_str[:8] != "snapshot": minv = None if pyqtcfg.sip_version >= 0x040000: if pyqtcfg.sip_version < sip_min_v4_version: minv = sip_min_v4_version else: if pyqtcfg.sip_version < sip_min_v3_version: minv = sip_min_v3_version if minv: sipconfig.error("This version of PyQMMP requires SIP v%s or later" % sipconfig.version_to_string(minv)) # Check for . # check_qmmp() # If wasn't found then there is no point carrying on. An # appropriate error message will already have been displayed. # if qmmp_version is None: # sys.exit(1) # Set the SIP platform, version and feature flags. set_sip_flags() # Tell the user what's been found. inform_user() lib_dir = "../../" # if opt_qmmplibdir != "../lib": # lib_dir = opt_qmmplibdir # Generate the code. generate_code( "qmmp", imports=["PyQt4"], extra_define=qmmp_define, extra_include_dir=opt_qmmpincdir, extra_lib_dir=lib_dir, extra_lib="qmmp", sip_flags=qmmp_sip_flags, ) # Create the additional Makefiles. create_makefiles() # Install the configuration module. create_config("pyqmmpconfig.py", "pyqmmpconfig.py.in")
def generate_code( mname, imports=None, extra_cflags=None, extra_cxxflags="-I%s/Qt3Support/ -I%s/QtXml/ -I%s/QtGui/ -I%s -I../../ -L../../" % (pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir), extra_define=None, extra_include_dir=None, extra_lflags="-lQt3Support", extra_lib_dir=None, extra_lib=None, sip_flags=None, ): """Generate the code for a module. mname is the name of the module. imports is the list of PyQt modules that this one %Imports. extra_cflags is a string containing additional C compiler flags. extra_cxxflags is a string containing additional C++ compiler flags. extra_define is a name to add to the list of preprocessor defines. extra_include_dir is the name of a directory to add to the list of include directories. extra_lflags is a string containing additional linker flags. extra_lib_dir is the name of a directory to add to the list of library directories. extra_lib is the name of an extra library to add to the list of libraries. sip_flags is the list of sip flags to use instead of the defaults. """ sipconfig.inform("Generating the C++ source for the %s module..." % mname) try: shutil.rmtree(mname) except: pass try: os.mkdir(mname) except: sipconfig.error("Unable to create the %s directory." % mname) # Build the SIP command line. argv = [pyqtcfg.sip_bin] if sip_flags: argv.extend(sip_flags) if opt_concat: argv.append("-j") argv.append(str(opt_split)) if opt_tracing: argv.append("-r") if opt_releasegil: argv.append("-g") argv.append("-c") argv.append(mname) buildfile = os.path.join(mname, mname + ".sbf") argv.append("-b") argv.append(buildfile) argv.append("-I") argv.append(pyqtcfg.pyqt_sip_dir) # SIP assumes POSIX style path separators. argv.append(string.join(["sip", mname, mname + "mod.sip"], "/")) os.system(string.join(argv)) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Compile the Python stub. if pyqtcfg.sip_version < 0x040000: sipconfig.inform("Compiling %s.py..." % mname) py_compile.compile(os.path.join(mname, mname + ".py"), os.path.join(mname, mname + ".pyc")) # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) installs = [] if pyqtcfg.sip_version >= 0x040000: warnings = 1 else: warnings = 0 installs.append([[mname + ".py", mname + ".pyc"], opt_pyqmmpmoddir]) sipfiles = [] for s in glob.glob("sip/" + mname + "/*.sip"): sipfiles.append(os.path.join("..", "sip", mname, os.path.basename(s))) installs.append([sipfiles, os.path.join(opt_pyqmmpsipdir, mname)]) makefile = sipconfig.SIPModuleMakefile( configuration=pyqtcfg, build_file=mname + ".sbf", dir=mname, install_dir=opt_pyqmmpmoddir, installs=installs, qt=1, warnings=warnings, static=opt_static, debug=opt_debug, ) if extra_cflags: makefile.extra_cflags.append(extra_cflags) if extra_cxxflags: makefile.extra_cxxflags.append(extra_cxxflags) if extra_define: makefile.extra_defines.append(extra_define) if extra_include_dir: makefile.extra_include_dirs.append(extra_include_dir) if extra_lflags: makefile.extra_lflags.append(extra_lflags) if extra_lib_dir: makefile.extra_lib_dirs.append(extra_lib_dir) if extra_lib: makefile.extra_libs.append(extra_lib) if pyqtcfg.sip_version < 0x040000 and imports: # Inter-module links. for im in imports: makefile.extra_lib_dirs.insert(0, pyqtcfg.pyqt_mod_dir) makefile.extra_libs.insert(0, makefile.module_as_lib(im)) makefile.generate()
def check_license(): """Handle the validation of the PyQMMP license. """ try: import license ltype = license.LicenseType lname = license.LicenseName try: lfile = license.LicenseFile except AttributeError: lfile = None except ImportError: ltype = None if ltype is None: ltype = "GPL" lname = "GNU General Public License" lfile = None sipconfig.inform( "This is the %s version of PyQMMP %s (licensed under the %s) for Python %s on %s." % (ltype, pyqmmp_version_str, lname, string.split(sys.version)[0], sys.platform) ) # Common checks. if ltype == "GPL" and sys.platform == "win32": error("You cannot use the GPL version of PyQMMP under Windows.") try: qted = pyqtcfg.qt_edition except AttributeError: qted = None if qted: if (qted == "free" and ltype != "GPL") or (qted != "free" and ltype == "GPL"): sipconfig.error("This version of PyQMMP and the %s edition of Qt have incompatible licenses." % qted) # Confirm the license. print print "Type 'L' to view the license." print "Type 'yes' to accept the terms of the license." print "Type 'no' to decline the terms of the license." print while 1: try: resp = raw_input("Do you accept the terms of the license? ") except: resp = "" resp = string.lower(string.strip(resp)) if resp == "yes": break if resp == "no": sys.exit(0) if resp == "l": os.system("more LICENSE") # If there should be a license file then check it is where it should be. if lfile: if os.access(os.path.join("sip", lfile), os.F_OK): sipconfig.inform("Found the license file %s." % lfile) else: sipconfig.error("Please copy the license file %s to the sip directory." % lfile)
def generate_code(mname, include_dirs=None, lib_dirs=None, libs=None, extra_sip_flags=None, debug=0): """Generate the code for a module. mname is the name of the module to generate the code for. extra_include_dirs is an optional list of additional directories to add to the list of include directories. extra_lib_dirs is an optional list of additional directories to add to the list of library directories. extra_libs is an optional list of additional libraries to add to the list of libraries. extra_sip_flags is an optional list of additional flags to pass to SIP. """ sipconfig.inform("Generating the C++ source for the %s module..." % mname) modfile = mname + "mod.sip" builddir = abspath( join("build", mname, "release" if not debug else "debug")) #sanity check - avoid cleaning a directory full of .sip files! if exists(join(builddir, modfile)): raise RuntimeError( "SIP module target {} exists in build directory {}, aborting!". format(modfile, builddir)) #clean the build directory mk_clean_dir(builddir) # Build the SIP command line. argv = ['"' + pyqtcfg.sip_bin + '"'] argv.append(qt_sip_flags) if extra_sip_flags: argv.extend(extra_sip_flags) #enable debugging statements within sip if debug: argv.append("-r") # the directory where our cpp files are placed argv.append("-c") argv.append(builddir) buildfile = join(builddir, mname + ".sbf") argv.append("-b") argv.append(buildfile) argv.append("-I") argv.append(pyqtcfg.pyqt_sip_dir) argv.append("-I") argv.append(join(os.getcwdu(), mname)) # SIP assumes POSIX style path separators. argv.append(abspath(join(mname, modfile))) cmd = " ".join(argv) sys.stdout.write(cmd + "\n") #call sip.exe to generate our C++ code os.system(cmd) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) makefile = sipconfig.SIPModuleMakefile(configuration=pyqtcfg, build_file=buildfile, dir=builddir, install_dir=pyqt_modroot, qt=True, universal=pyqtcfg.universal, arch=pyqtcfg.arch, debug=debug, export_all=True, prot_is_public=False, threaded=True) add_makefile_extras(makefile, include_dirs, lib_dirs, libs) makefile.extra_cxxflags.append('-EHsc') makefile.extra_cflags.append("-Zi") makefile.extra_cxxflags.append("-Zi") makefile.extra_lflags.append("/DEBUG") makefile.extra_lflags.append("/PDB:{}.pdb".format(mname)) makefile.generate() return builddir
pyqmmp_version = 0x0001 pyqmmp_version_str = "0.0.1" sip_min_v3_version = 0x030B00 sip_min_v4_version = 0x040100 qt_min_version = 0x030000 # qmmp_sip_flags = [] # qmmp_version = None qmmp_define = "" # Get the PyQt configuration. pyqtcfg = pyqtconfig.Configuration() if pyqtcfg.qt_version == 0: sipconfig.error("SIP has been built with Qt support disabled.") # Command line options. opt_pyqmmpmoddir = pyqtcfg.default_mod_dir opt_pyqmmpsipdir = pyqtcfg.default_sip_dir opt_qmmpincdir = "../" # pyqtcfg.qt_inc_dir opt_qmmplibdir = "../" # pyqtcfg.qt_lib_dir opt_static = 0 opt_debug = 0 opt_concat = 0 opt_split = 1 opt_releasegil = 0 opt_tracing = 0 opt_verbose = 0
def main(argv): """Create the configuration module module. argv is the list of command line arguments. """ try: optlist, args = getopt.getopt(argv[1:], "hcd:gj:kn:o:ruv:w:q") except getopt.GetoptError: usage() global opt_pyqicstablemoddir, opt_pyqicstablesipdir global opt_qicstableincdir, opt_qicstablelibdir global opt_static, opt_debug, opt_concat, opt_releasegil, opt_split global opt_tracing, opt_verbose, opt_qicsTableDebug for opt, arg in optlist: if opt == "-h": usage(0) elif opt == "-c": opt_concat = 1 elif opt == "-d": opt_pyqicstablemoddir = arg elif opt == "-g": opt_releasegil = 1 elif opt == "-j": try: opt_split = int(arg) except: usage() elif opt == "-k": opt_static = 1 elif opt == "-n": opt_qicstableincdir = arg elif opt == "-o": opt_qicstablelibdir = arg elif opt == "-r": opt_tracing = 1 elif opt == "-u": opt_debug = 1 elif opt == "-v": opt_pyqicstablesipdir = arg elif opt == "-w": opt_verbose = 1 elif opt == "-q": opt_qicsTableDebug = 1 if args: usage() check_license() sipconfig.inform("SIP %s is being used." % pyqtcfg.sip_version_str) # Check SIP is new enough. if pyqtcfg.sip_version_str[:8] != "snapshot": minv = None if pyqtcfg.sip_version >= 0x040000: if pyqtcfg.sip_version < sip_min_v4_version: minv = sip_min_v4_version else: if pyqtcfg.sip_version < sip_min_v3_version: minv = sip_min_v3_version if minv: sipconfig.error( "This version of PyQicsTable requires SIP v%s or later" % sipconfig.version_to_string(minv)) # Check for QicsTable. check_qicstable() # If QicsTable wasn't found then there is no point carrying on. An # appropriate error message will already have been displayed. if qicstable_version is None: sys.exit(1) # Set the SIP platform, version and feature flags. set_sip_flags() # Tell the user what's been found. inform_user() lib_dir = "../../../lib" if opt_qicstablelibdir != "../../lib": lib_dir = opt_qicstablelibdir # Generate the code. libName = None if os.name == "nt": if opt_qicsTableDebug == 1: libName = "qicstabled2" else: libName = "qicstable2" else: if opt_qicsTableDebug == 1: libName = "qicstable_debug" else: libName = "qicstable" generate_code("qicstable", imports=["PyQt4"], extra_define=qicstable_define, extra_include_dir=opt_qicstableincdir, extra_lib_dir=lib_dir, extra_lib=libName, sip_flags=qicstable_sip_flags) # Create the additional Makefiles. create_makefiles() # Install the configuration module. create_config("pyqicstableconfig.py", "pyqicstableconfig.py.in")
def generate_code(): """Generate the code for the QScintilla module. """ if pyqt.pyqt_version >= 0x040000: mname = "Qsci" else: mname = "qsci" sipconfig.inform("Generating the C++ source for the %s module..." % mname) # Build the SIP command line. argv = ['"' + pyqt.sip_bin + '"'] argv.extend(sip_flags()) if opts.no_timestamp: argv.append("-T") if not opts.no_docstrings: argv.append("-o"); if opts.prot_is_public: argv.append("-P"); if opts.concat: argv.append("-j") argv.append(str(opts.split)) if opts.tracing: argv.append("-r") argv.append("-c") argv.append(".") buildfile = os.path.join("qsci.sbf") argv.append("-b") argv.append(buildfile) if pyqt.pyqt_version >= 0x040000: argv.append("sip/qscimod4.sip") else: argv.append("sip/qscimod3.sip") os.system(" ".join(argv)) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) def fix_install(mfile): if sys.platform != "darwin" or opts.static: return mfile.write("\tinstall_name_tool -change libqscintilla2.%u.dylib %s/libqscintilla2.%u.dylib $(DESTDIR)%s/$(TARGET)\n" % (QSCI_API_MAJOR, opts.qscilibdir, QSCI_API_MAJOR, opts.qscimoddir)) if pyqt.pyqt_version >= 0x040000: class Makefile(pyqt4.QtGuiModuleMakefile): def generate_target_install(self, mfile): pyqt4.QtGuiModuleMakefile.generate_target_install(self, mfile) fix_install(mfile) else: class Makefile(pyqt3.QtModuleMakefile): def generate_target_install(self, mfile): pyqt3.QtModuleMakefile.generate_target_install(self, mfile) fix_install(mfile) installs = [] sipfiles = [] for s in glob.glob("sip/*.sip"): sipfiles.append(os.path.join("sip", os.path.basename(s))) installs.append([sipfiles, os.path.join(opts.qscisipdir, mname)]) installs.append(("QScintilla2.api", os.path.join(opts.qscidir, "api", "python"))) # PyQt v4.2 and later can handle MacOS/X universal binaries. if pyqt.pyqt_version >= 0x040200: makefile = Makefile( configuration=pyqt, build_file="qsci.sbf", install_dir=opts.qscimoddir, installs=installs, static=opts.static, debug=opts.debug, universal=pyqt.universal, arch=pyqt.arch, prot_is_public=opts.prot_is_public, deployment_target=pyqt.deployment_target ) else: makefile = Makefile( configuration=pyqt, build_file="qsci.sbf", install_dir=opts.qscimoddir, installs=installs, static=opts.static, debug=opts.debug ) if qsci_define: makefile.extra_defines.append(qsci_define) makefile.extra_include_dirs.append(opts.qsciincdir) makefile.extra_lib_dirs.append(opts.qscilibdir) makefile.extra_libs.append("qscintilla2") makefile.generate()
def check_license(): """Handle the validation of the PyQicsTable license. """ try: import license ltype = license.LicenseType lname = license.LicenseName try: lfile = license.LicenseFile except AttributeError: lfile = None except ImportError: ltype = None if ltype is None: ltype = "GPL" lname = "GNU General Public License" lfile = None sipconfig.inform( "This is the %s version of PyQicsTable %s (licensed under the %s) for Python %s on %s." % (ltype, pyqicstable_version_str, lname, string.split( sys.version)[0], sys.platform)) # Common checks. if ltype == "GPL" and sys.platform == "win32": error("You cannot use the GPL version of PyQicsTable under Windows.") try: qted = pyqtcfg.qt_edition except AttributeError: qted = None if qted: if (qted == "free" and ltype != "GPL") or (qted != "free" and ltype == "GPL"): sipconfig.error( "This version of PyQicsTable and the %s edition of Qt have incompatible licenses." % qted) # Confirm the license. print print "Type 'L' to view the license." print "Type 'yes' to accept the terms of the license." print "Type 'no' to decline the terms of the license." print while 1: try: resp = raw_input("Do you accept the terms of the license? ") except: resp = "" resp = string.lower(string.strip(resp)) if resp == "yes": break if resp == "no": sys.exit(0) if resp == "l": os.system("more LICENSE") # If there should be a license file then check it is where it should be. if lfile: if os.access(os.path.join("sip", lfile), os.F_OK): sipconfig.inform("Found the license file %s." % lfile) else: sipconfig.error( "Please copy the license file %s to the sip directory." % lfile)
def generate_code( mname, imports=None, extra_cflags=None, extra_cxxflags="-I%s/QtCore/ -I%s/QtXml/ -I%s/QtGui/ -I%s -I../../../include -L../../../lib" % (pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir, pyqtcfg.qt_inc_dir), extra_define=None, extra_include_dir=None, extra_lflags=None, extra_lib_dir=None, extra_lib=None, sip_flags=None): """Generate the code for a module. mname is the name of the module. imports is the list of PyQt modules that this one %Imports. extra_cflags is a string containing additional C compiler flags. extra_cxxflags is a string containing additional C++ compiler flags. extra_define is a name to add to the list of preprocessor defines. extra_include_dir is the name of a directory to add to the list of include directories. extra_lflags is a string containing additional linker flags. extra_lib_dir is the name of a directory to add to the list of library directories. extra_lib is the name of an extra library to add to the list of libraries. sip_flags is the list of sip flags to use instead of the defaults. """ sipconfig.inform("Generating the C++ source for the %s module..." % mname) try: shutil.rmtree(mname) except: pass try: os.mkdir(mname) except: sipconfig.error("Unable to create the %s directory." % mname) # Build the SIP command line. argv = [pyqtcfg.sip_bin] if sip_flags: argv.extend(sip_flags) if opt_concat: argv.append("-j") argv.append(str(opt_split)) if opt_tracing: argv.append("-r") if opt_releasegil: argv.append("-g") argv.append("-c") argv.append(mname) buildfile = os.path.join(mname, mname + ".sbf") argv.append("-b") argv.append(buildfile) argv.append("-I") argv.append(pyqtcfg.pyqt_sip_dir) # SIP assumes POSIX style path separators. argv.append(string.join(["sip", mname, mname + "mod.sip"], "/")) os.system(string.join(argv)) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Compile the Python stub. if pyqtcfg.sip_version < 0x040000: sipconfig.inform("Compiling %s.py..." % mname) py_compile.compile(os.path.join(mname, mname + ".py"), os.path.join(mname, mname + ".pyc")) # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) installs = [] if pyqtcfg.sip_version >= 0x040000: warnings = 1 else: warnings = 0 installs.append([[mname + ".py", mname + ".pyc"], opt_pyqicstablemoddir]) sipfiles = [] for s in glob.glob("sip/" + mname + "/*.sip"): sipfiles.append(os.path.join("..", "sip", mname, os.path.basename(s))) installs.append([sipfiles, os.path.join(opt_pyqicstablesipdir, mname)]) makefile = sipconfig.SIPModuleMakefile(configuration=pyqtcfg, build_file=mname + ".sbf", dir=mname, install_dir=opt_pyqicstablemoddir, installs=installs, qt=1, warnings=warnings, static=opt_static, debug=opt_debug) if extra_cflags: makefile.extra_cflags.append(extra_cflags) if extra_cxxflags: makefile.extra_cxxflags.append(extra_cxxflags) if extra_define: makefile.extra_defines.append(extra_define) if extra_include_dir: makefile.extra_include_dirs.append(extra_include_dir) if extra_lflags: makefile.extra_lflags.append(extra_lflags) if extra_lib_dir: makefile.extra_lib_dirs.append(extra_lib_dir) if extra_lib: makefile.extra_libs.append(extra_lib) if pyqtcfg.sip_version < 0x040000 and imports: # Inter-module links. for im in imports: makefile.extra_lib_dirs.insert(0, pyqtcfg.pyqt_mod_dir) makefile.extra_libs.insert(0, makefile.module_as_lib(im)) makefile.generate()
pyqicstable_version = 0x030000 pyqicstable_version_str = "3.0.0" sip_min_v3_version = 0x030b00 sip_min_v4_version = 0x040100 qt_min_version = 0x040200 qicstable_sip_flags = [] qicstable_version = None qicstable_define = "CREATE_OBJS_WITH_QICSTABLE" # Get the PyQt configuration. pyqtcfg = pyqtconfig.Configuration() if pyqtcfg.qt_version == 0: sipconfig.error("SIP has been built with Qt support disabled.") # Command line options. opt_pyqicstablemoddir = pyqtcfg.default_mod_dir opt_pyqicstablesipdir = pyqtcfg.default_sip_dir opt_qicstableincdir = "../../include" #pyqtcfg.qt_inc_dir opt_qicstablelibdir = "../../lib" #pyqtcfg.qt_lib_dir opt_static = 0 opt_debug = 0 opt_concat = 0 opt_split = 1 opt_releasegil = 0 opt_tracing = 0 opt_verbose = 0 opt_qicsTableDebug = 0
def main(argv): """Create the configuration module module. argv is the list of command line arguments. """ global pyqt # Check SIP is new enough. if "snapshot" not in pyqt.sip_version_str: if pyqt.sip_version < sip_min_version: sipconfig.error("This version of Fresh requires SIP v%s or later" % sipconfig.version_to_string(sip_min_version)) # Parse the command line. global opts p = create_optparser() opts, args = p.parse_args() if args: p.print_help() sys.exit(2) if opts.not_dll: global fresh_define fresh_define = "" # Set the version of PyQt explicitly. global qt_data_dir if pyqt4 is None: sipconfig.error("PyQt v4 was specified with the -p argument but doesn't seem to be installed.") else: pyqt = pyqt4.Configuration() qt_data_dir = pyqt.qt_data_dir # Now we know which version of PyQt to use we can set defaults for those # arguments that weren't specified. if opts.freshmoddir is None: opts.freshmoddir = pyqt.pyqt_mod_dir if not os.path.exists(opts.freshmoddir): print 'Invalid PyQt4 installation path in the PyQt4.pyqtconfig. Trying to detect automatically' import PyQt4 opts.freshmoddir = os.path.dirname(PyQt4.__file__) if os.path.exists(opts.freshmoddir): print 'Detected' else: sipconfig.error("PyQt installation path not detected") if opts.freshincdir is None: opts.freshincdir = pyqt.qt_inc_dir if opts.freshlibdir is None: opts.freshlibdir = pyqt.qt_lib_dir if opts.freshsipdir is None: opts.freshsipdir = pyqt.pyqt_sip_dir if opts.freshdir is None: opts.freshdir = os.path.join(qt_data_dir, "fresh") """ # Check for Fresh. check_qscintilla() """ # Tell the user what's been found. inform_user() # Generate the code. generate_code()
def generate_code(): """Generate the code for the Fresh module. """ mname = "fresh" sipconfig.inform("Generating the C++ source for the %s module..." % mname) # Build the SIP command line. argv = ['"' + pyqt.sip_bin + '"'] argv.extend(sip_flags()) if not opts.no_docstrings: argv.append("-o"); if opts.concat: argv.append("-j") argv.append(str(opts.split)) if opts.tracing: argv.append("-r") argv.append("-c") argv.append(".") buildfile = os.path.join("fresh.sbf") argv.append("-b") argv.append(buildfile) if pyqt.pyqt_version >= 0x040000: argv.append("../Python/sip/fresh.sip") os.system(" ".join(argv)) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) def fix_install(mfile): if sys.platform != "darwin" or opts.static: return mfile.write("\tinstall_name_tool -change libqscintilla2.%u.dylib %s/libqscintilla2.%u.dylib $(DESTDIR)%s/$(TARGET)\n" % (FRESH_API_MAJOR, opts.freshlibdir, FRESH_API_MAJOR, opts.freshmoddir)) if pyqt.pyqt_version >= 0x040000: class Makefile(pyqt4.QtGuiModuleMakefile): def generate_target_install(self, mfile): pyqt4.QtGuiModuleMakefile.generate_target_install(self, mfile) fix_install(mfile) else: class Makefile(pyqt3.QtModuleMakefile): def generate_target_install(self, mfile): pyqt3.QtModuleMakefile.generate_target_install(self, mfile) fix_install(mfile) installs = [] sipfiles = [] for s in glob.glob("sip/*.sip"): sipfiles.append(os.path.join("sip", os.path.basename(s))) installs.append([sipfiles, os.path.join(opts.freshsipdir, mname)]) installs.append(("fresh.api", os.path.join(opts.freshdir, "api", "python"))) makefile = Makefile( configuration=pyqt, build_file="fresh.sbf", install_dir=opts.freshmoddir, installs=installs, static=opts.static, debug=opts.debug, universal=pyqt.universal) if fresh_define: makefile.extra_defines.append(fresh_define) makefile.extra_include_dirs.append('..') makefile.extra_include_dirs.append(opts.freshincdir) makefile.extra_lib_dirs.append(opts.freshlibdir) makefile.extra_lib_dirs.append('../build') makefile.extra_libs.append("cppfresh") makefile.generate()
def main(argv): """Create the configuration module module. argv is the list of command line arguments. """ global pyqt # Check SIP is new enough. if "preview" not in pyqt.sip_version_str and "snapshot" not in pyqt.sip_version_str: if pyqt.sip_version < sip_min_version: sipconfig.error("This version of QScintilla requires SIP v%s or later" % sipconfig.version_to_string(sip_min_version)) # Parse the command line. global opts p = create_optparser() opts, args = p.parse_args() if args: p.print_help() sys.exit(2) # Provide defaults for platform-specific options. if sys.platform == 'win32': opts.prot_is_public = False if opts.not_dll: global qsci_define qsci_define = "" # Set the version of PyQt explicitly. global qt_data_dir if opts.pyqt_major == 4: if pyqt4 is None: sipconfig.error("PyQt v4 was specified with the -p argument but doesn't seem to be installed.") else: pyqt = pyqt4.Configuration() qt_data_dir = pyqt.qt_data_dir elif opts.pyqt_major == 3: if pyqt3 is None: sipconfig.error("PyQt v3 was specified with the -p argument but doesn't seem to be installed.") else: pyqt = pyqt3.Configuration() qt_data_dir = pyqt.qt_dir elif opts.pyqt_major >= 0: sipconfig.error("Specify either 3 or 4 with the -p argument.") # Now we know which version of PyQt to use we can set defaults for those # arguments that weren't specified. if opts.qscimoddir is None: opts.qscimoddir = pyqt.pyqt_mod_dir if opts.qsciincdir is None: opts.qsciincdir = pyqt.qt_inc_dir if opts.qscilibdir is None: opts.qscilibdir = pyqt.qt_lib_dir if opts.qscisipdir is None: opts.qscisipdir = pyqt.pyqt_sip_dir if opts.qscidir is None: opts.qscidir = os.path.join(qt_data_dir, "qsci") # Check for QScintilla. check_qscintilla() # Tell the user what's been found. inform_user() # Generate the code. generate_code()
def generate_code(mname, include_dirs=None, lib_dirs=None, libs=None, extra_sip_flags=None, debug=0): """Generate the code for a module. mname is the name of the module to generate the code for. extra_include_dirs is an optional list of additional directories to add to the list of include directories. extra_lib_dirs is an optional list of additional directories to add to the list of library directories. extra_libs is an optional list of additional libraries to add to the list of libraries. extra_sip_flags is an optional list of additional flags to pass to SIP. """ sipconfig.inform("Generating the C++ source for the %s module..." % mname) modfile = mname + "mod.sip" builddir = abspath(join("build", mname, "release" if not debug else "debug")) # sanity check - avoid cleaning a directory full of .sip files! if exists(join(builddir, modfile)): raise RuntimeError("SIP module target {} exists in build directory {}, aborting!".format(modfile, builddir)) # clean the build directory mk_clean_dir(builddir) # Build the SIP command line. argv = ['"' + pyqtcfg.sip_bin + '"'] argv.append(qt_sip_flags) if extra_sip_flags: argv.extend(extra_sip_flags) # enable debugging statements within sip if debug: argv.append("-r") # the directory where our cpp files are placed argv.append("-c") argv.append(builddir) buildfile = join(builddir, mname + ".sbf") argv.append("-b") argv.append(buildfile) argv.append("-I") argv.append(pyqtcfg.pyqt_sip_dir) argv.append("-I") argv.append(join(os.getcwdu(), mname)) # SIP assumes POSIX style path separators. argv.append(abspath(join(mname, modfile))) cmd = " ".join(argv) sys.stdout.write(cmd + "\n") # call sip.exe to generate our C++ code os.system(cmd) # Check the result. if not os.access(buildfile, os.F_OK): sipconfig.error("Unable to create the C++ code.") # Generate the Makefile. sipconfig.inform("Creating the Makefile for the %s module..." % mname) makefile = sipconfig.SIPModuleMakefile( configuration=pyqtcfg, build_file=buildfile, dir=builddir, install_dir=pyqt_modroot, qt=True, universal=pyqtcfg.universal, arch=pyqtcfg.arch, debug=debug, export_all=True, prot_is_public=False, threaded=True, ) add_makefile_extras(makefile, include_dirs, lib_dirs, libs) makefile.extra_cxxflags.append("-EHsc") makefile.extra_cflags.append("-Zi") makefile.extra_cxxflags.append("-Zi") makefile.extra_lflags.append("/DEBUG") makefile.extra_lflags.append("/PDB:{}.pdb".format(mname)) makefile.generate() return builddir