本文整理汇总了Python中dragnn.__file__方法的典型用法代码示例。如果您正苦于以下问题:Python dragnn.__file__方法的具体用法?Python dragnn.__file__怎么用?Python dragnn.__file__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dragnn
的用法示例。
在下文中一共展示了dragnn.__file__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import dragnn [as 别名]
# 或者: from dragnn import __file__ [as 别名]
def main():
cmd_args = argparse.ArgumentParser()
cmd_args.add_argument("--include-tensorflow", action="store_true")
cmd_args.add_argument("--output-dir", required=True)
args = cmd_args.parse_args()
if not os.path.isdir(args.output_dir):
raise EnvironmentError(
"Output directory {} doesn't exist".format(args.output_dir))
elif not args.output_dir.startswith("/"):
raise EnvironmentError("Please pass an absolute path to --output-dir.")
tmp_packaging = tempfile.mkdtemp()
runfiles, = (path for path in sys.path
if path.endswith("build_pip_package.runfiles"))
# Use the dragnn and tensorflow modules to resolve specific paths in the
# runfiles directory. Current Bazel puts dragnn in a __main__ subdirectory,
# for example.
lib_path = os.path.abspath(dragnn.__file__)
if runfiles not in lib_path:
raise EnvironmentError("WARNING: Unexpected PYTHONPATH set by Bazel :(")
base_dir = os.path.dirname(os.path.dirname(lib_path))
tensorflow_dir = os.path.dirname(tensorflow.__file__)
if runfiles not in tensorflow_dir:
raise EnvironmentError("WARNING: Unexpected tf PYTHONPATH set by Bazel :(")
# Copy the files.
subprocess.check_call([
"cp", "-r", os.path.join(base_dir, "dragnn"), os.path.join(
base_dir, "syntaxnet"), tmp_packaging
])
if args.include_tensorflow:
subprocess.check_call(
["cp", "-r", tensorflow_dir, tmp_packaging])
shutil.copy(
os.path.join(base_dir, "dragnn/tools/oss_setup.py"),
os.path.join(tmp_packaging, "setup.py"))
subprocess.check_output(
["python", "setup.py", "bdist_wheel"], cwd=tmp_packaging)
wheel, = glob.glob("{}/*.whl".format(os.path.join(tmp_packaging, "dist")))
shutil.move(wheel, args.output_dir)
print(
"Wrote {}".format(os.path.join(args.output_dir, os.path.basename(wheel))))
示例2: main
# 需要导入模块: import dragnn [as 别名]
# 或者: from dragnn import __file__ [as 别名]
def main():
cmd_args = argparse.ArgumentParser()
cmd_args.add_argument("--include-tensorflow", action="store_true")
cmd_args.add_argument("--output-dir", required=True)
args = cmd_args.parse_args()
if not os.path.isdir(args.output_dir):
raise EnvironmentError(
"Output directory {} doesn't exist".format(args.output_dir))
elif not args.output_dir.startswith("/"):
raise EnvironmentError("Please pass an absolute path to --output-dir.")
tmp_packaging = tempfile.mkdtemp()
runfiles, = (path for path in sys.path
if path.endswith("build_pip_package.runfiles"))
# Use the dragnn and tensorflow modules to resolve specific paths in the
# runfiles directory. Current Bazel puts dragnn in a __main__ subdirectory,
# for example.
lib_path = os.path.abspath(dragnn.__file__)
if runfiles not in lib_path:
raise EnvironmentError("WARNING: Unexpected PYTHONPATH set by Bazel :(")
base_dir = os.path.dirname(os.path.dirname(lib_path))
tensorflow_dir = os.path.dirname(tensorflow.__file__)
if runfiles not in tensorflow_dir:
raise EnvironmentError("WARNING: Unexpected tf PYTHONPATH set by Bazel :(")
# Copy the files.
subprocess.check_call([
"cp", "-r",
"--no-preserve=all", os.path.join(base_dir, "dragnn"), os.path.join(
base_dir, "syntaxnet"), tmp_packaging
])
if args.include_tensorflow:
subprocess.check_call(
["cp", "-r", "--no-preserve=all", tensorflow_dir, tmp_packaging])
shutil.copy(
os.path.join(base_dir, "dragnn/tools/oss_setup.py"),
os.path.join(tmp_packaging, "setup.py"))
subprocess.check_output(
["python", "setup.py", "bdist_wheel"], cwd=tmp_packaging)
wheel, = glob.glob("{}/*.whl".format(os.path.join(tmp_packaging, "dist")))
shutil.move(wheel, args.output_dir)
print(
"Wrote {}".format(os.path.join(args.output_dir, os.path.basename(wheel))))