def main(): # # Parse the command line options specified by the user. # parser = create_options_parser() (options, arguments) = parser.parse_args() # # The name of the build file generated by SIP and used by the # build system. # build_file = "libserial.sbf" logging.info("Build file is " + build_file) # # Get the configuration information for the local SIP installation. # logging.info("Reading sip configuration.") config = sipconfig.Configuration() config.qt_framework = None # # Construct and run SIP to generate the module's C++ code. # sip_command = " ".join( [config.sip_bin, "-c", ".", "-e", "-b", build_file, "libserial.sip"]) logging.info("Running sip command: '" + sip_command + "'") os.system(sip_command) # # Create the Makefile with threading support as the libserial libraries # use threads implicitly. # makefile = sipconfig.SIPModuleMakefile(config, build_file=build_file, threaded=1, makefile="Makefile.sip") # # Add the library we are wrapping. The name doesn't include any platform # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # ".dll" extension on Windows). # makefile.extra_include_dirs = ["../src"] makefile.extra_lib_dirs = ["../src/.libs"] makefile.extra_libs = ["serial"] # # Generate the Makefile itself. # makefile.generate()
def get_sip_dir(): q = os.environ.get( 'SIP_DIR', os.path.join(sys.prefix, 'share', 'sip') if iswindows else os.path.join(sys.prefix, 'share', 'sip')) for x in ('', 'Py3-PyQt5', 'PyQt5', 'sip/PyQt5'): base = os.path.join(q, x) if os.path.exists(os.path.join(base, 'QtWidgets')): return base try: import sipconfig base = os.path.join(sipconfig.Configuration().default_sip_dir, "Qt5") if os.path.exists(os.path.join(base, "QtWidgets")): return base except ImportError: raise EnvironmentError('Failed to import the sipconfig module') raise EnvironmentError( 'Failed to find the location of the PyQt5 .sip files')
def get_pyqt5_configuration(): """Return the PyQt configuration for Qt5. """ import PyQt5.QtCore import sipconfig from os.path import join import sys pyqtconfig = PyQt5.QtCore.PYQT_CONFIGURATION pyqtconfig = dict([('pyqt_' + key, value) for key, value in pyqtconfig.items()]) pyqtconfig['pyqt_sip_dir'] = join(sys.prefix, 'share', 'sip', 'PyQt5') pyqtconfig['qt_version'] = PyQt5.QtCore.QT_VERSION pyqtconfig['qt_threaded'] = 1 pyqtconfig['qt_winconfig'] = 'shared' pyqtconfig['qt_framework'] = True config = sipconfig.Configuration([pyqtconfig]) return config
def initialize_options(self): super().initialize_options() self.qmake_bin = 'qmake' self.sip_bin = None self.qt_include_dir = None self.qt_libinfix = '' self.pyqt_sip_dir = None self.pyqt_sip_flags = None self.sip_files_dir = None self.sip_inc_dir = None self.inc_dir = None self.module_inc_dir = None self.pyconfig = HostPythonConfiguration() self.qtconfig = TargetQtConfiguration(self.qmake_bin) self.config = sipconfig.Configuration() self.config.default_mod_dir = ( "/usr/local/lib/python%i.%i/dist-packages" % (sys.version_info.major, sys.version_info.minor))
def generateVersionInfo(linesep='\n'): """ Module function to generate a string with various version infos. @param linesep string to be used to separate lines (string) @return string with version infos (string) """ try: import sipconfig sip_version_str = sipconfig.Configuration().sip_version_str except ImportError: sip_version_str = "sip version not available" info = "Version Numbers:%s Python %s%s" % ( linesep, sys.version.split()[0], linesep) if KdeQt.isKDEAvailable(): info += " KDE %s%s PyKDE %s%s" % (str( KdeQt.kdeVersionString()), linesep, str( KdeQt.pyKdeVersionString()), linesep) info += " Qt %s%s PyQt4 %s%s" % (str( qVersion()), linesep, str(PYQT_VERSION_STR), linesep) info += " sip %s%s QScintilla %s%s" % ( str(sip_version_str), linesep, str(QSCINTILLA_VERSION_STR), linesep) info += " %s %s%s" % (Program, Version, linesep * 2) info += "Platform: %s%s%s%s" % (sys.platform, linesep, sys.version, linesep) return info
def _module_versions(): """Get versions of optional modules. Return: A list of lines with version info. """ lines = [] try: import sipconfig # pylint: disable=import-error,unused-variable except ImportError: pass else: try: lines.append('SIP: {}'.format( sipconfig.Configuration().sip_version_str)) except (AttributeError, TypeError): log.misc.exception("Error while getting SIP version") lines.append('SIP: ?') modules = collections.OrderedDict([ ('colorlog', []), ('colorama', ['VERSION', '__version__']), ('pypeg2', ['__version__']), ('jinja2', ['__version__']), ('pygments', ['__version__']), ('yaml', ['__version__']), ]) for name, attributes in modules.items(): try: module = importlib.import_module(name) except ImportError: text = '{}: no'.format(name) else: for attr in attributes: try: text = '{}: {}'.format(name, getattr(module, attr)) except AttributeError: pass else: break else: text = '{}: yes'.format(name) lines.append(text) return lines
def run_sip(ctx): import sipconfig os.makedirs(SIP_BUILD_DIR, exist_ok=True) with mev_build_utils.save_mtime(SIP_BUILD_DIR, ['*.cpp', '*.c', '*.h']): ctx.run([ sipconfig.Configuration().sip_bin, "-c", SIP_BUILD_DIR, # Generated code directory "-b", SIP_BUILDFILE, # Build file name "-T", # Suppress timestamps "-e", # Enable exception support "-w", # Enable warnings "-o", # Auto-generate docstrings "-I", SIP_SRC, # Additional include dir SIP_INPUT ]) # Input file sip_inject_build_directory(SIP_BUILDFILE, SIP_BUILD_DIR_REL)
def main(): args = parse_args() # SIP build file generated by SIP and used by the build system. build_file = "sip/word.sbf" # SIP specification file created by us. spec_file = "sip/word.sip" # stub file for python type hints stub_file = "generated/word.pyi" # Get the SIP configuration information. config = sipconfig.Configuration() options = [ "-c", "generated", # name of the directory into which all of the generated C++ code is placed "-b", build_file, # name of the build file to generate "-e", # support for C++ exceptions is enabled "-g", # The Python GIL is released before making any calls to the C/C++ library being wrapped and reacquired afterwards ] if args.pyi: options = options + ["-y", stub_file] options_str = " ".join(options) cmd = " ".join([config.sip_bin, options_str, spec_file]) # Execute the command in a subshell os.system(cmd) makefile = sipconfig.SIPModuleMakefile(config, build_file, makefile="generated/Makefile") # Add the library we are wrapping. The name doesn't include any platform # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # ".dll" extension on Windows). makefile.extra_libs = ["word"] # Generate the Makefile itself. makefile.generate()
def generate(env): """Add Builders and construction variables for SIP to an Environment.""" c_file, cxx_file = SCons.Tool.createCFileBuilders(env) cxx_file.suffix['.sip'] = sipSuffixEmitter cxx_file.add_action('.sip', SipAction) cxx_file.add_emitter('.sip', _sipEmitter) flags = [] try: from PyQt4 import pyqtconfig config = pyqtconfig.Configuration() flags = config.pyqt_sip_flags.split() + ['-I' + config.pyqt_sip_dir] except ImportError: import sipconfig config = sipconfig.Configuration() env['SIP'] = config.sip_bin env['SIPFLAGS'] = flags env['SIPCOM'] = '$SIP $SIPFLAGS -s ${TARGET.suffix} -c ${SIPOUTPUTDIR and SIPOUTPUTDIR or "."} -c ${TARGET.dir} $SOURCES' env['SIPCOMSTR'] = '$SIPCOM' env['BUILDERS']['Sip'] = cxx_file
def sip_makefile(module): # The name of the SIP build file generated by SIP and used by the build # system. build_file = "%s.sbf"%(module) # Get the SIP configuration information. config = sipconfig.Configuration() # Run SIP to generate the code. os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "%s.sip"%(module)])) # Create the Makefile. makefile = sipconfig.SIPModuleMakefile(config, build_file) # Add the library we are wrapping. The name doesn't include any platform # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # ".dll" extension on Windows). makefile.extra_libs = [module] makefile.extra_lib_dirs = ['.'] makefile.extra_defines = ['DYNAMIC_XLDRIVER_DLL','POINTER_32='] makefile.extra_cflags = ['--std=gnu99'] # Generate the Makefile itself. makefile.generate()
def gen_makefile(): # Get the SIP configuration information. config = sipconfig.Configuration() run_sip(config) # Create the Makefile in src. makefile = sipconfig.SIPModuleMakefile(config, build_file, dir=str(SIP_DIR)) # Add the library we are wrapping. The name doesn't include any platform # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the # ".dll" extension on Windows). makefile.extra_libs = [] makefile.extra_cxxflags = wxpyconfig.cxxflags makefile.extra_lflags = wxpyconfig.lflags # Generate the Makefile itself. makefile.generate() # Create the parent makefile root_make = sipconfig.ParentMakefile(config, subdirs=[SIP_DIR]) root_make.generate()
def get_default_sip_dir(): import sipconfig c = sipconfig.Configuration() pyqt_sip_dir = os.path.join(c.default_sip_dir, 'PyQt%d' % pyqt_ver) if os.path.isdir(pyqt_sip_dir): return pyqt_sip_dir # try another shape (as on Mac/homebrew) pyqt_sip_dir = os.path.join(c.default_sip_dir, 'Qt%d' % pyqt_ver) if os.path.isdir(pyqt_sip_dir): return pyqt_sip_dir # in ubuntu 22.04 install of sip 4.19.25, default_sip_dir is wrong as it # returns /usr/share/sip and PyQt sip files are in # /usr/lib/python3/dist-packages/PyQt5/bindings/ paths = [ '/usr/lib/python%d/dist-packages/PyQt%d/bindings' % (sys.version_info[0], pyqt_ver), '/usr/lib/python%d.%d/dist-packages/PyQt%d/bindings' % (sys.version_info[0], sys.version_info[1], pyqt_ver), ] for p in paths: if os.path.exists(p): return p return c.default_sip_dir
################################################################## # try to get various useful things we need in order to build SIP_FLAGS = PyQt5.QtCore.PYQT_CONFIGURATION['sip_flags'] try: # sipconfig is deprecated but necessary to find sip reliably import sipconfig except ImportError: # try to guess locations DEF_SIP_DIR = None DEF_SIP_BIN = None DEF_SIP_INC_DIR = None else: # use sipconfig if found DEF_SIP_DIR = sipconfig.Configuration().default_sip_dir DEF_SIP_BIN = sipconfig.Configuration().sip_bin DEF_SIP_INC_DIR = sipconfig.Configuration().sip_inc_dir ################################################################## def replace_suffix(path, new_suffix): return os.path.splitext(path)[0] + new_suffix def find_on_path(names, mainname): """From a list of names of executables, find the 1st one on a path. mainname is the generic name to report """
def _sip_sipfiles_dir(self): import sipconfig cfg = sipconfig.Configuration() return cfg.default_sip_dir
def _sip_inc_dir(self): import sipconfig cfg = sipconfig.Configuration() return cfg.sip_inc_dir
def main(module): # The name of the SIP build file generated by SIP and used by the build # system. build_file = "bundle" + ".sbf" target = module + ".so" # Get the extra SIP flags needed by the imported qt module. Note that # this normally only includes those flags (-x and -t) that relate to SIP's # versioning system. qt_sip_flags = qtconfigdict["sip_flags"] current_env_path = commandOutput("conda", ["info"]) # search the output of conda info for the current environment path for item in current_env_path.split("\n"): if "default environment" in item: current_env_path = item.strip().split(' ')[3] sip_bin = current_env_path + "/bin/sip" pyqt_sip_dir = current_env_path + "/share/sip/PyQt5" # Get the PyQt configuration information. config = sipconfig.Configuration() # Run SIP to generate the code. Note that we tell SIP where to find the qt # module's specification files using the -I flag. os.system(" ".join([ sip_bin, "-c", ".", "-b", build_file, "-I", pyqt_sip_dir, qt_sip_flags, module + ".sip" ])) # We are going to install the SIP specification file for this module and # its configuration module. installs = [] installs.append([module + ".sip", os.path.join(pyqt_sip_dir, "isis3")]) isis_root = os.getenv("ISISROOT") if not isis_root: raise ("Please set ISIS") extra_cxxflags = ["$(ALLINCDIRS)"] extra_libs = [ "$(ALLLIBS)", "-Wl,-rpath," + isis_root + "/lib", "-Wl,-rpath," + isis_root + "/3rdParty/lib" ] extra_lib_dirs = ["$(ALLLIBDIRS)"] makefile = ModuleMakefile(configuration=config, build_file=build_file, installs=installs) makefile.extra_cxxflags = extra_cxxflags makefile.extra_lflags = extra_lib_dirs makefile.generate() # add import line for isismake.os isis_makefile = "include " + isis_root + "/make/isismake.os" with open("Makefile", 'r+') as f: content = f.read() content = content.replace("LIBS =", "LIBS = " + ' '.join(extra_libs)) f.seek(0, 0) f.write(isis_makefile + '\n\n' + content)
# This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. ############################################################################ import os import glob import sipconfig import shutil import numpy # get sip version sip_version = sipconfig.Configuration().sip_version str_version = sipconfig.version_to_string(sip_version) versions = [int(x) for x in str_version.split('.')] major, minor = versions[0], versions[1] src_file = ('gldisplay_before_4_12.sip' if major == 4 and minor < 12 else 'gldisplay.sip') shutil.copyfile(src_file, 'gldisplay_tmp.sip') exclude_sipfile = set() # The name of the SIP build file generated by SIP and used by the build # system. build_file = 'gldisplay.sbf' config = sipconfig.Configuration()
QT_LIB_DIR = PyQt4.QtCore.QLibraryInfo.location( PyQt4.QtCore.QLibraryInfo.LibrariesPath) QT_INC_DIR = PyQt4.QtCore.QLibraryInfo.location( PyQt4.QtCore.QLibraryInfo.HeadersPath) QT_IS_FRAMEWORK = os.path.exists( os.path.join(QT_LIB_DIR, 'QtCore.framework') ) try: # >= 4.10 SIP_FLAGS = PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags'] except: import PyQt4.pyqtconfig SIP_FLAGS = PyQt4.pyqtconfig.Configuration().pyqt_sip_flags PYQT_SIP_DIR = os.path.join( sipconfig.Configuration().default_sip_dir, 'PyQt4') SIP_BIN = sipconfig.Configuration().sip_bin SIP_INC_DIR = sipconfig.Configuration().sip_inc_dir ################################################################## def replace_suffix(path, new_suffix): return os.path.splitext(path)[0] + new_suffix class build_ext (distutils.command.build_ext.build_ext): description = ('Compile SIP descriptions, then build C/C++ extensions ' '(compile/link to build directory)') def _get_sip_output_list(self, sbf):
# -*- coding: utf-8 -*-
def main(): excludeMods = set() config = sipconfig.Configuration() fn = rootName('config.inc') confFile = open(rootName('config.inc')) for line in confFile: if line.startswith('export'): break line = line.strip('\n ') if line.startswith('COMPILE_'): var, value = line.split('=') try: value = int(value) except ValueError: continue if not value: modname = '_'.join([x.lower() for x in var.split('_')[1:]]) excludeMods.add(modname) for modName, modDirs in modules: extra_cxxflags = [] if modName in excludeMods: continue if os.path.exists(modName): if not os.path.isdir(modName): raise 'Error: %s exists and is not a directory' % modName else: os.mkdir(modName) os.chdir('%s' % modName) global rootDir orig_rootDir = rootDir rootDir = os.path.join('..', rootDir) sipFileNameSrc = "lima%s.sip" % modName if modName != 'core': if major == 4 and minor < 12: sipFileNameIn = os.path.join("..", "limamodules_before_4_12.sip.in") else: sipFileNameIn = os.path.join("..", "limamodules.sip.in") f = open(sipFileNameIn) lines = f.read() f.close() newlines = lines.replace('%NAME', modName) d = open(sipFileNameSrc, 'w') d.write(newlines) d.close() elif major == 4 and minor < 12: sipFileNameSrc = "limacore_before_4_12.sip" sipFileName = "lima%s_tmp.sip" % modName shutil.copyfile(sipFileNameSrc, sipFileName) initNumpy = 'lima_init_numpy.cpp' shutil.copyfile(os.path.join('..', initNumpy), initNumpy) dirProcesslib = rootName(os.path.join('third-party', 'Processlib')) sipProcesslib = os.path.join(dirProcesslib, 'sip') extraIncludes = [ '.', os.path.join('..', 'core'), sipProcesslib, numpy.get_include(), config.sip_inc_dir ] extraIncludes += findIncludes(dirProcesslib) if platform.system() == 'Windows': extraIncludes += [ os.path.join(dirProcesslib, "core", "include", "WindowSpecific") ] coreDirs = modules[0][1] extraIncludes += findModuleIncludes('core') if (modName in espiaModules) and ('espia' not in excludeMods): espia_base = '/segfs/bliss/source/driver/linux-2.6/espia' espia_incl = os.path.join(espia_base, 'src') extraIncludes += [espia_incl] if (modName == 'basler'): if platform.system() != 'Windows': extraIncludes += ['%s/include' % os.environ['PYLON_ROOT']] extraIncludes += [ '%s/library/CPP/include' % os.environ['GENICAM_ROOT_V2_1'] ] extra_cxxflags += ['-DUSE_GIGE'] else: extraIncludes += [ '%s\library\cpp\include' % os.environ['PYLON_GENICAM_ROOT'] ] extraIncludes += ['%s\include' % os.environ['PYLON_ROOT']] extra_cxxflags += ['-DUSE_GIGE'] elif (modName == 'ueye') and platform.system() != 'Windows': extra_cxxflags += ['-D__LINUX__'] elif (modName == 'andor'): extraIncludes += ['/usr/local/include'] elif (modName == 'xpad'): extraIncludes += [ '../../third-party/yat/include', '/home/xpix_user/PCI_VALIDATED/trunk/sw/xpci_lib' ] elif (modName == 'xspress3'): extraIncludes += ['../../third-party/hdf5/c++/src'] extra_cxxflags += ['-DSIPCOMPILATION'] elif (modName == 'pco'): extraIncludes += [ 'R:/bliss/projects/LIMA/package/WIN32/PCO/sdkPco/include' ] elif (modName == 'marccd'): extraIncludes += ['../../../include/DiffractionImage'] extraIncludes += ['../../third-party/yat/include'] elif (modName == 'pointgrey'): extraIncludes += ['/usr/include/flycapture'] elif (modName == 'rayonixhs'): extraIncludes += [ '/opt/rayonix/include/craydl', '/opt/rayonix/include', '/opt/rayonix/include/marccd' ] extra_cxxflags += ['-std=c++0x'] elif (modName == 'aviex'): extra_cxxflags += ['-DOS_UNIX'] elif (modName == 'maxipix'): extraIncludes += ['../../camera/maxipix/tools/src'] elif (modName == 'pixirad'): extra_cxxflags += ['-std=c++11'] extraIncludes += findModuleIncludes(modName) elif (modName == 'hexitec'): extraIncludes += [ '../../camera/hexitec/sdk', '/opt/pleora/ebus_sdk/CentOS-RHEL-7-x86_64/include' ] extra_cxxflags += ['-std=c++11'] extra_cxxflags += ['-DSIPCOMPILATION'] elif (modName == 'slsdetector'): SLS_DETECTORS_DIR = os.environ['SLS_DETECTORS_DIR'] SLS_DETECTORS_SW = os.path.join(SLS_DETECTORS_DIR, 'slsDetectorSoftware') SLS_DETECTORS_RECV = os.path.join(SLS_DETECTORS_DIR, 'slsReceiverSoftware') slsIncl = [ os.path.join(SLS_DETECTORS_SW, 'include'), os.path.join(SLS_DETECTORS_SW, 'commonFiles'), os.path.join(SLS_DETECTORS_SW, 'slsDetector'), os.path.join(SLS_DETECTORS_SW, 'multiSlsDetector'), os.path.join(SLS_DETECTORS_SW, 'slsDetectorServer'), os.path.join(SLS_DETECTORS_SW, 'slsDetectorAnalysis'), os.path.join(SLS_DETECTORS_SW, 'slsReceiverInterface'), os.path.join(SLS_DETECTORS_RECV, 'include'), ] extraIncludes += slsIncl extraIncludes += findModuleIncludes(modName) if (modName == 'roperscientific'): extraIncludes.remove( '../../camera/roperscientific/sdk/msvc/include') sipFile = open(sipFileName, "a") sipFile.write('\n') sipProcesslib = sipProcesslib.replace( os.sep, '/') # sip don't manage windows path sipFile.write('%%Import %s/processlib_tmp.sip\n' % sipProcesslib) if modName != 'core': sipFile.write('%Import ../core/limacore_tmp.sip\n') if (modName in espiaModules) and (modName != 'espia'): sipFile.write('%Import ../espia/limaespia_tmp.sip\n') extraIncludes += findModuleIncludes('espia') for sdir in modDirs: srcDir = rootName(sdir) for root, dirs, files in os.walk(srcDir): dir2rmove = excludeMods.intersection(dirs) for dname in dir2rmove: dirs.remove(dname) for filename in files: base, ext = os.path.splitext(filename) if ext != '.sip': continue if major == 4 and minor < 12: if os.access(os.path.join(root, filename + "_4_12"), os.R_OK): filename += "_4_12" incl = os.path.join(root, filename) incl = incl.replace(os.sep, '/') # sip don't manage windows path. sipFile.write('%%Include %s\n' % incl) sipFile.close() # The name of the SIP build file generated by SIP and used by the build # system. build_file = "lima%s.sbf" % modName # Run SIP to generate the code. # module's specification files using the -I flag. if platform.system() == 'Windows': if platform.machine() == 'AMD64': plat = 'WIN64_PLATFORM' else: plat = 'WIN32_PLATFORM' else: plat = 'POSIX_PLATFORM' cmdargs = [config.sip_bin, "-g", "-e", "-c", '.', '-t', plat] if 'config' in excludeMods: cmdargs.extend(['-x', 'WITH_CONFIG']) cmdargs.extend(["-b", build_file, sipFileName]) cmd = " ".join(cmdargs) print(cmd) os.system(cmd) #little HACK for adding source bfile = open(build_file) whole_line = '' for line in bfile: if 'sources' in line: begin, end = line.split('=') line = '%s = lima_init_numpy.cpp %s' % (begin, end) whole_line += line bfile.close() bfile = open(build_file, 'w') bfile.write(whole_line) bfile.close() # We are going to install the SIP specification file for this module # and its configuration module. installs = [] installs.append( [sipFileNameSrc, os.path.join(config.default_sip_dir, "lima")]) installs.append(["limaconfig.py", config.default_mod_dir]) # Create the Makefile. The QtModuleMakefile class provided by the # pyqtconfig module takes care of all the extra preprocessor, compiler # and linker flags needed by the Qt library. makefile = sipconfig.ModuleMakefile(configuration=config, build_file=build_file, installs=installs, export_all=True) makefile.extra_include_dirs = extraIncludes if platform.system() == 'Windows': makefile.extra_libs = [ 'liblima%s' % modName, 'libprocesslib', 'libconfig++' ] if modName != 'core': makefile.extra_libs += ['liblimacore'] makefile.extra_cxxflags = ['/EHsc', '/DWITH_CONFIG' ] + extra_cxxflags if platform.machine() == 'AMD64': libpath = 'build\msvc\9.0\*\\x64\Release' makefile.extra_cxxflags.append('/DWITHOUT_GSL') else: libpath = 'build\msvc\9.0\*\Release' makefile.extra_lib_dirs += glob.glob( os.path.join(rootName(''), libpath)) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('third-party\Processlib'), libpath)) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('camera'), modName, libpath)) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('third-party\libconfig'), 'lib', 'libconfig++.Release')) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('third-party\libconfig'), 'lib', 'x64', 'Release')) if (modName == 'basler'): makefile.extra_lib_dirs += [ '%s\library\cpp\lib\win32_i86' % os.environ['PYLON_GENICAM_ROOT'] ] makefile.extra_lib_dirs += [ '%s\lib\Win32' % os.environ['PYLON_ROOT'] ] else: makefile.extra_libs = ['pthread', 'lima%s' % modName] makefile.extra_cxxflags = ['-pthread', '-g', '-DWITH_SPS_IMAGE' ] + extra_cxxflags if 'config' not in excludeMods: makefile.extra_cxxflags.append('-DWITH_CONFIG') makefile.extra_lib_dirs = [rootName('build')] if modName == 'slsdetector': bad_flag = '-Werror=format-security' good_flag = '-Wno-error=format-security' for flags in [makefile.CFLAGS, makefile.CXXFLAGS]: for fg in flags.as_list(): if bad_flag in fg: flags.remove(fg) fg = good_flag.join(fg.split(bad_flag)) flags.extend([fg]) makefile.extra_cxxflags.extend(['-I"%s"' % x for x in extraIncludes]) # Add the library we are wrapping. The name doesn't include any # platform specific prefixes or extensions (e.g. the "lib" prefix on # UNIX, or the ".dll" extension on Windows). # None (for me) # Generate the Makefile itself. makefile.generate() # Now we create the configuration module. This is done by merging a # Python dictionary (whose values are normally determined dynamically) # with a (static) template. content = { # Publish where the SIP specifications for this module will be # installed. "lima_sip_dir": config.default_sip_dir } # This creates the lima<mod>config.py module from the limaconfig.py.in # template and the dictionary. sipconfig.create_config_module("lima%sconfig.py" % modName, os.path.join("..", "limaconfig.py.in"), content) # Fix SIP Exception handling for cpp_file in glob.glob('siplima*.cpp'): modify = checksipexc(cpp_file) cpp_file_out = '%s.out' % cpp_file if not modify: os.remove(cpp_file_out) else: os.remove(cpp_file) shutil.move(cpp_file_out, cpp_file) os.chdir('..') rootDir = orig_rootDir
# this is likely to break, I'm sure QT_LIB_DIR = PyQt5.QtCore.QLibraryInfo.location( PyQt5.QtCore.QLibraryInfo.LibrariesPath) QT_INC_DIR = PyQt5.QtCore.QLibraryInfo.location( PyQt5.QtCore.QLibraryInfo.HeadersPath) QT_IS_FRAMEWORK = os.path.exists(os.path.join(QT_LIB_DIR, 'QtCore.framework')) try: # >= 4.10 SIP_FLAGS = PyQt5.QtCore.PYQT_CONFIGURATION['sip_flags'] except: import PyQt5.pyqtconfig SIP_FLAGS = PyQt5.pyqtconfig.Configuration().pyqt_sip_flags PYQT_SIP_DIR = os.path.join(sipconfig.Configuration().default_sip_dir, 'PyQt5') SIP_BIN = sipconfig.Configuration().sip_bin SIP_INC_DIR = sipconfig.Configuration().sip_inc_dir ################################################################## def replace_suffix(path, new_suffix): return os.path.splitext(path)[0] + new_suffix class build_ext(distutils.command.build_ext.build_ext): description = ('Compile SIP descriptions, then build C/C++ extensions ' '(compile/link to build directory)')
def main(): excludeMods = set() config = sipconfig.Configuration() fn = rootName('config.inc') confFile = open(rootName('config.inc')) for line in confFile: if line.startswith('export'): break line = line.strip('\n ') if line.startswith('COMPILE_'): var, value = line.split('=') try: value = int(value) except ValueError: continue if not value: excludeMods.add(var.split('_')[-1].lower()) for modName, modDirs in modules: extra_cxxflags = [] if modName in excludeMods: continue if os.path.exists(modName): if not os.path.isdir(modName): raise 'Error: %s exists and is not a directory' % modName else: os.mkdir(modName) os.chdir('%s' % modName) global rootDir orig_rootDir = rootDir rootDir = os.path.join('..', rootDir) sipFileNameSrc = "lima%s.sip" % modName if modName != 'core': sipFileNameIn = os.path.join("..", "limamodules.sip.in") f = file(sipFileNameIn) lines = f.read() f.close() newlines = lines.replace('%NAME', modName) d = file(sipFileNameSrc, 'w') d.write(newlines) d.close() sipFileName = "lima%s_tmp.sip" % modName shutil.copyfile(sipFileNameSrc, sipFileName) initNumpy = 'lima_init_numpy.cpp' shutil.copyfile(os.path.join('..', initNumpy), initNumpy) dirProcesslib = rootName(os.path.join('third-party', 'Processlib')) sipProcesslib = os.path.join(dirProcesslib, 'sip') extraIncludes = [ '.', os.path.join('..', 'core'), sipProcesslib, numpy.get_include(), config.sip_inc_dir ] extraIncludes += findIncludes(dirProcesslib) if platform.system() == 'Windows': extraIncludes += [ os.path.join(dirProcesslib, "core", "include", "WindowSpecific") ] coreDirs = modules[0][1] extraIncludes += findModuleIncludes('core') if (modName in espiaModules) and ('espia' not in excludeMods): espia_base = '/segfs/bliss/source/driver/linux-2.6/espia' espia_incl = os.path.join(espia_base, 'src') extraIncludes += [espia_incl] if (modName == 'basler'): extraIncludes += [ '/opt/pylon/include', '/opt/pylon/include/genicam', '/opt/pylon/genicam/library/CPP/include' ] extra_cxxflags += ['-DUSE_GIGE'] elif (modName == 'ueye') and platform.system() != 'Windows': extra_cxxflags += ['-D__LINUX__'] elif (modName == 'andor'): extraIncludes += ['/usr/local/include'] elif (modName == 'xpad'): extraIncludes += [ '../../third-party/yat/include', '/home/xpix_user/PCI_VALIDATED/trunk/sw/xpci_lib' ] elif (modName == 'pco'): extraIncludes += [ 'R:/bliss/projects/LIMA/package/WIN32/PCO/sdkPco/include' ] elif (modName == 'marccd'): extraIncludes += ['../../../include/DiffractionImage'] extraIncludes += ['../../third-party/yat/include'] extraIncludes += findModuleIncludes(modName) sipFile = open(sipFileName, "a") sipFile.write('\n') sipProcesslib = sipProcesslib.replace( os.sep, '/') # sip don't manage windows path sipFile.write('%%Import %s/processlib_tmp.sip\n' % sipProcesslib) if modName != 'core': sipFile.write('%Import ../core/limacore_tmp.sip\n') if (modName in espiaModules) and (modName != 'espia'): sipFile.write('%Import ../espia/limaespia_tmp.sip\n') extraIncludes += findModuleIncludes('espia') for sdir in modDirs: srcDir = rootName(sdir) for root, dirs, files in os.walk(srcDir): dir2rmove = excludeMods.intersection(dirs) for dname in dir2rmove: dirs.remove(dname) for filename in files: base, ext = os.path.splitext(filename) if ext != '.sip': continue incl = os.path.join(root, filename) incl = incl.replace(os.sep, '/') # sip don't manage windows path. sipFile.write('%%Include %s\n' % incl) sipFile.close() # The name of the SIP build file generated by SIP and used by the build # system. build_file = "lima%s.sbf" % modName # Run SIP to generate the code. # module's specification files using the -I flag. if platform.system() == 'Windows': plat = 'WIN32_PLATFORM' else: plat = 'POSIX_PLATFORM' cmd = " ".join([ config.sip_bin, "-g", "-e", "-c", '.', '-t', plat, "-b", build_file, sipFileName ]) print cmd os.system(cmd) #little HACK for adding source bfile = open(build_file) whole_line = '' for line in bfile: if 'sources' in line: begin, end = line.split('=') line = '%s = lima_init_numpy.cpp %s' % (begin, end) whole_line += line bfile.close() bfile = open(build_file, 'w') bfile.write(whole_line) bfile.close() # We are going to install the SIP specification file for this module # and its configuration module. installs = [] installs.append( [sipFileNameSrc, os.path.join(config.default_sip_dir, "lima")]) installs.append(["limaconfig.py", config.default_mod_dir]) # Create the Makefile. The QtModuleMakefile class provided by the # pyqtconfig module takes care of all the extra preprocessor, compiler # and linker flags needed by the Qt library. makefile = sipconfig.ModuleMakefile(configuration=config, build_file=build_file, installs=installs, export_all=True) makefile.extra_include_dirs = extraIncludes if platform.system() == 'Windows': makefile.extra_libs = ['liblima%s' % modName, 'libprocesslib'] if modName != 'core': makefile.extra_libs += ['liblimacore'] makefile.extra_cxxflags = ['/EHsc'] + extra_cxxflags #libpath = 'build\msvc\9.0\*\Debug' libpath = 'build\msvc\9.0\*\Release' #makefile.extra_lib_dirs = glob.glob(os.path.join(rootName('build'),'msvc','9.0','*','Release')) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName(''), libpath)) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('third-party\Processlib'), libpath)) makefile.extra_lib_dirs += glob.glob( os.path.join(rootName('camera'), modName, libpath)) else: makefile.extra_libs = ['pthread', 'lima%s' % modName] makefile.extra_cxxflags = ['-pthread', '-g', '-DWITH_SPS_IMAGE' ] + extra_cxxflags makefile.extra_lib_dirs = [rootName('build')] makefile.extra_cxxflags.extend(['-I' + x for x in extraIncludes]) # Add the library we are wrapping. The name doesn't include any # platform specific prefixes or extensions (e.g. the "lib" prefix on # UNIX, or the ".dll" extension on Windows). # None (for me) # Generate the Makefile itself. makefile.generate() # Now we create the configuration module. This is done by merging a # Python dictionary (whose values are normally determined dynamically) # with a (static) template. content = { # Publish where the SIP specifications for this module will be # installed. "lima_sip_dir": config.default_sip_dir } # This creates the lima<mod>config.py module from the limaconfig.py.in # template and the dictionary. sipconfig.create_config_module("lima%sconfig.py" % modName, os.path.join("..", "limaconfig.py.in"), content) # Fix SIP Exception handling for cpp_file in glob.glob('siplima*.cpp'): modify = checksipexc(cpp_file) cpp_file_out = '%s.out' % cpp_file if not modify: os.remove(cpp_file_out) else: os.remove(cpp_file) shutil.move(cpp_file_out, cpp_file) os.chdir('..') rootDir = orig_rootDir
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # FindPyQt.py # Copyright (c) 2007, Simon Edwards <*****@*****.**> # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. try: import PyQt5.pyqtconfig pyqtcfg = PyQt5.pyqtconfig.Configuration() except ImportError: import PyQt5.QtCore import sipconfig # won't work for SIP v5 import os.path import sys cfg = sipconfig.Configuration() sip_dir = cfg.default_sip_dir if sys.platform.startswith('freebsd'): py_version = str(sys.version_info.major) + str(sys.version_info.minor) sip_dir = sip_dir.replace(py_version, '') for p in (os.path.join(sip_dir, "PyQt5"), os.path.join(sip_dir, "PyQt5-3"), sip_dir): if os.path.exists(os.path.join(p, "QtCore", "QtCoremod.sip")): sip_dir = p break cfg = { 'pyqt_version': PyQt5.QtCore.PYQT_VERSION, 'pyqt_version_str': PyQt5.QtCore.PYQT_VERSION_STR, 'pyqt_sip_flags': PyQt5.QtCore.PYQT_CONFIGURATION['sip_flags'], 'pyqt_mod_dir': os.path.join(cfg.default_mod_dir, "PyQt5"),
def checkBlacklistedVersions(): """ Module functions to check for blacklisted versions of the prerequisites. @return flag indicating good versions were found (boolean) """ from install import BlackLists, PlatformsBlackLists # determine the platform dependent black list if isWindowsPlatform(): PlatformBlackLists = PlatformsBlackLists["windows"] elif isLinuxPlatform(): PlatformBlackLists = PlatformsBlackLists["linux"] else: PlatformBlackLists = PlatformsBlackLists["mac"] # check version of sip try: import sipconfig sipVersion = sipconfig.Configuration().sip_version_str # always assume, that snapshots are good if "snapshot" not in sipVersion: # check for blacklisted versions for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: if vers == sipVersion: print( 'Sorry, sip version {0} is not compatible with pymakr.' .format(vers)) print('Please install another version.') return False except ImportError: pass # check version of PyQt from PyQt5.QtCore import PYQT_VERSION_STR pyqtVersion = PYQT_VERSION_STR # always assume, that snapshots are good if "snapshot" not in pyqtVersion: # check for blacklisted versions pyqtVariant = "PyQt{0}".format(pyqtVersion[0]) for vers in BlackLists[pyqtVariant] + PlatformBlackLists[pyqtVariant]: if vers == pyqtVersion: print('Sorry, PyQt version {0} is not compatible with pymakr.'. format(vers)) print('Please install another version.') return False # check version of QScintilla from PyQt5.Qsci import QSCINTILLA_VERSION_STR scintillaVersion = QSCINTILLA_VERSION_STR # always assume, that snapshots are new enough if "snapshot" not in scintillaVersion: # check for blacklisted versions for vers in BlackLists["QScintilla2"] + \ PlatformBlackLists["QScintilla2"]: if vers == scintillaVersion: print('Sorry, QScintilla2 version {0} is not compatible' ' with eric6.'.format(vers)) print('Please install another version.') return False return True
def main(): qmakePath = getEnv('QMAKE', 'qmake') sipPath = getEnv('SIP', 'sip') sipConfig = sipconfig.Configuration() config = Config(qmakePath) projectPath = getEnv('PROJECT_PATH', os.getcwd() + '/..') includePath = getEnv('INCLUDE_PATH', projectPath) libraryPath = getEnv('LIBRARY_PATH', projectPath + '/fakevim') sipFilePath = getEnv('SIP_FILE_PATH', projectPath + '/python/fakevim.sip') pyQtIncludePath = getEnv( 'PYQT_INCLUDE_PATH', '/usr/share/sip/PyQt' + (config.hasQt5() and '5' or '4')) commandOutput( sipPath, config.sipFlags().split(' ') + [ '-I', pyQtIncludePath, '-b', 'fakevim_python.pro', '-o', '-c', '.', sipFilePath ]) # Find libpython pythonLibDir = sysconfig.get_config_var('LIBDIR') pythonLdLibrary = sysconfig.get_config_var('LDLIBRARY') pythonLibrary = pythonLibDir + "/" + pythonLdLibrary if not os.path.isfile(pythonLibrary): pythonLibrary = pythonLibDir + "/" \ + sysconfig.get_config_var('MULTIARCH') + "/" \ + pythonLdLibrary with open('fakevim_python.pro', 'a') as pro: pro.write(''' TEMPLATE = lib CONFIG += release plugin no_plugin_name_prefix QT += widgets TARGET = $$target HEADERS = $$headers "{projectPythonInclude}/fakevimproxy.h" SOURCES = $$sources "{projectPythonInclude}/fakevimproxy.cpp" INCLUDEPATH += "{sipInclude}" "{pythonInclude}" "{projectInclude}" "{projectPythonInclude}" "{includePath}" "{includePath}/fakevim" LIBS += -Wl,-rpath,"{libraryPath}" -L"{libraryPath}" -lfakevim "{pythonLibrary}" DEFINES += FAKEVIM_PYQT_MAJOR_VERSION={qtVersion} isEmpty(PREFIX) {{ PREFIX = "{installPath}" }} target.path = $$PREFIX INSTALLS += target '''.format(pythonInclude=sysconfig.get_python_inc(), sipInclude=sipConfig.sip_inc_dir, projectInclude=projectPath, projectPythonInclude=projectPath + "/python", includePath=includePath, libraryPath=libraryPath, pythonLibrary=pythonLibrary, qtVersion=config.hasQt5() and 5 or 4, installPath=site.getusersitepackages()).replace( '\n ', '\n'))
def create_makefiles(macros): """Create the Makefiles. macros is the dictionary of platform specific build macros. """ # Bootstrap. Make sure we get the right one. sys.path.insert(0, os.path.curdir) invalidate_caches() import sipconfig cfg = sipconfig.Configuration() cfg.set_build_macros(macros) all_installs = [] top_installs = [] gen_installs = [] subdirs = [] if not opts.no_tools: subdirs.append('sipgen') top_installs.append( (["sipconfig.py", os.path.join(src_dir, "sipdistutils.py")], cfg.sip_root_dir)) gen_installs.append((os.path.join(src_dir, "siplib", "sip.h"), cfg.sip_inc_dir)) if not opts.no_module: subdirs.append('siplib') all_installs.extend(top_installs) all_installs.extend(gen_installs) # The command to run to generate the dist-info directory. mk_distinfo = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mk_distinfo.py') distinfo_dir = os.path.join( cfg.sip_module_dir, '%s-%s.dist-info' % (sip_module_name.replace('.', '_'), sip_version_str)) if opts.use_qmake: run_mk_distinfo = '%s %s \\\"$(INSTALL_ROOT)\\\" %s installed.txt' % ( sys.executable, mk_distinfo, distinfo_dir) sipconfig.inform("Creating top level .pro file...") pro = open("sip.pro", "w") pro.write("TEMPLATE = subdirs\n") pro.write("SUBDIRS = %s\n" % " ".join(subdirs)) if top_installs: # There will only be one element. files, path = top_installs[0] pro.write("\n") pro.write("build_system.files = %s\n" % " ".join(files)) pro.write("build_system.path = %s\n" % quote(path)) pro.write("INSTALLS += build_system\n") if opts.distinfo: pro.write("\n") pro.write("distinfo.extra = %s\n" % run_mk_distinfo) pro.write("distinfo.path = %s\n" % quote(cfg.sip_module_dir)) pro.write("INSTALLS += distinfo\n") pro.close() else: run_mk_distinfo = '%s %s "$(DESTDIR)" %s installed.txt' % ( sys.executable, mk_distinfo, distinfo_dir) sipconfig.inform("Creating top level Makefile...") # Note that mk_distinfo.py won't exist if we are building from the # repository. if opts.distinfo and os.path.isfile(mk_distinfo): top_installs.append((run_mk_distinfo, None)) sipconfig.ParentMakefile(configuration=cfg, subdirs=subdirs, installs=top_installs).generate() if opts.use_qmake: sipconfig.inform("Creating sip code generator .pro file...") pro = open(os.path.join("sipgen", "sipgen.pro"), "w") pro.write("TEMPLATE = app\n") pro.write("TARGET = sip\n") pro.write("CONFIG -= qt app_bundle\n") pro.write("CONFIG += warn_on exceptions_off console %s\n" % (("debug" if opts.debug else "release"))) pro.write("\n") pro.write("# Work around QTBUG-39300.\n") pro.write("CONFIG -= android_install\n") pro.write("\n") pro.write("target.path = %s\n" % os.path.dirname(cfg.sip_bin)) pro.write("INSTALLS += target\n") c_sources = get_sources("sipgen", "*.c") pro.write("\n") pro.write("SOURCES = %s\n" % " ".join([qmake_quote(s) for s in c_sources])) headers = get_sources("sipgen", "*.h") pro.write("\n") pro.write("HEADERS = %s\n" % " ".join([qmake_quote(h) for h in headers])) if gen_installs: # There will only be one element. files, path = gen_installs[0] pro.write("\n") pro.write("sip_h.files = %s\n" % " ".join(files)) pro.write("sip_h.path = %s\n" % quote(path)) pro.write("INSTALLS += sip_h\n") pro.close() else: sipconfig.inform("Creating sip code generator Makefile...") sipconfig.ProgramMakefile( configuration=cfg, build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"), dir="sipgen", install_dir=os.path.dirname(cfg.sip_bin), installs=gen_installs, console=1, warnings=1, universal=opts.universal, arch=opts.arch, deployment_target=opts.deployment_target).generate() # The implied code generator installs. if not opts.no_tools: sip_dir, sip_exe = os.path.split(cfg.sip_bin) if sys.platform == 'win32': sip_exe += '.exe' all_installs.append((sip_exe, sip_dir)) # The module installs. module_installs = [] if opts.pyi: module_installs.append((os.path.join(src_dir, 'sip.pyi'), pyi_dir)) all_installs.extend(module_installs) if not opts.no_module: if sys.platform == 'win32': mod = 'sip.lib' if opts.static else 'sip.pyd' else: mod = 'libsip.a' if opts.static else 'sip.so' all_installs.append((mod, sip_module_dest_dir)) if opts.use_qmake: sipconfig.inform("Creating sip module .pro file...") pro = open(os.path.join("siplib", "siplib.pro"), "w") pro.write("TEMPLATE = lib\n") pro.write("TARGET = sip\n") pro.write("CONFIG -= qt\n") pro.write("CONFIG += warn_on exceptions_off %s %s\n" % (("staticlib" if opts.static else "plugin plugin_bundle"), ("debug" if opts.debug else "release"))) pro.write("\n") pro.write("# Work around QTBUG-39300.\n") pro.write("CONFIG -= android_install\n") pro.write("\n") pro.write("INCLUDEPATH += %s\n" % cfg.py_inc_dir) if cfg.py_conf_inc_dir != cfg.py_inc_dir: pro.write("INCLUDEPATH += %s\n" % cfg.py_conf_inc_dir) if sip_module_name != 'sip': pro.write("\n") pro.write('DEFINES += SIP_MODULE_NAME=%s\n' % sip_module_name) base_name = sip_module_name.split('.')[-1] if base_name != 'sip': pro.write('DEFINES += SIP_MODULE_BASENAME=%s\n' % base_name) if not opts.static: # These only need to be correct for Windows. debug_suffix = "_d" if opts.debug else "" link_lib_dir = quote("-L" + cfg.py_lib_dir) pro.write(""" win32 { PY_MODULE = sip%s.pyd PY_MODULE_SRC = $(DESTDIR_TARGET) LIBS += %s } else { PY_MODULE = sip.so macx { PY_MODULE_SRC = $(TARGET).plugin/Contents/MacOS/$(TARGET) QMAKE_LFLAGS += "-undefined dynamic_lookup" } else { PY_MODULE_SRC = $(TARGET) } } QMAKE_POST_LINK = $(COPY_FILE) $$PY_MODULE_SRC $$PY_MODULE target.CONFIG = no_check_exist target.files = $$PY_MODULE """ % (debug_suffix, link_lib_dir)) pro.write("\n") pro.write("target.path = %s\n" % sip_module_dest_dir) pro.write("INSTALLS += target\n") if opts.pyi: pro.write("\n") pro.write("sip_pyi.files = sip.pyi\n") pro.write("sip_pyi.path = %s\n" % pyi_dir) pro.write("INSTALLS += sip_pyi\n") c_sources = get_sources("siplib", "*.c") cpp_sources = get_sources("siplib", "*.cpp") pro.write("\n") pro.write("SOURCES = %s\n" % " ".join([qmake_quote(s) for s in c_sources + cpp_sources])) headers = get_sources("siplib", "*.h") pro.write("\n") pro.write("HEADERS = %s\n" % " ".join([qmake_quote(h) for h in headers])) pro.close() else: sipconfig.inform("Creating sip module Makefile...") build_dir = os.getcwd() makefile = sipconfig.ModuleMakefile( configuration=cfg, build_file=os.path.join(src_dir, "siplib", "siplib.sbf"), dir="siplib", install_dir=sip_module_dest_dir, installs=module_installs, console=1, warnings=1, static=opts.static, debug=opts.debug, universal=opts.universal, arch=opts.arch, deployment_target=opts.deployment_target) if sip_module_name != 'sip': makefile.DEFINES.append('SIP_MODULE_NAME=%s' % sip_module_name) base_name = sip_module_name.split('.')[-1] if base_name != 'sip': makefile.DEFINES.append('SIP_MODULE_BASENAME=%s' % base_name) if src_dir != build_dir: src_siplib_dir = os.path.join(src_dir, "siplib") makefile.extra_include_dirs.append(src_siplib_dir) makefile.extra_source_dirs.append(src_siplib_dir) makefile.generate() # Create the file containing all installed files. if opts.distinfo: installed = open('installed.txt', 'w') for sources, dst in all_installs: if not isinstance(sources, (list, tuple)): sources = [sources] for src in sources: installed.write( os.path.join(dst, os.path.basename(src)) + '\n') installed.close()
def _sip_sipfiles_dir(self): cfg = sipconfig.Configuration() return join(cfg.default_sip_dir, 'PyQt5')
def create_makefiles(macros): """Create the Makefiles. macros is the dictionary of platform specific build macros. """ # Bootstrap. Make sure we get the right one. sys.path.insert(0, os.path.curdir) invalidate_caches() import sipconfig cfg = sipconfig.Configuration() cfg.set_build_macros(macros) if opts.no_tools: subdirs = ["siplib"] installs = None else: subdirs = ["sipgen", "siplib"] installs = (["sipconfig.py", os.path.join(src_dir, "sipdistutils.py")], cfg.sip_mod_dir) if opts.use_qmake: sipconfig.inform("Creating top level .pro file...") pro = open("sip.pro", "w") pro.write("TEMPLATE = subdirs\n") pro.write("SUBDIRS = %s\n" % " ".join(subdirs)) if installs is not None: files, path = installs pro.write("\n") pro.write("build_system.files = %s\n" % " ".join(files)) pro.write("build_system.path = %s\n" % quote(path)) pro.write("INSTALLS += build_system\n") pro.close() else: sipconfig.inform("Creating top level Makefile...") sipconfig.ParentMakefile(configuration=cfg, subdirs=subdirs, installs=installs).generate() if opts.use_qmake: sipconfig.inform("Creating sip code generator .pro file...") pro = open(os.path.join("sipgen", "sipgen.pro"), "w") pro.write("TEMPLATE = app\n") pro.write("TARGET = sip\n") pro.write("CONFIG -= qt app_bundle\n") pro.write("CONFIG += warn_off exceptions_off console %s\n" % (("debug" if opts.debug else "release"))) pro.write("\n") pro.write("# Work around QTBUG-39300.\n") pro.write("CONFIG -= android_install\n") pro.write("\n") pro.write("target.path = %s\n" % os.path.dirname(cfg.sip_bin)) pro.write("INSTALLS += target\n") c_sources = get_sources("sipgen", "*.c") pro.write("\n") pro.write("SOURCES = %s\n" % " ".join(c_sources)) headers = get_sources("sipgen", "*.h") pro.write("\n") pro.write("HEADERS = %s\n" % " ".join(headers)) pro.close() else: sipconfig.inform("Creating sip code generator Makefile...") sipconfig.ProgramMakefile( configuration=cfg, build_file=os.path.join(src_dir, "sipgen", "sipgen.sbf"), dir="sipgen", install_dir=os.path.dirname(cfg.sip_bin), console=1, warnings=0, universal=opts.universal, arch=opts.arch, deployment_target=opts.deployment_target).generate() if opts.use_qmake: sipconfig.inform("Creating sip module .pro file...") pro = open(os.path.join("siplib", "siplib.pro"), "w") pro.write("TEMPLATE = lib\n") pro.write("TARGET = %s\n" % sip_module_base) pro.write("CONFIG -= qt\n") pro.write("CONFIG += warn_on exceptions_off %s %s\n" % (("staticlib" if opts.static else "plugin"), ("debug" if opts.debug else "release"))) pro.write("\n") pro.write("# Work around QTBUG-39300.\n") pro.write("CONFIG -= android_install\n") pro.write("\n") pro.write("INCLUDEPATH += %s\n" % cfg.py_inc_dir) if cfg.py_conf_inc_dir != cfg.py_inc_dir: pro.write("INCLUDEPATH += %s\n" % cfg.py_conf_inc_dir) if not opts.static: # These only need to be correct for Windows. debug_suffix = "_d" if opts.debug else "" link_lib_dir = quote("-L" + cfg.py_lib_dir) pro.write(""" win32 { PY_MODULE = %s%s.pyd target.files = %s%s.pyd LIBS += %s -lpython%d.%d QMAKE_POST_LINK = $(COPY_FILE) $(DESTDIR_TARGET) $$PY_MODULE } else { PY_MODULE = %s.so target.files = %s.so QMAKE_POST_LINK = $(COPY_FILE) $(TARGET) $$PY_MODULE } macx { QMAKE_LFLAGS += "-undefined dynamic_lookup" QMAKE_LFLAGS += "-install_name $$absolute_path($$PY_MODULE, $$target.path)" } """ % (sip_module_base, debug_suffix, sip_module_base, debug_suffix, link_lib_dir, (py_version >> 16), ((py_version >> 8) & 0xff), sip_module_base, sip_module_base)) pro.write("\n") pro.write("target.CONFIG = no_check_exist\n") pro.write("target.path = %s\n" % cfg.sip_mod_dir) pro.write("INSTALLS += target\n") pro.write("\n") pro.write("sip_h.files = sip.h\n") pro.write("sip_h.path = %s\n" % cfg.sip_inc_dir) pro.write("INSTALLS += sip_h\n") c_sources = get_sources("siplib", "*.c") cpp_sources = get_sources("siplib", "*.cpp") pro.write("\n") pro.write("SOURCES = %s\n" % " ".join(c_sources + cpp_sources)) headers = get_sources("siplib", "*.h") pro.write("\n") pro.write("HEADERS = %s\n" % " ".join(headers)) pro.close() else: sipconfig.inform("Creating sip module Makefile...") sipconfig.ModuleMakefile( configuration=cfg, build_file=os.path.join(src_dir, "siplib", "siplib.sbf"), dir="siplib", install_dir=cfg.sip_mod_dir, installs=([os.path.join(src_dir, "siplib", "sip.h")], cfg.sip_inc_dir), console=1, warnings=0, static=opts.static, debug=opts.debug, universal=opts.universal, arch=opts.arch, deployment_target=opts.deployment_target).generate()
# FindSIP.py # # Copyright (c) 2007, Simon Edwards <*****@*****.**> # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. import sys import sipconfig sipcfg = sipconfig.Configuration() print("sip_version:%06.0x" % sipcfg.sip_version) print("sip_version_str:%s" % sipcfg.sip_version_str) print("sip_bin:%s" % sipcfg.sip_bin) print("default_sip_dir:%s" % sipcfg.default_sip_dir) print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. ############################################################################ import os import glob import sipconfig import shutil import numpy import platform from checksipexc import checksipexc # get sip version str_version = sipconfig.version_to_string( sipconfig.Configuration().sip_version) versions = [int(x) for x in str_version.split('.')] major, minor = versions[0], versions[1] modules = [ ('core', ['common', 'hardware', 'control']), ('simulator', [os.path.join('camera', 'simulator')]), ('pco', [os.path.join('camera', 'pco')]), ('espia', [os.path.join('camera', 'common', 'espia')]), ('frelon', [os.path.join('camera', 'frelon')]), ('maxipix', [os.path.join('camera', 'maxipix')]), ('basler', [os.path.join('camera', 'basler')]), ('prosilica', [os.path.join('camera', 'prosilica')]), ('ueye', [os.path.join('camera', 'ueye')]), ('roperscientific', [os.path.join('camera', 'roperscientific')]), ('adsc', [os.path.join('camera', 'adsc')]),