我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用setuptools.Distribution()。
def ask_supports_thread(): from distutils.core import Distribution from distutils.sysconfig import get_config_vars get_config_vars() # workaround for a bug of distutils, e.g. on OS/X config = Distribution().get_command_obj('config') ok = config.try_compile('__thread int some_threadlocal_variable_42;') if ok: define_macros.append(('USE__THREAD', None)) else: ok1 = config.try_compile('int some_regular_variable_42;') if not ok1: no_working_compiler_found() sys.stderr.write("Note: will not use '__thread' in the C code\n") sys.stderr.write("The above error message can be safely ignored\n")
def get_setuptools_script_dir(): # Run the above class just to get paths dist = Distribution({'cmdclass': {'install': GetPaths}}) dist.dry_run = True dist.parse_config_files() command = dist.get_command_obj('install') command.ensure_finalized() command.run() print(dist.install_libbase) src_dir = glob(os.path.join(dist.install_libbase, 'medaka-*', 'exes'))[0] for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)): print("Copying", os.path.basename(exe), '->', dist.install_scripts) shutil.copy(exe, dist.install_scripts) return dist.install_libbase, dist.install_scripts
def get_setuptools_script_dir(): # Run the above class just to get paths dist = Distribution({'cmdclass': {'install': GetPaths}}) dist.dry_run = True dist.parse_config_files() command = dist.get_command_obj('install') command.ensure_finalized() command.run() src_dir = glob(os.path.join(dist.install_libbase, 'pomoxis-*', 'exes'))[0] for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)): print("Copying", os.path.basename(exe), '->', dist.install_scripts) shutil.copy(exe, dist.install_scripts) return dist.install_libbase, dist.install_scripts
def new_distribution(self): return Distribution({})