Skip to content

Commit

Permalink
debugged
Browse files Browse the repository at this point in the history
  • Loading branch information
dyldonahue committed Aug 19, 2024
1 parent b3882f9 commit 52b7982
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
distro
pre-commit
probe-rs
docker
docker-compose
62 changes: 45 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def modify_activation_scripts(venv_path):

# aliases

print("Activation script modified to start Docker container.")
print("Activation script modified to add aliases")
except Exception as e:
print(f"ERROR: Failed to modify activation script: {e}", file=sys.stderr)
print(f"Failed to modify activation script: {e}", file=sys.stderr)
sys.exit(1)

# Modify the deactivate script to stop Docker container
Expand All @@ -57,57 +57,82 @@ def modify_activation_scripts(venv_path):
deactivate_file.write("docker-compose down ner-gcc-arm\n")
print("Deactivation script modified to stop Docker container.")
except Exception as e:
print(f"ERROR: Failed to modify deactivation script: {e}", file=sys.stderr)
print(f"Failed to modify deactivation script: {e}", file=sys.stderr)
sys.exit(1)

def install_requirements(venv_python):
print("Installing requirements.txt...")
try:
run_command([venv_python, '-m', 'pip', 'install', '-r', 'requirements.txt'])
except Exception as e:
print(f"ERROR: Failed to install requirements: {e}", file=sys.stderr)
print(f"Failed to install requirements: {e}", file=sys.stderr)
sys.exit(1)

def install_pyyaml_no_build_isolation(venv_python):
print("Installing PyYAML without build isolation...")
try:
run_command([venv_python, '-m', 'pip', 'install', 'pyyaml==5.4.1', '--no-build-isolation'])
except Exception as e:
print(f"Failed to install PyYAML: {e}", file=sys.stderr)
sys.exit(1)

def install_cython_and_wheel(venv_python):
print("Installing Cython and Wheel...")
try:
run_command([venv_python, '-m', 'pip', 'install', 'cython<3.0.0', 'wheel'])
except Exception as e:
print(f"Failed to install Cython and Wheel: {e}", file=sys.stderr)
sys.exit(1)

def install_precommit(venv_python):
print("Installing pre-commit hook...")
try:
run_command([venv_python, '-m', 'pre_commit', 'install'])
except Exception as e:
print(f"ERROR: Failed to install pre-commit: {e}", file=sys.stderr)
print(f"Failed to install pre-commit: {e}", file=sys.stderr)
sys.exit(1)

def install_probe_rs(venv_python):
def install_probe_rs():
os_type = platform.system()
print("Installing probe-rs...")
try:
run_command([venv_python, '-m', 'pip', 'install', 'probe-rs'])
if os_type == "Windows":
# For Windows, using PowerShell to execute the script
command = ["powershell", "-Command", "irm https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.ps1 | iex"]
run_command(command, shell=False)
else:
# For Unix-like systems (Linux, macOS)
command = ["bash", "-c", "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh"]
run_command(command, shell=False)
except Exception as e:
print(f"ERROR: Failed to install probe-rs: {e}", file=sys.stderr)
print(f"Failed to install probe-rs: {e}", file=sys.stderr)
sys.exit(1)

def install_usbip():
if distro:
distro_name = distro.id()
if distro_name in ["ubuntu", "debian"]:
run_command(["sudo", "apt-get", "install", "-y", "usbip"])
run_command(["sudo", "apt-get", "install", "-y", "linux-tools-generic"])
elif distro_name == "fedora":
run_command(["sudo", "dnf", "install", "-y", "usbip"])
run_command(["sudo", "dnf", "install", "-y", "linux-tools-generic"])
elif distro_name == "arch":
run_command(["sudo", "pacman", "-S", "--noconfirm", "usbip"])
run_command(["sudo", "pacman", "-S", "--noconfirm", "linux-tools-generic"])
else:
print("We haven't added USBIP install support for your distro, but if you're actually on linux, you can install it manually!"))
print("We haven't added USBIP install support for your distro, but if you're actually on linux, you can install it manually!")
else:
print("You should only see this if im stupid!" Let someone know if you see this message")
print("You should only see this if im stupid! Let someone know if you see this message")

def main():
print("Welcome to NER Embedded Software! If this script shits the bed, let a system head or lead know!)
print("Welcome to NER Embedded Software! If this script shits the bed, let a system head or lead know!")
print("-----------------------------------------------------------------------------------------------")

# Step 0: Check for Docker and Rust
check_docker_and_rust()

os_type = platform.system()
venv_path = ".ner-venv"

current_directory = os.path.dirname(os.path.abspath(__file__))
parent_directory = os.path.dirname(current_directory)
venv_path = os.path.join(parent_directory, 'ner-venv')
# Step 1: Create the Python virtual environment
create_venv(venv_path)

Expand All @@ -118,13 +143,16 @@ def main():
venv_python = os.path.join(venv_path, 'Scripts', 'python') if os_type == "Windows" else os.path.join(venv_path, 'bin', 'python')

# Step 3: Install all Python packages from requirements.txt

install_cython_and_wheel(venv_python)
install_pyyaml_no_build_isolation(venv_python)
install_requirements(venv_python)

# Step 4: Run pre-commit install
install_precommit(venv_python)

# Step 5: Install probe-rs
install_probe_rs(venv_python)
install_probe_rs()

# Step 6: Install usbip if on Linux
if os_type == "Linux":
Expand Down

0 comments on commit 52b7982

Please sign in to comment.