Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Retry creating an environment while another program holds its Python file

Bowen Xue28b678fa3475
diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.py
index c238093..368106c 100644
--- a/freevideo_engine/bootstrap.py
+++ b/freevideo_engine/bootstrap.py
@@ -372,6 +372,8 @@ def inventory(gpu=None):
# Windows reuses a detected Git from 2.35, the oldest tested there, and
# otherwise installs its own MinGit.
WINDOWS_MIN_GIT = (2, 35)
+# Seconds to wait before creating an environment again after another program held a file.
+ENVIRONMENT_BUSY_WAITS = (3, 10, 30)
def git_floor(system=None):
@@ -1599,23 +1601,31 @@ class Installer:
def environment(folder=venv, executable=python, label=name):
if executable.exists() and environment_seeded(folder):
return None
- command = [uv, 'venv', '--seed', '--python', self.versions['python']]
- # The Python file came back (restored from quarantine) without
- # the seed packages: keep it and add them. Without the file, the
- # folder is a leftover that uv replaces.
- if executable.exists():
- command.append('--allow-existing')
- elif folder.exists():
- command.append('--clear')
- try:
- return self.packages(label + '-venv', [*command, folder])
- except RuntimeError as error:
- from .failure_details import environment_python_removed
- # uv failed while the new interpreter was disappearing.
- removed = '' if executable.exists() else environment_python_removed([executable], [executable])
- if not removed:
- raise
- raise RuntimeError(removed + str(error)) from error
+ from .failure_details import environment_python_removed, file_in_use
+ for wait in (*ENVIRONMENT_BUSY_WAITS, None):
+ command = [uv, 'venv', '--seed', '--python', self.versions['python']]
+ # The Python file came back (restored from quarantine) without
+ # the seed packages: keep it and add them. Without the file, the
+ # folder is a leftover that uv replaces.
+ if executable.exists():
+ command.append('--allow-existing')
+ elif folder.exists():
+ command.append('--clear')
+ try:
+ return self.packages(label + '-venv', [*command, folder])
+ except RuntimeError as error:
+ # Another program (usually security software scanning the
+ # Python file just unpacked) held it open while uv copied it.
+ if wait is not None and file_in_use(error) and not self.cancel.is_set():
+ self.ui.write('A file is in use by another program; trying again in %d s.\n' % wait)
+ if not self.cancel.wait(wait):
+ continue
+ raise
+ # uv failed while the new interpreter was disappearing.
+ removed = '' if executable.exists() else environment_python_removed([executable], [executable])
+ if not removed:
+ raise
+ raise RuntimeError(removed + str(error)) from error
task(name + '-venv', environment, ('python',), writer)
command = [uv, 'pip', 'install', '--python', python, *spec['torch'], '-c', constraints_file(name, self.system)]
family = 'torch-' + spec['cuda'] + '-' + spec['torch'][0].split('==')[1]
diff --git a/freevideo_engine/failure_details.py b/freevideo_engine/failure_details.py
index af9d23c..345f322 100644
--- a/freevideo_engine/failure_details.py
+++ b/freevideo_engine/failure_details.py
@@ -219,6 +219,15 @@ def environment_python_removed(args, pythons):
return ''
+# Windows sharing violation: another program (often security software scanning
+# a file that was just written) holds a file open. It is usually released within seconds.
+FILE_IN_USE = r'os error 32\b|WinError 32\b|being used by another process|另一个程序正在使用'
+
+
+def file_in_use(text):
+ return re.search(FILE_IN_USE, str(text)) is not None
+
+
# Checked before free space: freeing space cannot fix a disk that cannot hold the installation.
PLACE_RULES = (
(r'Git is unavailable\. Check the network connection', 'git-unavailable',
@@ -738,6 +747,11 @@ def _launcher_failure(value, *, zh=False, other_disk=False, disk_name='', can_re
_joined(CHANGED_WHY['files'], CHANGED_REPAIR)),
(r'The installation plan changed\. Detect configuration again', 'plan-changed', CHANGED_TITLE,
_joined(CHANGED_WHY['other'], CHANGED_REPAIR)),
+ (FILE_IN_USE, 'file-in-use',
+ ('A file is in use by another program', '文件被其他程序占用'),
+ ('Security software or another program is holding a file that setup needs. Wait a moment and click Retry installation; '
+ 'if it happens again, allow the FreeVideo folder in the security software.',
+ '安全软件或其他程序正在占用安装所需的文件。请稍候后点“重试安装”;仍然失败时,请在安全软件中允许 FreeVideo 所在的文件夹。')),
(ENVIRONMENT_PYTHON_REMOVED, 'environment-python-removed',
('A program file is missing', '缺少一个程序文件'),
('It may have been quarantined by security software. Restore the file or allow the FreeVideo folder, '