-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathpackage.py
59 lines (53 loc) · 2.03 KB
/
package.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import zipfile
import os
import shutil
packages = [
{
"name": "blender-photogrammetry-1.1-linux",
"platform": "linux",
"features": ["blender", "bundler", "colmap", "imagemodeler", "meshroom", "openmvs", "pmvs", "visualsfm"],
},
{
"name": "blender-photogrammetry-1.1-windows",
"platform": "windows",
"features": ["blender", "bundler", "colmap", "imagemodeler", "meshroom", "openmvs", "pmvs", "visualsfm"],
},
# {
# "name": "blender-photogrammetry-1.1-mac",
# "platform": "darwin",
# "features": ["blender", "bundler", "imagemodeler", "pmvs"],
# }
]
for package in packages:
print(f"Creating {package['name']}...")
cwd = os.path.dirname(__file__)
basepath = os.path.join(cwd, 'release', package['name'], 'blender_photogrammetry')
try:
if os.path.exists(basepath):
shutil.rmtree(basepath)
except Exception as ex:
print(ex)
os.makedirs(basepath, exist_ok=True)
# copy core addon module files
shutil.copy(os.path.join(cwd, '__init__.py'), basepath)
shutil.copy(os.path.join(cwd, 'utils.py'), basepath)
shutil.copy(os.path.join(cwd, 'kmeans.py'), basepath)
# copy each feature module
for feature in package['features']:
os.makedirs(os.path.join(basepath, feature))
for filename in os.listdir(feature):
filepath = os.path.join(feature, filename)
if os.path.isfile(filepath):
shutil.copy(filepath, os.path.join(basepath, feature))
try:
binpath = os.path.join(feature, package['platform'])
if os.path.exists(binpath):
shutil.copytree(binpath, os.path.join(basepath, feature, 'bin'))
except Exception as ex:
print(ex)
shutil.make_archive(os.path.join(cwd, 'release', package['name']), 'zip', os.path.join(cwd, 'release', package['name']))
try:
# clean up folder used for making archive
shutil.rmtree(os.path.dirname(basepath))
except:
pass