Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into CURA-11622_conan_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 27, 2024
2 parents 9238e7e + 428ea3a commit 8e25302
Show file tree
Hide file tree
Showing 7,873 changed files with 72,734 additions and 12,136 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
29 changes: 20 additions & 9 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
version: "5.9.0-alpha.0"

version: "5.10.0-alpha.0"
requirements:
- "cura_resources/5.9.0-alpha.0@ultimaker/cura_11622"
- "uranium/5.9.0-alpha.0@ultimaker/cura_11622"
- "curaengine/5.9.0-alpha.0@ultimaker/cura_11622"
- "cura_binary_data/5.9.0-alpha.0@ultimaker/cura_11622"
- "fdm_materials/5.9.0-alpha.0@ultimaker/cura_11622"
- "cura_resources/5.10.0-alpha.0@ultimaker/cura_11622"
- "uranium/5.10.0-alpha.0@ultimaker/cura_11622"
- "curaengine/5.10.0-alpha.0@ultimaker/cura_11622"
- "cura_binary_data/5.10.0-alpha.0@ultimaker/cura_11622"
- "fdm_materials/5.10.0-alpha.0@ultimaker/cura_11622"
- "dulcificum/0.2.0-alpha.0@ultimaker/cura_11622"
- "pysavitar/5.4.0-alpha.0@ultimaker/cura_11622"
- "pynest2d/5.4.0-alpha.0@ultimaker/cura_11622"
requirements_internal:
- "fdm_materials/5.8.1"
- "cura_private_data/5.9.0-alpha.0@internal/cura_11622"
- "cura_private_data/5.10.0-alpha.0@internal/cura_11622"
requirements_enterprise:
- "native_cad_plugin/2.0.0"

urls:
default:
cloud_api_root: "https://api.ultimaker.com"
Expand Down Expand Up @@ -124,6 +122,19 @@ pyinstaller:
Windows: "./icons/Cura.ico"
Macos: "./icons/cura.icns"
Linux: "./icons/cura-128.png"
blacklist:
- [ "assimp" ]
- [ "qt", "charts" ]
- [ "qt", "coap" ]
- [ "qt", "data", "vis" ]
- [ "qt", "lab", "animat" ]
- [ "qt", "mqtt" ]
- [ "qt", "net", "auth" ]
- [ "qt", "quick3d" ]
- [ "qt", "timeline" ]
- [ "qt", "virt", "key" ]
- [ "qt", "wayland", "compos" ]
- [ "qt", "5", "compat" ]

pycharm_targets:
- jinja_path: .run_templates/pycharm_cura_run.run.xml.jinja
Expand Down
102 changes: 101 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,62 @@ def _generate_cura_version(self, location):
python_installs=self._python_installs(),
))

def _delete_unwanted_binaries(self, root):
dynamic_binary_file_exts = [".so", ".dylib", ".dll", ".pyd", ".pyi"]
prohibited = [
"qt5compat",
"qtcharts",
"qtcoap",
"qtdatavis3d",
"qtlottie",
"qtmqtt",
"qtnetworkauth",
"qtquick3d",
"qtquick3dphysics",
"qtquicktimeline",
"qtvirtualkeyboard",
"qtwayland"
]
forbiddens = [x.encode() for x in prohibited]
to_remove_files = []
to_remove_dirs = []
for root, dir_, files in os.walk(root):
for filename in files:
if not any([(x in filename) for x in dynamic_binary_file_exts]):
continue
pathname = os.path.join(root, filename)
still_exist = True
for forbidden in prohibited:
if forbidden.lower() in str(pathname).lower():
to_remove_files.append(pathname)
still_exist = False
break
if not still_exist:
continue
with open(pathname, "rb") as file:
bytez = file.read().lower()
for forbidden in forbiddens:
if bytez.find(forbidden) >= 0:
to_remove_files.append(pathname)
for dirname in dir_:
for forbidden in prohibited:
if forbidden.lower() == str(dirname).lower():
pathname = os.path.join(root, dirname)
to_remove_dirs.append(pathname)
break
for file in to_remove_files:
try:
os.remove(file)
print(f"deleted file: {file}")
except Exception as ex:
print(f"WARNING: Attempt to delete file {file} results in: {str(ex)}")
for dir_ in to_remove_dirs:
try:
rmdir(self, dir_)
print(f"deleted dir_: {dir_}")
except Exception as ex:
print(f"WARNING: Attempt to delete folder {dir_} results in: {str(ex)}")

def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file, cura_source_folder):
pyinstaller_metadata = self.conan_data["pyinstaller"]
datas = []
Expand Down Expand Up @@ -240,13 +296,27 @@ def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, e
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
cura_version = Version(version)

# filter all binary files in binaries on the blacklist
blacklist = pyinstaller_metadata["blacklist"]
filtered_binaries = [b for b in binaries if not any([all([(part in b[0].lower()) for part in parts]) for parts in blacklist])]

# In case the installer isn't actually pyinstaller (Windows at the moment), outright remove the offending files:
specifically_delete = set(binaries) - set(filtered_binaries)
for (unwanted_path, _) in specifically_delete:
try:
os.remove(unwanted_path)
print(f"delete: {unwanted_path}")
except Exception as ex:
print(f"WARNING: Attempt to delete binary {unwanted_path} results in: {str(ex)}")

# Write the actual file:
with open(os.path.join(location, "UltiMaker-Cura.spec"), "w") as f:
f.write(pyinstaller.render(
name = str(self.options.display_name).replace(" ", "-"),
display_name = self._app_name,
entrypoint = entrypoint_location,
datas = datas,
binaries = binaries,
binaries = filtered_binaries,
venv_script_path = str(self._script_dir),
hiddenimports = pyinstaller_metadata["hiddenimports"],
collect_all = pyinstaller_metadata["collect_all"],
Expand Down Expand Up @@ -325,8 +395,10 @@ def generate(self):

for dependency in self.dependencies.host.values():
for bindir in dependency.cpp_info.bindirs:
self._delete_unwanted_binaries(bindir)
copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
for libdir in dependency.cpp_info.libdirs:
self._delete_unwanted_binaries(libdir)
copy(self, "*.pyd", libdir, str(self._site_packages), keep_path = False)
copy(self, "*.pyi", libdir, str(self._site_packages), keep_path = False)
copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
Expand Down Expand Up @@ -383,6 +455,34 @@ def deploy(self):
copy(self, "*", uranium.resdirs[1], str(self._share_dir.joinpath("uranium", "plugins")), keep_path = True)
copy(self, "*", uranium.libdirs[0], str(self._site_packages.joinpath("UM")), keep_path = True)

# Generate the GitHub Action version info Environment
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
cura_version = Version(version)
env_prefix = "Env:" if self.settings.os == "Windows" else ""
activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
""").render(cura_version_major = cura_version.major,
cura_version_minor = cura_version.minor,
cura_version_patch = cura_version.patch,
cura_version_build = cura_version.build if cura_version.build != "" else "0",
cura_version_full = self.version,
cura_app_name = self._app_name,
env_prefix = env_prefix)

ext = ".sh" if self.settings.os != "Windows" else ".ps1"
save(self, os.path.join(self._script_dir, f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)

self._generate_cura_version(os.path.join(self._site_packages, "cura"))

self._delete_unwanted_binaries(self._site_packages)
self._delete_unwanted_binaries(self.package_folder)
self._delete_unwanted_binaries(self._base_dir)
self._delete_unwanted_binaries(self._share_dir)

entitlements_file = "'{}'".format(Path(self.deploy_folder, "packaging", "MacOS", "cura.entitlements"))
self._generate_pyinstaller_spec(location = self.deploy_folder,
entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
Expand Down
2 changes: 1 addition & 1 deletion cura/ApplicationMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Each release has a fixed SDK version coupled with it. It doesn't make sense to make it configurable because, for
# example Cura 3.2 with SDK version 6.1 will not work. So the SDK version is hard-coded here and left out of the
# CuraVersion.py.in template.
CuraSDKVersion = "8.8.0"
CuraSDKVersion = "8.9.0"

try:
from cura.CuraVersion import CuraLatestURL
Expand Down
12 changes: 8 additions & 4 deletions cura/BuildVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,23 @@ def render(self, renderer):
if not self.getMeshData() or not self.isVisible():
return True

theme = self._application.getTheme()
if not self._shader:
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "default.shader"))
self._grid_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "grid.shader"))
theme = self._application.getTheme()
self._grid_shader.setUniformValue("u_plateColor", Color(*theme.getColor("buildplate").getRgb()))
self._grid_shader.setUniformValue("u_gridColor0", Color(*theme.getColor("buildplate_grid").getRgb()))
self._grid_shader.setUniformValue("u_gridColor1", Color(*theme.getColor("buildplate_grid_minor").getRgb()))

plate_color = Color(*theme.getColor("buildplate").getRgb())
if self._global_container_stack.getMetaDataEntry("has_textured_buildplate", False):
plate_color.setA(0.5)
self._grid_shader.setUniformValue("u_plateColor", plate_color)

renderer.queueNode(self, mode = RenderBatch.RenderMode.Lines)
renderer.queueNode(self, mesh = self._origin_mesh, backface_cull = True)
renderer.queueNode(self, mesh = self._grid_mesh, shader = self._grid_shader, backface_cull = True)
renderer.queueNode(self, mesh = self._grid_mesh, shader = self._grid_shader, backface_cull = True, transparent = True, sort = -10)
if self._disallowed_area_mesh:
renderer.queueNode(self, mesh = self._disallowed_area_mesh, shader = self._shader, transparent = True, backface_cull = True, sort = -9)
renderer.queueNode(self, mesh = self._disallowed_area_mesh, shader = self._shader, transparent = True, backface_cull = True, sort = -5)

if self._error_mesh:
renderer.queueNode(self, mesh=self._error_mesh, shader=self._shader, transparent=True,
Expand Down
19 changes: 8 additions & 11 deletions cura/CuraApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class CuraApplication(QtApplication):
# SettingVersion represents the set of settings available in the machine/extruder definitions.
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
# changes of the settings.
SettingVersion = 23
SettingVersion = 24

Created = False

Expand Down Expand Up @@ -1895,23 +1895,20 @@ def _openUrl(self, url: QUrl) -> None:
def on_finish(response):
content_disposition_header_key = QByteArray("content-disposition".encode())

if not response.hasRawHeader(content_disposition_header_key):
Logger.log("w", "Could not find Content-Disposition header in response from {0}".format(
model_url.url()))
# Use the last part of the url as the filename, and assume it is an STL file
filename = model_url.path().split("/")[-1] + ".stl"
else:
filename = model_url.path().split("/")[-1] + ".stl"

if response.hasRawHeader(content_disposition_header_key):
# content_disposition is in the format
# ```
# content_disposition attachment; "filename=[FILENAME]"
# content_disposition attachment; filename="[FILENAME]"
# ```
# Use a regex to extract the filename
content_disposition = str(response.rawHeader(content_disposition_header_key).data(),
encoding='utf-8')
content_disposition_match = re.match(r'attachment; filename="(?P<filename>.*)"',
content_disposition_match = re.match(r'attachment; filename=(?P<filename>.*)',
content_disposition)
assert content_disposition_match is not None
filename = content_disposition_match.group("filename")
if content_disposition_match is not None:
filename = content_disposition_match.group("filename").strip("\"")

tmp = tempfile.NamedTemporaryFile(suffix=filename, delete=False)
with open(tmp.name, "wb") as f:
Expand Down
1 change: 1 addition & 0 deletions cura/Machines/MachineNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, container_id: str) -> None:
self.preferred_variant_name = my_metadata.get("preferred_variant_name", "")
self.preferred_material = my_metadata.get("preferred_material", "")
self.preferred_quality_type = my_metadata.get("preferred_quality_type", "")
self.supports_abstract_color = parseBool(my_metadata.get("supports_abstract_color", "false"))

self._loadAll()

Expand Down
7 changes: 3 additions & 4 deletions cura/Machines/Models/QualityManagementModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ def renameQualityChangesGroup(self, quality_changes_group: "QualityChangesGroup"
# have no container for the global stack, because "my_profile" just got renamed to "my_new_profile". This results
# in crashes because the rest of the system assumes that all data in a QualityChangesGroup will be correct.
#
# Renaming the container for the global stack in the end seems to be ok, because the assumption is mostly based
# on the quality changes container for the global stack.
# This is why we use the "supress_signals" flag for the set name. This basically makes the change silent.
for metadata in quality_changes_group.metadata_per_extruder.values():
extruder_container = cast(InstanceContainer, container_registry.findContainers(id = metadata["id"])[0])
extruder_container.setName(new_name)
extruder_container.setName(new_name, supress_signals=True)
global_container = cast(InstanceContainer, container_registry.findContainers(id = quality_changes_group.metadata_for_global["id"])[0])
global_container.setName(new_name)
global_container.setName(new_name, supress_signals=True)

quality_changes_group.name = new_name

Expand Down
4 changes: 4 additions & 0 deletions cura/Machines/VariantNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def _loadAll(self) -> None:
filtered_materials = [material for material in materials if not self.machine.isExcludedMaterialBaseFile(material["id"])]

for material in filtered_materials:
if material.get("abstract_color", False) and not self.machine.supports_abstract_color:
continue # do not show abstract color profiles if the machine does not support them
base_file = material["base_file"]
if base_file not in self.materials:
self.materials[base_file] = MaterialNode(material["id"], variant = self)
Expand Down Expand Up @@ -126,6 +128,8 @@ def _materialAdded(self, container: ContainerInterface) -> None:
return # We won't add any materials.
material_definition = container.getMetaDataEntry("definition")

if (not self.machine.supports_abstract_color) and container.getMetaDataEntry("abstract_color", False):
return
base_file = container.getMetaDataEntry("base_file")
if self.machine.isExcludedMaterialBaseFile(base_file):
return # Material is forbidden for this printer.
Expand Down
12 changes: 4 additions & 8 deletions cura/PrinterOutput/FormatMaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,19 @@ class FormatMaps:

# A map from the material-name in their native file-formats to some info, including the internal name we use.
MATERIAL_MAP = {
"abs": {"name": "ABS", "guid": "2780b345-577b-4a24-a2c5-12e6aad3e690"},
"abs": {"name": "ABS", "guid": "e0f1d581-cc6b-4e36-8f3c-3f5601ecba5f"},
"abs-cf10": {"name": "ABS-CF", "guid": "495a0ce5-9daf-4a16-b7b2-06856d82394d"},
"abs-wss1": {"name": "ABS-R", "guid": "88c8919c-6a09-471a-b7b6-e801263d862d"},
"asa": {"name": "ASA", "guid": "f79bc612-21eb-482e-ad6c-87d75bdde066"},
"nylon12-cf": {"name": "Nylon 12 CF", "guid": "3c6f2877-71cc-4760-84e6-4b89ab243e3b"},
"nylon": {"name": "Nylon", "guid": "283d439a-3490-4481-920c-c51d8cdecf9c"},
"pc": {"name": "PC", "guid": "62414577-94d1-490d-b1e4-7ef3ec40db02"},
"petg": {"name": "PETG", "guid": "69386c85-5b6c-421a-bec5-aeb1fb33f060"},
"nylon-cf": {"name": "Nylon CF", "guid": "17abb865-ca73-4ccd-aeda-38e294c9c60b"},
"pet": {"name": "PETG", "guid": "2d004bbd-d1bb-47f8-beac-b066702d5273"},
"pla": {"name": "PLA", "guid": "abb9c58e-1f56-48d1-bd8f-055fde3a5b56"},
"pva": {"name": "PVA", "guid": "add51ef2-86eb-4c39-afd5-5586564f0715"},
"wss1": {"name": "RapidRinse", "guid": "a140ef8f-4f26-4e73-abe0-cfc29d6d1024"},
"sr30": {"name": "SR-30", "guid": "77873465-83a9-4283-bc44-4e542b8eb3eb"},
"bvoh": {"name": "BVOH", "guid": "923e604c-8432-4b09-96aa-9bbbd42207f4"},
"cpe": {"name": "CPE", "guid": "da1872c1-b991-4795-80ad-bdac0f131726"},
"hips": {"name": "HIPS", "guid": "a468d86a-220c-47eb-99a5-bbb47e514eb0"},
"tpu": {"name": "TPU 95A", "guid": "19baa6a9-94ff-478b-b4a1-8157b74358d2"},
"im-pla": {"name": "Tough", "guid": "de031137-a8ca-4a72-bd1b-17bb964033ad"}
# /!\ When changing this list, make sure the changes are reported accordingly on Digital Factory
}

__inverse_printer_name: Optional[Dict[str, str]] = None
Expand Down
11 changes: 6 additions & 5 deletions cura/Settings/ExtruderStack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2024 UltiMaker
# Cura is released under the terms of the LGPLv3 or higher.

from typing import Any, Dict, TYPE_CHECKING, Optional
Expand All @@ -12,11 +12,8 @@
from UM.Settings.Interfaces import ContainerInterface, PropertyEvaluationContext
from UM.Util import parseBool

import cura.CuraApplication

from . import Exceptions
from .CuraContainerStack import CuraContainerStack, _ContainerIndexes
from .ExtruderManager import ExtruderManager

if TYPE_CHECKING:
from cura.Settings.GlobalStack import GlobalStack
Expand Down Expand Up @@ -141,7 +138,11 @@ def getProperty(self, key: str, property_name: str, context: Optional[PropertyEv
context.popContainer()
return result

limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
if not context:
context = PropertyEvaluationContext(self)
if "extruder_position" not in context.context:
context.context["extruder_position"] = super().getProperty(key, "limit_to_extruder", context)
limit_to_extruder = context.context["extruder_position"]
if limit_to_extruder is not None:
limit_to_extruder = str(limit_to_extruder)

Expand Down
Loading

0 comments on commit 8e25302

Please sign in to comment.