Skip to content

Commit 8e1332d

Browse files
authored
Merge pull request #59 from FreeCAD/dev
Continue migration to external repo
2 parents ca46a74 + 1dddf40 commit 8e1332d

File tree

4 files changed

+123
-31
lines changed

4 files changed

+123
-31
lines changed

CMakeLists.txt

Lines changed: 85 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
IF (BUILD_GUI)
2-
PYSIDE_WRAP_RC(AddonManager_QRC_SRCS Resources/AddonManager.qrc)
32
add_subdirectory(Widgets)
43
ENDIF (BUILD_GUI)
54

@@ -82,6 +81,89 @@ ENDIF (BUILD_GUI)
8281

8382
SOURCE_GROUP("" FILES ${AddonManager_SRCS})
8483

84+
SET(AddonManagerResourceFilesIcons
85+
Resources/icons/addon_manager.svg
86+
Resources/icons/addon_manager_with_warning.svg
87+
Resources/icons/button_left.svg
88+
Resources/icons/button_valid.svg
89+
Resources/icons/compact_view.svg
90+
Resources/icons/composite_view.svg
91+
Resources/icons/debug-stop.svg
92+
Resources/icons/document-package.svg
93+
Resources/icons/document-python.svg
94+
Resources/icons/expanded_view.svg
95+
Resources/icons/process-stop.svg
96+
Resources/icons/sort_ascending.svg
97+
Resources/icons/sort_descending.svg
98+
Resources/icons/view-refresh.svg
99+
)
100+
101+
SET(AddonManagerResourceFilesTranslations
102+
Resources/translations/AddonManager_af.qm
103+
Resources/translations/AddonManager_ar.qm
104+
Resources/translations/AddonManager_be.qm
105+
Resources/translations/AddonManager_bg.qm
106+
Resources/translations/AddonManager_ca.qm
107+
Resources/translations/AddonManager_cs.qm
108+
Resources/translations/AddonManager_da.qm
109+
Resources/translations/AddonManager_de.qm
110+
Resources/translations/AddonManager_el.qm
111+
Resources/translations/AddonManager_es-AR.qm
112+
Resources/translations/AddonManager_es-ES.qm
113+
Resources/translations/AddonManager_eu.qm
114+
Resources/translations/AddonManager_fi.qm
115+
Resources/translations/AddonManager_fil.qm
116+
Resources/translations/AddonManager_fr.qm
117+
Resources/translations/AddonManager_gl.qm
118+
Resources/translations/AddonManager_hr.qm
119+
Resources/translations/AddonManager_hu.qm
120+
Resources/translations/AddonManager_id.qm
121+
Resources/translations/AddonManager_it.qm
122+
Resources/translations/AddonManager_ja.qm
123+
Resources/translations/AddonManager_ka.qm
124+
Resources/translations/AddonManager_kab.qm
125+
Resources/translations/AddonManager_ko.qm
126+
Resources/translations/AddonManager_lt.qm
127+
Resources/translations/AddonManager_nl.qm
128+
Resources/translations/AddonManager_no.qm
129+
Resources/translations/AddonManager_pl.qm
130+
Resources/translations/AddonManager_pt-BR.qm
131+
Resources/translations/AddonManager_pt-PT.qm
132+
Resources/translations/AddonManager_ro.qm
133+
Resources/translations/AddonManager_ru.qm
134+
Resources/translations/AddonManager_sk.qm
135+
Resources/translations/AddonManager_sl.qm
136+
Resources/translations/AddonManager_sr-CS.qm
137+
Resources/translations/AddonManager_sr.qm
138+
Resources/translations/AddonManager_sv-SE.qm
139+
Resources/translations/AddonManager_tr.qm
140+
Resources/translations/AddonManager_uk.qm
141+
Resources/translations/AddonManager_val-ES.qm
142+
Resources/translations/AddonManager_vi.qm
143+
Resources/translations/AddonManager_zh-CN.qm
144+
Resources/translations/AddonManager_zh-TW.qm
145+
)
146+
147+
LIST(APPEND AddonManager_SRCS
148+
${AddonManagerResourceFilesIcons}
149+
${AddonManagerResourceFilesLicenses}
150+
${AddonManagerResourceFilesTranslations}
151+
)
152+
153+
SET(AddonManagerResourceFilesLicenses
154+
Resources/licenses/Apache-2.0.txt
155+
Resources/licenses/BSD-2-Clause.txt
156+
Resources/licenses/BSD-3-Clause.txt
157+
Resources/licenses/CC0-1.0.txt
158+
Resources/licenses/GPL-2.0-or-later.txt
159+
Resources/licenses/GPL-3.0-or-later.txt
160+
Resources/licenses/LGPL-2.1-or-later.txt
161+
Resources/licenses/LGPL-3.0-or-later.txt
162+
Resources/licenses/MIT.txt
163+
Resources/licenses/MPL-2.0.txt
164+
Resources/licenses/spdx.json
165+
)
166+
85167
SET(AddonManagerTests_SRCS
86168
AddonManagerTest/__init__.py
87169
AddonManagerTest/test_information.md
@@ -157,32 +239,17 @@ IF (BUILD_GUI)
157239
ENDIF (BUILD_GUI)
158240

159241
ADD_CUSTOM_TARGET(AddonManager ALL
160-
SOURCES ${AddonManager_SRCS} ${AddonManager_QRC_SRCS}
242+
SOURCES ${AddonManager_SRCS}
161243
)
162244

163245
ADD_CUSTOM_TARGET(AddonManagerTests ALL
164246
SOURCES ${AddonManagerTests_ALL}
165247
)
166248

167249
fc_copy_sources(AddonManager "${CMAKE_BINARY_DIR}/Mod/AddonManager" ${AddonManager_SRCS})
168-
169250
fc_copy_sources(AddonManagerTests "${CMAKE_BINARY_DIR}/Mod/AddonManager" ${AddonManagerTests_ALL})
170251

171-
IF (BUILD_GUI)
172-
fc_target_copy_resource(AddonManager
173-
${CMAKE_CURRENT_BINARY_DIR}
174-
${CMAKE_BINARY_DIR}/Mod/AddonManager
175-
AddonManager_rc.py)
176-
ENDIF (BUILD_GUI)
177-
178-
INSTALL(
179-
FILES
180-
${AddonManager_SRCS}
181-
${AddonManager_QRC_SRCS}
182-
DESTINATION
183-
Mod/AddonManager
184-
)
185-
252+
INSTALL(FILES ${AddonManager_SRCS} DESTINATION Mod/AddonManager)
186253
INSTALL(FILES ${AddonManagerTests_SRCS} DESTINATION Mod/AddonManager/AddonManagerTest)
187254
INSTALL(FILES ${AddonManagerTestsApp_SRCS} DESTINATION Mod/AddonManager/AddonManagerTest/app)
188255
INSTALL(FILES ${AddonManagerTestsGui_SRCS} DESTINATION Mod/AddonManager/AddonManagerTest/gui)

addonmanager_freecad_interface.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,46 @@
3232
import json
3333
import logging
3434
import os
35+
import platform
36+
import shutil
3537
import tempfile
3638

3739
# pylint: disable=too-few-public-methods
3840

3941
try:
4042
import FreeCAD
41-
from freecad.utils import get_python_exe
43+
44+
try:
45+
from freecad.utils import get_python_exe
46+
except ImportError:
47+
# This was only added in FreeCAD 1.0 -- to support FreeCAD 0.21 a backup strategy must be
48+
# used. This code is borrowed from FreeCAD 1.1dev.
49+
def get_python_exe():
50+
prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/PythonConsole")
51+
python_exe = prefs.GetString("ExternalPythonExecutable", "Not set")
52+
fc_dir = FreeCAD.getHomePath()
53+
if not python_exe or python_exe == "Not set" or not os.path.exists(python_exe):
54+
python_exe = os.path.join(fc_dir, "bin", "python3")
55+
if "Windows" in platform.system():
56+
python_exe += ".exe"
57+
58+
if not python_exe or not os.path.exists(python_exe):
59+
python_exe = os.path.join(fc_dir, "bin", "python")
60+
if "Windows" in platform.system():
61+
python_exe += ".exe"
62+
63+
if not python_exe or not os.path.exists(python_exe):
64+
python_exe = shutil.which("python3")
65+
66+
if not python_exe or not os.path.exists(python_exe):
67+
python_exe = shutil.which("python")
68+
69+
if not python_exe or not os.path.exists(python_exe):
70+
return ""
71+
72+
python_exe = python_exe.replace("/", os.path.sep)
73+
prefs.SetString("ExternalPythonExecutable", python_exe)
74+
return python_exe
4275

4376
if not hasattr(FreeCAD, "Console"):
4477
raise ImportError("Unrecognized FreeCAD version")
@@ -105,6 +138,9 @@ def translate(context: str, sourceText: str, disambiguation: str = "", n: int =
105138
def Version():
106139
return 1, 1, 0, "dev"
107140

141+
def get_python_exe():
142+
return shutil.which("python3")
143+
108144
class ConsoleReplacement:
109145
"""If FreeCAD's Console is not available, create a replacement by redirecting FreeCAD
110146
log calls to Python's built-in logging facility."""

addonmanager_utilities.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@
4949

5050
import addonmanager_freecad_interface as fci
5151

52-
try:
53-
from freecad.utils import get_python_exe
54-
except ImportError:
55-
56-
def get_python_exe():
57-
"""Use shutil.which to find python executable"""
58-
return shutil.which("python")
59-
6052

6153
if fci.FreeCADGui:
6254

@@ -597,7 +589,7 @@ def create_pip_call(args: List[str]) -> List[str]:
597589
call_args = [python_exe, "-m", "pip", "--disable-pip-version-check"]
598590
call_args.extend(args)
599591
else:
600-
python_exe = get_python_exe()
592+
python_exe = fci.get_python_exe()
601593
if not python_exe:
602594
raise RuntimeError("Could not locate Python executable on this system")
603595
call_args = [python_exe, "-m", "pip", "--disable-pip-version-check"]

first_run.ui

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
<property name="scaledContents">
5252
<bool>false</bool>
5353
</property>
54-
<property name="pixmap">
55-
<pixmap resource="../AddonManager.qrc">:/icons/AddonMgrWithWarning.svg</pixmap>
56-
</property>
5754
</widget>
5855
</item>
5956
<item>

0 commit comments

Comments
 (0)