mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix IfcPatch pyinstaller script to make it easier to distribute ifcpatch.
This commit is contained in:
@@ -55,13 +55,12 @@ defined with data sources.
|
||||
],
|
||||
"b": [
|
||||
{
|
||||
"file": "/path/to/two.ifc"
|
||||
"file": "/path/to/two.ifc",
|
||||
"selector": ".IfcWall",
|
||||
"mode": "i"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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__
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user