Fix IfcPatch pyinstaller script to make it easier to distribute ifcpatch.

This commit is contained in:
Dion Moult
2021-08-03 22:30:51 +10:00
parent 2b63698d7c
commit 7403d14001
7 changed files with 32 additions and 45 deletions
+2 -3
View File
@@ -55,13 +55,12 @@ defined with data sources.
],
"b": [
{
"file": "/path/to/two.ifc"
"file": "/path/to/two.ifc",
"selector": ".IfcWall",
"mode": "i"
}
]
},
...
}
]
```
+7
View File
@@ -21,6 +21,13 @@ If you want something more Unix-like ...
$ alias ifcpatch='python -m ifcpatch'
```
Alternatively, you can package it as a distributable.
```
$ python make.py
$ ./dist/ifcpatch
```
## Usage
Usage is like any other CLI app.
+8
View File
@@ -0,0 +1,8 @@
import toposort
import ifcpatch
import ifcpatch.recipes
import ifcopenshell.util.selector
import ifcopenshell.util.element
import ifcopenshell.util.schema
import ifcpatch.__main__
-18
View File
@@ -3,7 +3,6 @@
import ifcopenshell
import logging
import argparse
def execute(args, is_library=None):
@@ -28,21 +27,4 @@ def execute(args, is_library=None):
text_file.write(ifc_file)
else:
ifc_file.write(args["output"])
def main():
parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data")
parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch")
parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC")
parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching")
parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log")
parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe")
args = vars(parser.parse_args())
execute(args)
print("# All tasks are complete :-)")
if __name__ == "__main__":
main()
+9 -1
View File
@@ -1,4 +1,12 @@
#!/usr/bin/env python3
import argparse
import ifcpatch
ifcpatch.main()
parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data")
parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch")
parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC")
parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching")
parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log")
parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe")
args = vars(parser.parse_args())
ifcpatch.execute(args)
-23
View File
@@ -1,23 +0,0 @@
#!/usr/bin/env python3
import os
import subprocess
# add hidden imports in recipes here
HIDDEN_IMPORTS = [
"ifcopenshell.util.selector",
"ifcopenshell.util.element",
"ifcopenshell.util.schema",
"toposort",
]
def main():
hiddenimport_args = " ".join('--hiddenimport "{}"'.format(imp) for imp in HIDDEN_IMPORTS)
cmd = 'pyinstaller ./__init__.py --onefile --clean --add-data ".{}ifcpatch" {}'.format(
os.pathsep, hiddenimport_args
)
subprocess.check_output(cmd, shell=True)
if __name__ == "__main__":
main()
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
import os
import subprocess
cmd = f'pyinstaller ./bootstrap.py --name ifcpatch --onefile --clean --add-data "ifcpatch{os.pathsep}ifcpatch"'
subprocess.check_output(cmd, shell=True)