Setup: don't build speedups in-place, copy isntead (#1945)
This commit is contained in:
parent
cbb7616f03
commit
50537a9161
24
setup.py
24
setup.py
|
@ -6,6 +6,7 @@ import shutil
|
||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import typing
|
import typing
|
||||||
|
import warnings
|
||||||
import zipfile
|
import zipfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import io
|
import io
|
||||||
|
@ -302,17 +303,28 @@ class BuildExeCommand(cx_Freeze.command.build_exe.BuildEXE):
|
||||||
|
|
||||||
# auto-build cython modules
|
# auto-build cython modules
|
||||||
build_ext = self.distribution.get_command_obj("build_ext")
|
build_ext = self.distribution.get_command_obj("build_ext")
|
||||||
build_ext.inplace = True
|
build_ext.inplace = False
|
||||||
self.run_command("build_ext")
|
self.run_command("build_ext")
|
||||||
|
# find remains of previous in-place builds, try to delete and warn otherwise
|
||||||
|
for path in build_ext.get_outputs():
|
||||||
|
parts = os.path.split(path)[-1].split(".")
|
||||||
|
pattern = parts[0] + ".*." + parts[-1]
|
||||||
|
for match in Path().glob(pattern):
|
||||||
|
try:
|
||||||
|
match.unlink()
|
||||||
|
print(f"Removed {match}")
|
||||||
|
except Exception as ex:
|
||||||
|
warnings.warn(f"Could not delete old build output: {match}\n"
|
||||||
|
f"{ex}\nPlease close all AP instances and delete manually.")
|
||||||
|
|
||||||
# regular cx build
|
# regular cx build
|
||||||
self.buildtime = datetime.datetime.utcnow()
|
self.buildtime = datetime.datetime.utcnow()
|
||||||
super().run()
|
super().run()
|
||||||
|
|
||||||
# delete in-place built modules, otherwise this interferes with future pyximport
|
# manually copy built modules to lib folder. cx_Freeze does not know they exist.
|
||||||
for path in build_ext.get_output_mapping().values():
|
for src in build_ext.get_outputs():
|
||||||
print(f"deleting temp {path}")
|
print(f"copying {src} -> {self.libfolder}")
|
||||||
os.unlink(path)
|
shutil.copy(src, self.libfolder, follow_symlinks=False)
|
||||||
|
|
||||||
# need to finish download before copying
|
# need to finish download before copying
|
||||||
sni_thread.join()
|
sni_thread.join()
|
||||||
|
@ -599,7 +611,7 @@ cx_Freeze.setup(
|
||||||
ext_modules=cythonize("_speedups.pyx"),
|
ext_modules=cythonize("_speedups.pyx"),
|
||||||
options={
|
options={
|
||||||
"build_exe": {
|
"build_exe": {
|
||||||
"packages": ["worlds", "kivy", "_speedups", "cymem"],
|
"packages": ["worlds", "kivy", "cymem"],
|
||||||
"includes": [],
|
"includes": [],
|
||||||
"excludes": ["numpy", "Cython", "PySide2", "PIL",
|
"excludes": ["numpy", "Cython", "PySide2", "PIL",
|
||||||
"pandas"],
|
"pandas"],
|
||||||
|
|
Loading…
Reference in New Issue