Skip to content

Commit

Permalink
initial setup script for windows users
Browse files Browse the repository at this point in the history
  • Loading branch information
zfleeman committed Jan 26, 2024
1 parent 2af6051 commit db91068
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions windows_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from urllib.request import urlretrieve
import zipfile
import subprocess
import os

curdir = os.getcwd()

print("Downloading ffmpeg to ffmpeg.zip...")
urlretrieve("https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip", "ffmpeg.zip")
print("Done!")

print("Unzipping ffmpeg.zip...")
with zipfile.ZipFile("ffmpeg.zip", 'r') as zip_ref:
zip_ref.extractall()
folder = f"{curdir}\\{zip_ref.namelist()[0][:-1]}\\bin"
print("Done!")

def add_to_system_path(directory) -> None:
# Get the current system-wide PATH
current_path = os.environ.get('PATH', '')

if "ffmpeg" in current_path:
print("ffmpeg is already present in your system PATH!")
return

# Append the new directory to the PATH, separated by a semicolon
new_path = f"{current_path};{directory}"

# Set the modified PATH variable for the current session
os.environ['PATH'] = new_path

try:
# Use setx command to set the PATH persistently
subprocess.run(['setx', 'PATH', new_path], check=True)
print(f"Added {directory} to the system-wide PATH permanently.")
except subprocess.CalledProcessError as e:
print(f"Failed to set the PATH permanently: {e}")

directory_to_add = folder
add_to_system_path(directory_to_add)

0 comments on commit db91068

Please sign in to comment.