1 Star 0 Fork 12

Leon/Tensorpipe

forked from Ascend/Tensorpipe 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
setup.py 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
王诚昊 提交于 2023-08-31 19:22 . add pybind11 compile script
# Copyright (c) 2023 Huawei Technologies Co., Ltd
# Copyright (c) 2020 Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import os
import subprocess
import sys
from pathlib import Path
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class CMakeBuild(build_ext):
def run(self):
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
source_path = Path(__file__).parent.resolve()
output_path = Path(self.get_ext_fullpath(ext.name)).parent.resolve()
build_type = "Debug" if self.debug else "Release"
cmake_cmd = [
"cmake",
f"{source_path}",
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={output_path}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={build_type}",
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
"-DCMAKE_POSITION_INDEPENDENT_CODE=true",
"-DTP_BUILD_PYTHON=true",
]
for opt in os.environ:
if opt.startswith("TP_"):
cmake_cmd.append(f"-D{opt}={os.environ[opt]}")
make_cmd = ["make", "-j", "pytensorpipe"]
subprocess.check_call(cmake_cmd, cwd=self.build_temp)
subprocess.check_call(make_cmd, cwd=self.build_temp)
setup(
name="tensorpipe",
version="0.0.0",
author="Huawei Ascend",
ext_modules=[Extension("pytensorpipe", sources=[])],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/carpediemml/Tensorpipe.git
git@gitee.com:carpediemml/Tensorpipe.git
carpediemml
Tensorpipe
Tensorpipe
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385