Skip to content

Instantly share code, notes, and snippets.

@meisa233
Created October 21, 2025 07:14
Show Gist options
  • Select an option

  • Save meisa233/968bea82a62a1073497ffa314a8f1d91 to your computer and use it in GitHub Desktop.

Select an option

Save meisa233/968bea82a62a1073497ffa314a8f1d91 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from setuptools import setup
from Cython.Build import cythonize
import os
# 指定要编译的文件夹
py_files = []
for root, dirs, files in os.walk("./"):
if "dist" in root or "venv" in root or "logs" in root or "input" in root or "output" in root or "test_videos" in root:
continue
for file in files:
if file.endswith(".py"):
py_files.append(os.path.join(root, file))
setup(
ext_modules=cythonize(py_files, compiler_directives={'language_level': "3"}), # Python 3 版本
)
# 运行命令
# 需要通过pip install cython安装cython
# python setup.py build_ext --inplace
# 运行完之后只需要所有的.so文件就可以运行了
# 但是需要自己写一个py文件用来进入程序
# 比如我运行的时候是`python -u shuzishuiyin.py`
# 那么就需要写一个run.py里面import shuzishuiyin;shuzishuiyin.main()
# 注意需要在shuzishuiyin.py里面设定一个def main()的入口
# 运行的时候运行run.py即可
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment