Bump binary versions in makefiles; add backwards compatibility to logger usage in python #8167

This commit is contained in:
Thomas Krijnen
2026-06-15 09:56:36 +02:00
parent 22707fa534
commit 6a6756de66
10 changed files with 70 additions and 39 deletions
+2 -2
View File
@@ -54,8 +54,8 @@ ifeq ($(PLATFORM), win64)
PLATFORMTAG:=win_amd64
endif
BINARY_VERSION:=0.8.5
BUILD_COMMIT:=1c5b825
BINARY_VERSION:=0.8.6
BUILD_COMMIT:=3e7b739
IOS_URL:=https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v$(BINARY_VERSION)-$(BUILD_COMMIT)-$(PLATFORM).zip
IFCCONVERT_URL:=https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v$(BINARY_VERSION)-$(BUILD_COMMIT)-$(PLATFORM).zip
@@ -95,7 +95,9 @@ from .entity_instance import entity_instance, register_schema_attributes
from .file import file, rocksdb_lazy_instance
from .file import file as _file
from .sql import sqlite, sqlite_entity
from .ifcopenshell_wrapper import get_log, logger
get_log = ifcopenshell_wrapper.get_log
logger = getattr(ifcopenshell_wrapper, "logger", None)
# explicitly specify available imported symbols
# (it's a requirement for a typed library)
@@ -192,10 +194,10 @@ def open(
raise FileNotFoundError(f"Path does not exist: '{path}'.")
if format is None:
format = guess_format(path)
if logger is None:
logger = ifcopenshell_wrapper.logger.Root()
if logger is None and (logger_type := getattr(ifcopenshell_wrapper, "logger", None)):
logger = logger_type.Root()
if format == ".ifcXML":
f = ifcopenshell_wrapper.parse_ifcxml(str(path.absolute()), logger)
f = ifcopenshell_wrapper.parse_ifcxml(str(path.absolute()), *((logger,) if logger is not None else ()))
if f:
return file(f)
raise OSError(f"Failed to parse .ifcXML file from {path}")
@@ -212,9 +214,11 @@ def open(
if should_stream:
return stream(path)
if readonly: # Temporary conditional see #7131. Remove once newer builds don't segfault on Linux.
f = ifcopenshell_wrapper.open(str(path.absolute()), readonly, logger)
f = ifcopenshell_wrapper.open(str(path.absolute()), readonly, *((logger,) if logger is not None else ()))
elif bypass_types:
f = ifcopenshell_wrapper.file(ifcopenshell_wrapper.uninitialized_tag(), logger)
f = ifcopenshell_wrapper.file(
ifcopenshell_wrapper.uninitialized_tag(), *((logger,) if logger is not None else ())
)
for ty in bypass_types:
f.bypass_type(ty)
if mmap:
@@ -224,9 +228,12 @@ def open(
f.initialize(str(path.absolute()))
elif mmap:
# mmap parameter is only available for builds with USE_MMAP, not used in our main builds
f = ifcopenshell_wrapper.open(str(path.absolute()), mmap=mmap, logger=logger) # ty: ignore[unknown-argument]
kwargs = {"mmap": mmap}
if logger is not None:
kwargs["logger"] = logger
f = ifcopenshell_wrapper.open(str(path.absolute()), **kwargs) # ty: ignore[unknown-argument]
else:
f = ifcopenshell_wrapper.open(str(path.absolute()), False, logger)
f = ifcopenshell_wrapper.open(str(path.absolute()), False, *((logger,) if logger is not None else ()))
return file(f)
+2 -2
View File
@@ -107,7 +107,7 @@ def main(
progress_function: Callable = DO_NOTHING,
logger=None,
):
if logger is None:
if logger is None and ifcopenshell.logger is not None:
logger = ifcopenshell.logger.Root()
def by_guid(g):
@@ -543,7 +543,7 @@ def main(
arranged = W.arrange_polygons(
*filter(None, (ARRANGE_POLYGON_SETTINGS,)),
polies, # ty: ignore[too-many-positional-arguments]
logger,
*((logger,) if logger is not None else ()),
)
svg_data_3 = W.polygons_to_svg(arranged, False)
dom3 = parseString(svg_data_3)
@@ -217,7 +217,8 @@ for id in to_emit:
statements.append("%s << %s" % (id, stmt))
if __name__ == "__main__":
print(r"""
print(
r"""
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
from __future__ import annotations
@@ -256,4 +257,6 @@ if __name__ == "__main__":
mdl = importlib.import_module(output)
mdl.Generator(m).emit()
sys.stdout.write(m.schema.name)
""" % ("\n ".join(statements)))
"""
% ("\n ".join(statements))
)
@@ -363,18 +363,24 @@ class EarlyBoundCodeWriter:
)
)
self.statements[self.statements.index("{factory_placeholder}")] = """
self.statements[self.statements.index("{factory_placeholder}")] = (
"""
class %(schema_name)s_instance_factory : public IfcParse::instance_factory {
virtual IfcUtil::IfcBaseClass* operator()(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) const {
%(instance_mapping)s
}
};
""" % locals()
"""
% locals()
)
""
self.statements[self.statements.index("{string_pool_placeholder}")] = """
self.statements[self.statements.index("{string_pool_placeholder}")] = (
"""
const std::string strings[] = {%s};
""" % ",".join(map(lambda s: '"%s"s' % s, self.strings))
"""
% ",".join(map(lambda s: '"%s"s' % s, self.strings))
)
def __str__(self):
return "\n".join(self.statements)
@@ -145,7 +145,8 @@ class configuration:
config.set(
"snippets",
"print all wall ids",
self.config_encode("""
self.config_encode(
"""
###########################################################################
# A simple script that iterates over all walls in the current model #
# and prints their Globally unique IDs (GUIDS) to the console window #
@@ -153,13 +154,15 @@ class configuration:
for wall in model.by_type("IfcWall"):
print ("wall with global id: "+str(wall.GlobalId))
""".lstrip()),
""".lstrip()
),
)
config.set(
"snippets",
"print properties of current selection",
self.config_encode("""
self.config_encode(
"""
###########################################################################
# A simple script that iterates over all IfcPropertySets of the currently #
# selected object and prints them to the console #
@@ -177,7 +180,8 @@ if selection:
for prop in relDefinesByProperties.RelatingPropertyDefinition.HasProperties:
print ("{:<20} :{}".format(prop.Name,prop.NominalValue.wrappedValue))
print ("\\n")
""".lstrip()),
""".lstrip()
),
)
with open(conf_file, "w") as configfile:
config.write(configfile)
@@ -302,8 +302,8 @@ class iterator(ifcopenshell_wrapper.Iterator):
logger=None,
):
self.settings = settings
if logger is None:
logger = ifcopenshell_wrapper.logger.Root()
if logger is None and (logger_type := getattr(ifcopenshell_wrapper, "logger", None)):
logger = logger_type.Root()
if isinstance(file_or_filename, file):
self.file = file
file_or_filename = file_or_filename.wrapped_data
@@ -336,19 +336,18 @@ class iterator(ifcopenshell_wrapper.Iterator):
else:
initializer = ifcopenshell_wrapper.construct_iterator_with_include_exclude
self.this = initializer(
args = (
geometry_library,
self.settings,
file_or_filename,
include_or_exclude,
include is not None,
num_threads,
logger,
)
self.this = initializer(*args, *((logger,) if logger is not None else ()))
else:
self.this = ifcopenshell_wrapper.construct_iterator(
geometry_library, self.settings, file_or_filename, num_threads, logger
)
args = (geometry_library, self.settings, file_or_filename, num_threads)
self.this = ifcopenshell_wrapper.construct_iterator(*args, *((logger,) if logger is not None else ()))
if has_occ:
@@ -517,7 +516,11 @@ def create_shape(
return wrap_shape_creation(
settings,
ifcopenshell_wrapper.create_shape(
settings, inst.wrapped_data, repr.wrapped_data if repr is not None else None, geometry_library, *(filter(None, (logger,)))
settings,
inst.wrapped_data,
repr.wrapped_data if repr is not None else None,
geometry_library,
*((logger,) if logger is not None else ()),
),
)
@@ -355,7 +355,8 @@ def get_cost_rate(
class CostValueUnserialiser:
def parse(self, formula: str):
l = lark.Lark("""start: formula
l = lark.Lark(
"""start: formula
formula: operand (operator operand)*
operand: value | category "(" formula ")"
value: NUMBER?
@@ -392,7 +393,8 @@ class CostValueUnserialiser:
NEWLINE: (CR? LF)+
%ignore WS // Disregard spaces in text
""")
"""
)
start = l.parse(formula)
return self.get_formula(start.children[0])
@@ -39,7 +39,8 @@ import ifcopenshell.util.shape
import ifcopenshell.util.system
import ifcopenshell.util.unit
filter_elements_grammar = lark.Lark("""start: filter_group
filter_elements_grammar = lark.Lark(
"""start: filter_group
filter_group: facet_list ("+" facet_list)*
facet_list: facet ("," facet)*
@@ -110,9 +111,11 @@ filter_elements_grammar = lark.Lark("""start: filter_group
NEWLINE: (CR? LF)+
%ignore WS // Disregard spaces in text
""")
"""
)
get_element_grammar = lark.Lark("""start: keys
get_element_grammar = lark.Lark(
"""start: keys
keys: key ("." key)*
key: quoted_string | regex_string | unquoted_string
@@ -127,9 +130,11 @@ get_element_grammar = lark.Lark("""start: keys
WS: /[ \\t\\f\\r\\n]/+
%ignore WS // Disregard spaces in text
""")
"""
)
format_grammar = lark.Lark("""start: expression
format_grammar = lark.Lark(
"""start: expression
?expression: add_sub
?add_sub: mul_div
@@ -188,7 +193,8 @@ format_grammar = lark.Lark("""start: expression
NEWLINE: (CR? LF)+
%ignore WS // Disregard spaces in text
""")
"""
)
class FormatTransformer(lark.Transformer):