Skip to content

Commit ace464b

Browse files
committed
ci: Add GitHub Actions workflow for build and release
1 parent d65d58e commit ace464b

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

build_analytics.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,26 @@
2121
if sys.platform == "win32":
2222
BUILDS["dml"] = "requirements_dml.txt"
2323

24-
def run_command(command, shell=True, cwd=None):
25-
print(f"--- Running command: {' '.join(command) if isinstance(command, list) else command}")
26-
use_shell = isinstance(command, str) if sys.platform != "win32" else shell
27-
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=use_shell, cwd=cwd, text=True, encoding='utf-8')
24+
# VVVVVV --- ИЗМЕНЕНИЕ 1: Упрощенная и более надежная функция --- VVVVVV
25+
def run_command(command, cwd=None):
26+
"""Runs a command, ensuring shell is used for strings."""
27+
is_string = isinstance(command, str)
28+
print(f"--- Running command: {command}")
29+
process = subprocess.Popen(
30+
command,
31+
stdout=subprocess.PIPE,
32+
stderr=subprocess.STDOUT,
33+
shell=is_string, # Use shell only for string commands
34+
cwd=cwd,
35+
text=True,
36+
encoding='utf-8'
37+
)
2838
for line in process.stdout:
2939
print(line, end='')
3040
process.wait()
3141
if process.returncode != 0:
3242
raise subprocess.CalledProcessError(process.returncode, command)
43+
# ^^^^^^ --- КОНЕЦ ИЗМЕНЕНИЯ 1 --- ^^^^^^
3344

3445
def get_onnx_libs_path(venv_path):
3546
if sys.platform == "win32":
@@ -45,24 +56,24 @@ def create_and_build(name, req_file):
4556

4657
if sys.platform == "win32":
4758
python_executable = venv_path / "Scripts" / "python.exe"
59+
pip_executable = venv_path / "Scripts" / "pip.exe"
4860
else:
4961
python_executable = venv_path / "bin" / "python"
62+
pip_executable = venv_path / "bin" / "pip"
5063

5164
if not venv_path.exists():
5265
print(f"Creating virtual environment for {name}...")
5366
venv.create(venv_path, with_pip=True)
5467

5568
print(f"Installing dependencies for {name} from {req_file}...")
5669

57-
# VVVVVV --- ИСПРАВЛЕНИЕ ЗДЕСЬ --- VVVVVV
58-
# Убираем кавычки вокруг путей. В Linux-окружении без пробелов они не нужны и могут мешать.
59-
cmd_as_string = f"{str(python_executable)} -m pip install -r {str(req_file)}"
70+
# VVVVVV --- ИЗМЕНЕНИЕ 2: Вызываем pip напрямую и как строку --- VVVVVV
71+
cmd_as_string = f"{str(pip_executable)} install -r {str(req_file)}"
6072
run_command(cmd_as_string)
61-
# ^^^^^^ --- КОНЕЦ ИСПРАВЛЕНИЯ --- ^^^^^^
73+
# ^^^^^^ --- КОНЕЦ ИЗМЕНЕНИЯ 2 --- ^^^^^^
6274

6375
print(f"Running PyInstaller for {name}...")
6476

65-
# PyInstaller лучше вызывать списком, это более надежно
6677
pyinstaller_command = [
6778
str(python_executable), "-m", "PyInstaller",
6879
"--noconfirm", "--onefile",
@@ -83,6 +94,7 @@ def create_and_build(name, req_file):
8394

8495
pyinstaller_command.append(str(SRC_FILE))
8596

97+
# Вызываем PyInstaller списком, как и раньше, т.к. это надежнее для сложных команд
8698
run_command(pyinstaller_command)
8799
print(f"--- Successfully built {name} version! ---")
88100

0 commit comments

Comments
 (0)