我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用setuptools.command.install()。
def run(self): bin = os.path.join(self.root, "usr/bin") try: os.makedirs(bin) except: pass for file, pkg in get_console_scripts(): path = os.path.join(bin, file) with open(path, "w") as f: f.write( """#!/usr/bin/python3 from {} import main import sys if __name__ == '__main__': sys.exit(main()) """.format(pkg)) os.chmod(path, 0o755) setuptools.command.install.install.run(self)
def run(self): if not self.skip_build: self.run_command('build_deps') setuptools.command.install.install.run(self)
def run(self): self.create_version_file() setuptools.command.install.install.run(self) subprocess.check_call("python test/test.py".split())
def build_libs(libs): for lib in libs: assert lib in dep_libs, 'invalid lib: {}'.format(lib) if IS_WINDOWS: build_libs_cmd = ['torch\\lib\\build_libs.bat'] else: build_libs_cmd = ['bash', 'torch/lib/build_libs.sh'] my_env = os.environ.copy() my_env["PYTORCH_PYTHON"] = sys.executable if not IS_WINDOWS: if WITH_NINJA: my_env["CMAKE_GENERATOR"] = '-GNinja' my_env["CMAKE_INSTALL"] = 'ninja install' else: my_env['CMAKE_GENERATOR'] = '' my_env['CMAKE_INSTALL'] = 'make install' if WITH_SYSTEM_NCCL: my_env["NCCL_ROOT_DIR"] = NCCL_ROOT_DIR if WITH_CUDA: my_env["CUDA_BIN_PATH"] = CUDA_HOME build_libs_cmd += ['--with-cuda'] if WITH_CUDNN: my_env["CUDNN_LIB_DIR"] = CUDNN_LIB_DIR my_env["CUDNN_INCLUDE_DIR"] = CUDNN_INCLUDE_DIR if subprocess.call(build_libs_cmd + libs, env=my_env) != 0: sys.exit(1) if 'ATen' in libs: from tools.nnwrap import generate_wrappers as generate_nn_wrappers generate_nn_wrappers()
def create_compile_commands(self): def load(filename): with open(filename) as f: return json.load(f) ninja_files = glob.glob('build/*_compile_commands.json') cmake_files = glob.glob('torch/lib/build/*/compile_commands.json') all_commands = [entry for f in ninja_files + cmake_files for entry in load(f)] with open('compile_commands.json', 'w') as f: json.dump(all_commands, f, indent=2) if not WITH_NINJA: print("WARNING: 'develop' is not building C++ code incrementally") print("because ninja is not installed. Run this to enable it:") print(" > pip install ninja")