Skip to content

Commit 9ff3cc5

Browse files
committed
prevent duplicated building
1 parent ba9a9fe commit 9ff3cc5

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

.github/workflows/build-linux.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ jobs:
3636
architecture: ${{ matrix.architecture }}
3737

3838
- name: Install build deps
39-
run: python -m pip install setuptools wheel
39+
run: |
40+
python -m pip install --upgrade setuptools
41+
python -m pip install wheel
4042
4143
- name: Build a source tarball
4244
if: ${{ matrix.python-version == '3.13'}}

setup.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import subprocess
55
import sys
66

7-
from setuptools import setup
7+
from setuptools import setup, Extension, find_packages
88
from setuptools.command.build_ext import build_ext
99
from setuptools.command.install import install
1010
from setuptools.command.bdist_wheel import bdist_wheel
@@ -27,7 +27,12 @@ def is_virtualenv():
2727
def 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
3032
def 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

7286
class 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

Comments
 (0)