44import subprocess
55import sys
66
7- from setuptools import setup
7+ from setuptools import setup , Extension , find_packages
88from setuptools .command .build_ext import build_ext
99from setuptools .command .install import install
1010from setuptools .command .bdist_wheel import bdist_wheel
@@ -27,7 +27,12 @@ def is_virtualenv():
2727def get_base_python_path (venv_path ):
2828 return re .search ("home = (.*)\n " , open (os .path .join (venv_path , "pyvenv.cfg" ), 'r' ).read ()).group (1 )
2929
30+
31+ cmake_built = False
3032def run_cmake ():
33+ global cmake_built
34+ if cmake_built : return
35+
3136 cmake_args = []
3237 build_args = ["--config" , "Release" ]
3338
@@ -68,6 +73,15 @@ def run_cmake():
6873 sys .stdout .flush ()
6974 subprocess .check_call (cmake_build , cwd = build_folder )
7075
76+ cmake_built = True
77+
78+
79+ class FakeExtension (Extension ):
80+
81+ def __init__ (self , name , sourcedir = "" ):
82+ Extension .__init__ (self , name , sources = [], py_limited_api = True )
83+ self .sourcedir = os .path .abspath (sourcedir )
84+
7185
7286class CMakeBuild (build_ext ):
7387
@@ -98,13 +112,15 @@ def run(self):
98112 license = "LICENSE" ,
99113 url = URL ,
100114 install_requires = INSTALL_REQUIRES ,
115+ ext_modules = [FakeExtension ("LAppModelWrapper" , "." )],
101116 cmdclass = {
102117 "build_ext" : CMakeBuild ,
103118 "bdist_wheel" : BuildWheel ,
104119 "install" : Install
105120 },
106- packages = ["package.live2d" ],
107- package_data = {"package.live2d" : ["*" , "**/*.pyd" , "**/*.so" , "**/*.pyi" , "**/*.py" ]},
121+ packages = ["live2d" ],
122+ package_data = {"live2d" : ["**/*.pyd" , "**/*.so" , "**/*.pyi" , "**/*.py" ]},
123+ package_dir = {"live2d" : "package/live2d" },
108124 keywords = ["Live2D" , "Cubism Live2D" , "Cubism SDK" , "Cubism SDK for Python" ],
109125 python_requires = REQUIRES_PYTHON
110126)
0 commit comments