Skip to content

Commit 49328f5

Browse files
committed
Add missing Python requirements, clean final result
1 parent a611f00 commit 49328f5

4 files changed

Lines changed: 87 additions & 7 deletions

File tree

compile_all.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,20 @@ def _build_standard_cmake(self, extra_args: List[str] = None):
516516

517517
def _pip_install(self, requirement: str) -> None:
518518
path_to_python = self.python_exe()
519+
if self.skip_existing:
520+
package_name = requirement.split("==")[0]
521+
try:
522+
result = subprocess.run(
523+
[path_to_python, "-m", "pip", "show", package_name],
524+
check=True,
525+
capture_output=True,
526+
)
527+
if "WARNING:" not in result.stdout.decode("utf-8"):
528+
print(f" Not reinstalling {package_name}, it is already in the LibPack")
529+
return
530+
except subprocess.CalledProcessError:
531+
pass
532+
519533
try:
520534
subprocess.run(
521535
[path_to_python, "-m", "pip", "install", requirement],
@@ -1024,6 +1038,16 @@ def build_calculix(self, _: None):
10241038
"""Cannot currently build Calculix (it's in Fortran, and we only support MSVC toolchain right now). Extract
10251039
the relevant files from the downloaded zipfile and copy them"""
10261040
path_to_ccx_bin = os.path.join(os.getcwd(), "CL35-win64", "bin", "ccx", "218")
1041+
if self.skip_existing:
1042+
if os.path.exists(path_to_ccx_bin):
1043+
print(" Not rebuilding Calculix, it is already in the LibPack")
1044+
return
10271045
if not os.path.exists(path_to_ccx_bin):
10281046
raise RuntimeError("Could not locate Calculix")
10291047
shutil.copytree(path_to_ccx_bin, os.path.join(self.install_dir, "bin"), dirs_exist_ok=True)
1048+
# The download we use calls the executable ccx218.exe, but FreeCAD would prefer it be called ccx.exe for
1049+
# automatic location of the executable
1050+
shutil.move(
1051+
os.path.join(self.install_dir, "bin", "ccx218.exe"),
1052+
os.path.join(self.install_dir, "bin", "ccx.exe"),
1053+
)

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"FreeCAD-version":"1.0.0",
3-
"LibPack-version":"3.0.0",
3+
"LibPack-version":"3.0.0RC3",
44
"content": [
55
{
66
"name":"python",

create_libpack.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def write_manifest(outer_config: dict, mode_used: compile_all.BuildMode):
292292
path_cleaner.remove_local_path_from_cmake_files(base_path)
293293
path_cleaner.correct_opencascade_freetype_ref(base_path)
294294
path_cleaner.delete_qtwebengine(base_path)
295+
path_cleaner.delete_qtquick(base_path)
295296
path_cleaner.delete_llvm_executables(base_path)
297+
path_cleaner.delete_clang_executables(base_path)
296298

297299
write_manifest(config_dict, mode)

path_cleaner.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# should probably be consolidated.
44

55
import os
6+
import shutil
67

78
paths_to_delete = [
89
"custom_vc14_64.bat",
@@ -12,12 +13,14 @@
1213
"env.bat",
1314
"draw.bat",
1415
"RELEASE.txt",
16+
"samples",
1517
]
1618

1719

1820
def delete_extraneous_files(base_path: str) -> None:
1921
"""Delete each of the files listed above from the path specified in base_path. Failure to delete a file does not
2022
constitute a fatal error."""
23+
print("Removing extraneous files")
2124
if not os.path.exists(base_path):
2225
raise RuntimeError(f"{base_path} does not exist")
2326
if not os.path.isdir(base_path):
@@ -35,6 +38,7 @@ def remove_local_path_from_cmake_files(base_path: str) -> None:
3538
a) OpenCASCADE codes in the local path to FreeType, which then fails when the LibPack is distributed, and b) for
3639
good measure cMake files shouldn't refer to non-existent paths on a foreign system. So this method looks for
3740
cmake config files and cleans the ones it finds."""
41+
print("Removing local paths from cMake files")
3842
for root, dirs, files in os.walk(base_path):
3943
for file in files:
4044
if file.lower().endswith(".cmake"):
@@ -108,27 +112,77 @@ def delete_qtwebengine(base_path: str):
108112
"""QtWebEngine is huge and pervasive -- it's also not used by FreeCAD (anymore). Delete anything that seems to be
109113
related to it from the LibPack."""
110114

115+
print("Removing QtWebEngine (and related code)")
111116
for root, dirs, files in os.walk(base_path):
117+
for dir in dirs:
118+
if (
119+
"webengine" in dir.lower()
120+
or "webchannel" in dir.lower()
121+
or "websockets" in dir.lower()
122+
):
123+
try:
124+
full_path = os.path.join(root, dir)
125+
shutil.rmtree(full_path)
126+
except OSError as e:
127+
print(f"Failed to delete file {full_path}: {e}")
112128
for file in files:
113129
if "webengine" in file.lower() or "webchannel" in file.lower():
114130
try:
115-
os.unlink(os.path.join(base_path, file))
131+
full_path = os.path.join(root, file)
132+
os.unlink(full_path)
116133
except OSError as e:
117-
pass
134+
print(f"Failed to delete path {full_path}: {e}")
135+
136+
137+
def delete_qtquick(base_path: str):
138+
"""QtQuick is unused in FreeCAD at this time."""
139+
140+
def is_qtquick(name: str) -> bool:
141+
lc = name.lower()
142+
if "qtquick" in lc or "qml" in lc:
143+
return True
144+
if lc.startswith("q") and "quick" in lc:
145+
return True
146+
return False
147+
148+
print("Removing QtQuick/QML")
149+
for root, dirs, files in os.walk(base_path):
118150
for dir in dirs:
119-
if "webengine" in dir.lower() or "webchannel" in dir.lower():
151+
if is_qtquick(dir):
152+
try:
153+
full_path = os.path.join(root, dir)
154+
shutil.rmtree(full_path)
155+
except OSError as e:
156+
print(f"Failed to delete file {full_path}: {e}")
157+
for file in files:
158+
if is_qtquick(file):
120159
try:
121-
shutil.rmtree(os.path.join(base_path, dir))
160+
full_path = os.path.join(root, file)
161+
os.unlink(full_path)
122162
except OSError as e:
123-
pass
163+
print(f"Failed to delete path {full_path}: {e}")
124164

125165

126166
def delete_llvm_executables(base_path: str):
127167
"""During the build of the libpack, a number of llvm executable files are created: these are not needed to compile
128168
or run FreeCAD, so remove them."""
169+
print("Removing llvm executables")
170+
files_in_bin = os.listdir(os.path.join(base_path, "bin"))
171+
for file in files_in_bin:
172+
if file.startswith("llvm") and file.endswith(".exe"):
173+
try:
174+
os.unlink(os.path.join(base_path, "bin", file))
175+
except OSError as e:
176+
pass
177+
178+
179+
def delete_clang_executables(base_path: str):
180+
"""During the build of the libpack, a number of clang executable files are created: these are not needed to compile
181+
or run FreeCAD, so remove them."""
182+
print("Removing clang executables")
129183
files_in_bin = os.listdir(os.path.join(base_path, "bin"))
130184
for file in files_in_bin:
131-
if file.startswith(llvm) and file.endswith(".exe"):
185+
if file.startswith("clang") and file.endswith(".exe"):
132186
try:
133187
os.unlink(os.path.join(base_path, "bin", file))
134188
except OSError as e:

0 commit comments

Comments
 (0)