-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe1be21
commit 6f9a372
Showing
7 changed files
with
47 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ MODULE* | |
|
||
# py | ||
__pycache__ | ||
*.egg-info | ||
|
||
# model | ||
*.gynn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
file(GLOB BIND_SRC "*.cc") | ||
pybind11_add_module(mininn MODULE ${BIND_SRC}) | ||
target_link_libraries(mininn PRIVATE runtime kernel operator parser graph utils) | ||
pybind11_add_module(mininn_capi MODULE ${BIND_SRC}) | ||
target_link_libraries(mininn_capi PRIVATE runtime kernel operator parser graph utils) | ||
|
||
message(STATUS "Source files for mininn library: ${BIND_SRC}") | ||
message(STATUS "Source files for mininn_capi library: ${BIND_SRC}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
from setuptools import setup, find_packages, Extension | ||
from setuptools import setup, find_packages | ||
from setuptools.command.build_py import build_py | ||
|
||
import os | ||
import shutil | ||
|
||
VERSION = '0.0.1' | ||
DESCRIPTION = 'My first Python package' | ||
LONG_DESCRIPTION = 'My first Python package with a slightly longer description' | ||
DESCRIPTION = 'python interface of MiniNN' | ||
LONG_DESCRIPTION = 'Build a deep learning inference framework from scratch' | ||
|
||
ext_modules = [ | ||
Extension( | ||
'mininn', | ||
["mininn.so"], | ||
), | ||
] | ||
class CustomBuildCommand(build_py): | ||
"""Custom build step to copy CMake-built .so file into the package.""" | ||
def run(self): | ||
cmake_output = os.path.abspath("../build/python/mininn_capi.cpython-311-x86_64-linux-gnu.so") | ||
target_dir = os.path.join(self.build_lib, "mininn") | ||
|
||
if not os.path.exists(target_dir): | ||
os.makedirs(target_dir) | ||
|
||
if os.path.exists(cmake_output): | ||
shutil.copyfile(cmake_output, os.path.join(target_dir, "mininn_capi.so")) | ||
else: | ||
raise FileNotFoundError(f"{cmake_output} does not exist. Build with CMake first.") | ||
|
||
super().run() | ||
|
||
|
||
# 配置 | ||
setup( | ||
name="mininn", | ||
version=VERSION, | ||
author="masteryi-0018", | ||
author_email="<[email protected]>", | ||
description=DESCRIPTION, | ||
long_description=LONG_DESCRIPTION, | ||
packages=find_packages(), | ||
install_requires=[], | ||
name = "mininn", | ||
version = VERSION, | ||
author = "masteryi-0018", | ||
author_email = "<[email protected]>", | ||
description = DESCRIPTION, | ||
long_description = LONG_DESCRIPTION, | ||
packages = find_packages(), | ||
cmdclass={"build_py": CustomBuildCommand}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters