Skip to content

Commit 7403d14

Browse files
committed
Fix IfcPatch pyinstaller script to make it easier to distribute ifcpatch.
1 parent 2b63698 commit 7403d14

File tree

7 files changed

+32
-45
lines changed

7 files changed

+32
-45
lines changed

src/ifcclash/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ defined with data sources.
5555
],
5656
"b": [
5757
{
58-
"file": "/path/to/two.ifc"
58+
"file": "/path/to/two.ifc",
5959
"selector": ".IfcWall",
6060
"mode": "i"
6161
}
6262
]
63-
},
64-
...
63+
}
6564
]
6665
```
6766

src/ifcpatch/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ If you want something more Unix-like ...
2121
$ alias ifcpatch='python -m ifcpatch'
2222
```
2323

24+
Alternatively, you can package it as a distributable.
25+
26+
```
27+
$ python make.py
28+
$ ./dist/ifcpatch
29+
```
30+
2431
## Usage
2532

2633
Usage is like any other CLI app.

src/ifcpatch/bootstrap.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import toposort
2+
import ifcpatch
3+
import ifcpatch.recipes
4+
import ifcopenshell.util.selector
5+
import ifcopenshell.util.element
6+
import ifcopenshell.util.schema
7+
8+
import ifcpatch.__main__

src/ifcpatch/ifcpatch/__init__.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import ifcopenshell
55
import logging
6-
import argparse
76

87

98
def execute(args, is_library=None):
@@ -28,21 +27,4 @@ def execute(args, is_library=None):
2827
text_file.write(ifc_file)
2928
else:
3029
ifc_file.write(args["output"])
31-
32-
33-
def main():
34-
parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data")
35-
parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch")
36-
parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC")
37-
parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching")
38-
parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log")
39-
parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe")
40-
args = vars(parser.parse_args())
41-
42-
execute(args)
43-
4430
print("# All tasks are complete :-)")
45-
46-
47-
if __name__ == "__main__":
48-
main()

src/ifcpatch/ifcpatch/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/usr/bin/env python3
2+
import argparse
23
import ifcpatch
34

4-
ifcpatch.main()
5+
parser = argparse.ArgumentParser(description="Patches IFC files to fix badly formatted data")
6+
parser.add_argument("-i", "--input", type=str, required=True, help="The IFC file to patch")
7+
parser.add_argument("-o", "--output", type=str, help="The output file to save the patched IFC")
8+
parser.add_argument("-r", "--recipe", type=str, required=True, help="Name of the recipe to use when patching")
9+
parser.add_argument("-l", "--log", type=str, help="Specify a log file", default="ifcpatch.log")
10+
parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom arguments to the patch recipe")
11+
args = vars(parser.parse_args())
12+
ifcpatch.execute(args)

src/ifcpatch/ifcpatch/make.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/ifcpatch/make.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import subprocess
4+
5+
cmd = f'pyinstaller ./bootstrap.py --name ifcpatch --onefile --clean --add-data "ifcpatch{os.pathsep}ifcpatch"'
6+
subprocess.check_output(cmd, shell=True)

0 commit comments

Comments
 (0)