From b10ba451945facc28120557f9c845c98c80c1368 Mon Sep 17 00:00:00 2001 From: Cyril Waechter Date: Sat, 16 Jan 2021 00:42:45 +0100 Subject: [PATCH] Allow to install ifcpatch separately (#1263) Will allow to provide ifcpatch as a standard python package for various usages (eg. standalone, blenderbim addon, FreeCAD) * Copy folder instead of files [using svn](https://stackoverflow.com/a/18194523/4098083) * Fetch recipes from ifcpatch module path --- src/ifcblenderexport/Makefile | 16 +--------------- src/ifcblenderexport/blenderbim/bim/prop.py | 6 ++++-- src/ifcpatch/{ifcpatch.py => __init__.py} | 0 3 files changed, 5 insertions(+), 17 deletions(-) rename src/ifcpatch/{ifcpatch.py => __init__.py} (100%) diff --git a/src/ifcblenderexport/Makefile b/src/ifcblenderexport/Makefile index 842a8c08eb..431bf7960e 100644 --- a/src/ifcblenderexport/Makefile +++ b/src/ifcblenderexport/Makefile @@ -266,21 +266,7 @@ endif rm -rf dist/working # Provides IFCPatch functionality - cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/ifcpatch.py - cd dist/blenderbim/libs/site/packages/ && mkdir recipes - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/__init__.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/ExtractElements.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/MergeProject.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/Migrate.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/OffsetObjectPlacements.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/OffsetStoreyElevations.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/Optimise.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/RecycleNonRootedElements.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/RemoveSiteRepresentation.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/ResetSpatialElementLocations.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/SetRefElevation.py - cd dist/blenderbim/libs/site/packages/recipes && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcpatch/recipes/SplitByBuildingStorey.py + cd dist/blenderbim/libs/site/packages/ && svn export https://github.com/IfcOpenShell/IfcOpenShell/trunk/src/ifcpatch cd dist/blenderbim && sed -i "s/999999/$(VERSION)/" __init__.py cd dist && zip -r blender28-bim-$(VERSION)-$(PLATFORM).zip ./* diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index f5b0663f22..f6c2c4c242 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1,7 +1,8 @@ import json import os -import ifcopenshell from pathlib import Path +import importlib +import ifcopenshell from . import export_ifc from . import schema from . import ifc @@ -319,7 +320,8 @@ def getIfcPatchRecipes(self, context): global ifcpatchrecipes_enum if len(ifcpatchrecipes_enum) < 1: ifcpatchrecipes_enum.clear() - for filename in Path(os.path.join(cwd, "..", "libs", "site", "packages", "recipes")).glob("*.py"): + ifcpatch_path = Path(importlib.util.find_spec("ifcpatch").submodule_search_locations[0]) + for filename in ifcpatch_path.joinpath("recipes").glob("*.py"): f = str(filename.stem) if f == "__init__": continue diff --git a/src/ifcpatch/ifcpatch.py b/src/ifcpatch/__init__.py similarity index 100% rename from src/ifcpatch/ifcpatch.py rename to src/ifcpatch/__init__.py