Skip to content

Commit

Permalink
Merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
dougollerenshaw committed Oct 10, 2024
2 parents 3a3d46e + edf893b commit 358fb60
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ https://github.com/user-attachments/assets/8aa729ff-c431-4a61-a9ef-d17050a27d02

2. Create a Conda environment:
```
conda create -n codeaide python=3.8
conda create -n codeaide python=3.11
conda activate codeaide
```

Expand Down
Binary file modified codeaide/assets/green_mic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified codeaide/assets/red_mic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions codeaide/ui/code_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ def line_number_area_paint_event(self, event):

block = self.firstVisibleBlock()
block_number = block.blockNumber()
top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top()
bottom = top + self.blockBoundingRect(block).height()
top = round(
self.blockBoundingGeometry(block).translated(self.contentOffset()).top()
)
bottom = top + round(self.blockBoundingRect(block).height())

while block.isValid() and top <= event.rect().bottom():
if block.isVisible() and bottom >= event.rect().top():
Expand All @@ -123,7 +125,7 @@ def line_number_area_paint_event(self, event):
)
block = block.next()
top = bottom
bottom = top + self.blockBoundingRect(block).height()
bottom = top + round(self.blockBoundingRect(block).height())
block_number += 1


Expand Down
26 changes: 20 additions & 6 deletions codeaide/utils/environment_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import venv
import shutil
from codeaide.utils.logging_config import get_logger

logger = get_logger()
Expand Down Expand Up @@ -45,11 +46,6 @@ def _get_installed_packages(self):
logger.error(f"Error getting installed packages: {e}")

def install_requirements(self, requirements_file):
pip_path = (
os.path.join(self.env_path, "bin", "pip")
if os.name != "nt"
else os.path.join(self.env_path, "Scripts", "pip.exe")
)
with open(requirements_file, "r") as f:
required_packages = {line.strip().lower() for line in f if line.strip()}

Expand All @@ -58,9 +54,14 @@ def install_requirements(self, requirements_file):
if packages_to_install:
packages_str = " ".join(packages_to_install)
logger.info(f"Installing new packages: {packages_str}")
pip_path = (
os.path.join(self.env_path, "bin", "pip")
if os.name != "nt"
else os.path.join(self.env_path, "Scripts", "pip.exe")
)
try:
subprocess.run(
f"{pip_path} install {packages_str}", shell=True, check=True
f'"{pip_path}" install {packages_str}', shell=True, check=True
)
self.installed_packages.update(packages_to_install)
logger.info(
Expand All @@ -86,3 +87,16 @@ def get_activation_command(self):
if os.name == "nt"
else f"source {activation_path}"
)

def get_python_executable(self):
if os.name == "nt": # Windows
return os.path.join(self.env_path, "Scripts", "python.exe")
else: # Unix-like
return os.path.join(self.env_path, "bin", "python")

def recreate_environment(self):
logger.info(f"Recreating virtual environment at {self.env_path}")
if os.path.exists(self.env_path):
shutil.rmtree(self.env_path)
self._setup_environment()
self._get_installed_packages()
6 changes: 4 additions & 2 deletions codeaide/utils/terminal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def __init__(self, traceback_callback=None):
atexit.register(self.cleanup)

def run_script(self, script_path, requirements_path):
# Install requirements
# Install only new requirements
new_packages = self.env_manager.install_requirements(requirements_path)

# Get activation command
Expand All @@ -203,6 +203,8 @@ def run_script(self, script_path, requirements_path):

def _create_script_content(self, script_path, activation_command, new_packages):
script_name = os.path.basename(script_path)
python_executable = self.env_manager.get_python_executable()

script_content = f"""
clear # Clear the terminal
echo "Activating environment..."
Expand All @@ -216,7 +218,7 @@ def _create_script_content(self, script_path, activation_command, new_packages):

script_content += f"""
echo "Running {script_name}..."
python "{script_path}"
"{python_executable}" "{script_path}"
echo "Script execution completed."
"""
return script_content
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ google-generativeai==0.8.3
python-decouple==3.8
virtualenv==20.16.2
numpy==1.26.4
numpy==1.26.4
openai
hjson
pyyaml
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.8",
python_requires=">=3.9",
)

0 comments on commit 358fb60

Please sign in to comment.