-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmake.py
More file actions
110 lines (83 loc) · 3.14 KB
/
Copy pathmake.py
File metadata and controls
110 lines (83 loc) · 3.14 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
# This file is part of the Kitfox Normal Brush distribution (https://github.com/blackears/blenderEasyFly).
# Copyright (c) 2021 Mark McKay
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import platform
import os
import sys
import subprocess
import urllib.request
import zipfile
import tarfile
platform_sys = platform.system()
wheels_dir = "build/source/wheels"
build_dir = "build/source"
BLENDER_ARCHIVE = "blender-5.1.2-linux-x64.tar.gz"
if platform_sys == 'Windows':
pass
elif platform_sys == 'Linux':
if not os.path.exists("build"):
os.makedirs("build")
os.chdir("build")
if not os.path.exists(wheels_dir):
os.makedirs(wheels_dir)
#Download wheels
command = [
sys.executable, "-m", "pip", "download",
#"--only-binary=:all:", # Force downloading wheels only (.whl)
"--dest", wheels_dir, # Specify target directory
"allosaurus"
]
try:
result = subprocess.run(command, check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while downloading: {e.stderr}")
#Build manifest
os.chdir("source")
manifest_text = ""
with open("../blender_manifest_template_linux.toml", "r") as file:
for line in file:
if line.startswith("numpy"):
continue
manifest_text += line
with open("blender_manifest.toml", "w", encoding="utf-8") as file:
file.write(manifest_text)
#Download blender
if not os.path.exists("blender"):
os.makedirs("blender")
urllib.request.urlretrieve("https://download.blender.org/release/Blender5.1/${BLENDER_ARCHIVE}", "blender/blender.tar.gz")
#Unzip Blender
# with zipfile.ZipFile("blender.tar.gz", 'r') as zip_ref:
# zip_ref.extractall("blender_dir")
with tarfile.open("blender.tar.gz", "r:gz") as tar:
# Extract all contents into the current directory
tar.extractall(path="blender_dir")
if not os.path.exists("extension"):
os.makedirs("extension")
#Build extension
command = [
"blender_dir/blender",
"--command", "extension",
"build",
"--source-dir", "source",
"--output-filepath", "extension/parrotLipsync.zip",
]
try:
result = subprocess.run(command, check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while downloading: {e.stderr}")
pass
elif platform_sys == 'Darwin':
#Macintosh
pass