def finalize_options(self): self.cmdclass['config'] = config self.cmdclass['build'] = build self.cmdclass['build_exe'] = build_exe self.cmdclass['build_qk'] = build_qk self.cmdclass['build_ext'] = build_ext self.cmdclass['build_qext'] = build_qext self.cmdclass['install'] = install self.cmdclass['install_exe'] = install_exe self.cmdclass['install_qlib'] = install_qlib self.cmdclass['install_qext'] = install_qext self.cmdclass['test'] = PyTest if 'QHOME' in os.environ: self.qhome = os.getenv('QHOME') else: qhome_root = os.getenv( 'SystemDrive') + '\\' if platform == 'Windows' else os.getenv( 'HOME') self.qhome = os.path.join(qhome_root, 'q') if 'VIRTUAL_ENV' in os.environ: path = os.path.join(os.getenv('VIRTUAL_ENV'), 'q') if os.path.exists(path): self.qhome = path bits = BITS if platform == 'Linux': o = 'l' elif platform == 'SunOS': o = 'v' if uname()[-1] == 'i86pc' else 's' elif platform == 'Darwin': o = 'm' bits = 32 elif platform == 'Windows': o = 'w' bits = 32 # FIXME: We test with 32-bit kdb+ on Windows, so forcing 32-bit version. else: sys.stderr.write("Unknown platform: %s\n" % str(platform)) sys.exit(1) self.qarch = "%s%d" % (o, bits) self.install_data = os.path.join(self.qhome, self.qarch) self.kxver = self.get_kxver(self.qhome) self.qexecutable = os.path.join(self.qhome, self.qarch, 'q') _Distribution.finalize_options(self) for ext in self.ext_modules + self.qext_modules: ext.define_macros.append(('KXVER', self.kxver.split('.')[0])) ext.define_macros.append(('QVER', self.kxver.split('.')[0])) if sys.hexversion >= 0x3000000: ext.define_macros.append( ('PY3K', "%s%s" % sys.version_info[:2])) for exe in self.executables: exe.define_macros.append(('QARCH', self.qarch))
def finalize_options(self): self.cmdclass['config'] = config self.cmdclass['build'] = build self.cmdclass['build_exe'] = build_exe self.cmdclass['build_qk'] = build_qk self.cmdclass['build_ext'] = build_ext self.cmdclass['build_qext'] = build_qext self.cmdclass['install'] = install self.cmdclass['install_exe'] = install_exe self.cmdclass['install_qlib'] = install_qlib self.cmdclass['install_qext'] = install_qext self.cmdclass['test'] = PyTest default_qhome_root = os.getenv('SystemDrive') + '\\' if platform == 'Windows' else os.getenv('HOME') self.qhome = os.getenv('QHOME') or os.path.join(default_qhome_root, 'q') bits = BITS if platform == 'Linux': o = 'l' elif platform == 'SunOS': o = 'v' if uname()[-1] == 'i86pc' else 's' elif platform == 'Darwin': o = 'm' bits = 32 elif platform == 'Windows': o = 'w' bits = 32 # FIXME: We test with 32-bit kdb+ on Windows, so forcing 32-bit version. else: sys.stderr.write("Unknown platform: %s\n" % str(platform)) sys.exit(1) self.qarch = "%s%d" % (o, bits) self.install_data = os.path.join(self.qhome, self.qarch) self.kxver = self.get_kxver(self.qhome) self.qexecutable = os.path.join(self.qhome, self.qarch, 'q') _Distribution.finalize_options(self) for ext in self.ext_modules + self.qext_modules: ext.define_macros.append(('KXVER', self.kxver.split('.')[0])) ext.define_macros.append(('QVER', self.kxver.split('.')[0])) if sys.hexversion >= 0x3000000: ext.define_macros.append(('PY3K', "%s%s" % sys.version_info[:2]))
def get_ccompiler(): """ Return a new CCompiler instance. CCompiler used to be constructible via `distutils.ccompiler.new_compiler`, but this API was removed as part of the distutils deprecation. Instead, we trick setuptools into instantiating it by creating a dummy Distribution with a list of extension modules that claims to be truthy, but is actually empty, and then running the Distribution's build_ext command. (If using a plain empty ext_modules, build_ext would early-return without doing anything.) """ class L(list): def __bool__(self): return True build_ext = Distribution({"ext_modules": L()}).get_command_obj("build_ext") build_ext.finalize_options() build_ext.run() return build_ext.compiler
def finalize_options(self): self.cmdclass['config'] = config self.cmdclass['build'] = build self.cmdclass['build_exe'] = build_exe self.cmdclass['build_qk'] = build_qk self.cmdclass['build_ext'] = build_ext self.cmdclass['build_qext'] = build_qext self.cmdclass['install'] = install self.cmdclass['install_exe'] = install_exe self.cmdclass['install_qlib'] = install_qlib self.cmdclass['install_qext'] = install_qext self.cmdclass['test'] = PyTest self.qhome = os.getenv('QHOME') or os.path.join(os.getenv('HOME'), 'q') bits = 8 * get_config_var('SIZEOF_VOID_P') u = os.uname() if u[0] == 'Linux': o = 'l' elif u[0] == 'SunOS': o = 'v' if u[-1] == 'i86pc' else 's' elif u[0] == 'Darwin': o = 'm' bits = 32 else: sys.stderr.write("Unknown platform: %s\n" % str(u)) sys.exit(1) self.qarch = "%s%d" % (o, bits) self.install_data = os.path.join(self.qhome, self.qarch) self.kxver = self.get_kxver(self.qhome) self.qexecutable = os.path.join(self.qhome, self.qarch, 'q') _Distribution.finalize_options(self) for ext in self.ext_modules + self.qext_modules: ext.define_macros.append(('KXVER', self.kxver.split('.')[0])) ext.define_macros.append(('QVER', self.kxver.split('.')[0])) if sys.hexversion >= 0x3000000: ext.define_macros.append( ('PY3K', "%s%s" % sys.version_info[:2]))
def __init__(self): # TODO: is this really how we get the build paths? build_cmd = Distribution().get_command_obj('build') build_cmd.finalize_options() self.build_platlib = build_cmd.build_platlib self.build_temp = build_cmd.build_temp if platform.system() == "Windows": # Windows uses separate temp build folders for debug and release if build_cmd.debug: self.build_temp = os.path.join(self.build_temp, "Debug") else: self.build_temp = os.path.join(self.build_temp, "Release") build_ext_cmd = Distribution().get_command_obj('build_ext') build_ext_cmd.initialize_options() build_ext_cmd.setup_shlib_compiler() self.build_ext_cmd = build_ext_cmd self.root = "klayout"
def finalize_options(self): self.cmdclass['config'] = config self.cmdclass['build'] = build self.cmdclass['build_exe'] = build_exe self.cmdclass['build_qk'] = build_qk self.cmdclass['build_ext'] = build_ext self.cmdclass['build_qext'] = build_qext self.cmdclass['install'] = install self.cmdclass['install_exe'] = install_exe self.cmdclass['install_qlib'] = install_qlib self.cmdclass['install_qext'] = install_qext self.cmdclass['test'] = PyTest self.qhome = os.getenv('QHOME') or os.path.join(os.getenv('HOME'), 'q') bits = 8 * get_config_var('SIZEOF_VOID_P') u = os.uname() if u[0] == 'Linux': o = 'l' elif u[0] == 'SunOS': o = 'v' if u[-1] == 'i86pc' else 's' elif u[0] == 'Darwin': o = 'm' bits = 32 else: sys.stderr.write("Unknown platform: %s\n" % str(u)) sys.exit(1) self.qarch = "%s%d" % (o, bits) self.install_data = os.path.join(self.qhome, self.qarch) self.kxver = self.get_kxver(self.qhome) self.qexecutable = os.path.join(self.qhome, self.qarch, 'q') _Distribution.finalize_options(self) for ext in self.ext_modules + self.qext_modules: ext.define_macros.append(('KXVER', self.kxver.split('.')[0])) ext.define_macros.append(('QVER', self.kxver.split('.')[0])) if sys.hexversion >= 0x3000000: ext.define_macros.append(('PY3K', "%s%s" % sys.version_info[:2]))
build_ext_cmd.setup_shlib_compiler() def libname(name): """gets 'name' and returns something like libname.cpython-37m-darwin.so""" filename = build_ext_cmd.get_ext_filename(name) fn, ext = os.path.splitext(filename) return build_ext_cmd.shlib_compiler.library_filename(fn, libtype) pkg_name = "nonpy_rpath" crypt_name = "_cryptexample" crypt_soname = libname(crypt_name) build_cmd = Distribution().get_command_obj("build") build_cmd.finalize_options() build_platlib = build_cmd.build_platlib def link_args(soname=None): args = [] if soname: args += ["-Wl,-soname," + soname] loader_path = "$ORIGIN" args += ["-Wl,-rpath," + loader_path] return args nonpy_rpath_module = Extension( pkg_name + "._nonpy_rpath", language="c++",