From 52b798280200ed17d7b15e587789aecf7da80ba2 Mon Sep 17 00:00:00 2001 From: Dylan Donahue Date: Mon, 19 Aug 2024 19:10:05 -0400 Subject: [PATCH] debugged --- requirements.txt | 1 - setup.py | 62 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/requirements.txt b/requirements.txt index d4e260e..a3fac95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ distro pre-commit -probe-rs docker docker-compose diff --git a/setup.py b/setup.py index 276fdbf..3d68cf1 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -57,7 +57,7 @@ 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): @@ -65,7 +65,23 @@ def install_requirements(venv_python): 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): @@ -73,41 +89,50 @@ def install_precommit(venv_python): 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) @@ -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":