Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ CodeAide.app/
# Ignore CodeAide.dmg file
CodeAide.dmg

# Ignore build directory
# Build artifacts
build/

# Ignore codeaide.spec file
codeaide.spec

# Ignore dist directory
dist/
*.spec
!build_scripts/codeaide.spec

# Ignore .dmg files
*.dmg

# Ignore .egg-info directories
*.egg-info/

# Ignore the models folder
models/
149 changes: 55 additions & 94 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,113 +6,74 @@ CodeAide is a chat application that leverages LLMs to generate code based on use

Follow these steps to build CodeAide as a standalone application for macOS:

Prerequisites
### Prerequisites

- Python 3.7 or higher
- pip (Python package installer)
- Python 3.11 or higher
- Conda (for managing the Python environment)
- Homebrew (for installing create-dmg)

### Step 1: Install Required Python Packages

```
pip install PyQt5 pyinstaller
```

### Step 2: Package the Application

1. Navigate to your project directory:
```
cd path/to/CodeAIde
```

2. Run PyInstaller:
```
pyinstaller --windowed --onefile --add-data "codeaide/examples.yaml:codeaide" codeaide.py
```
This command creates a single executable file in the `dist` folder.

Note: Make sure the path to examples.yaml is correct. If you're in the root of your project, it should be "codeaide/examples.yaml" as shown above.

### Step 3: Create an Application Bundle

1. Create the necessary directories:
```
mkdir -p CodeAide.app/Contents/MacOS
mkdir -p CodeAide.app/Contents/Resources
```

2. Move your executable:
```
mv dist/codeaide CodeAide.app/Contents/MacOS/CodeAide
```

3. Create an `Info.plist` file in `CodeAide.app/Contents/`:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>CodeAide</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.codeaide</string>
<key>CFBundleName</key>
<string>CodeAide</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
</dict>
</plist>
### Step 1: Set Up the Environment

1. Create and activate a new conda environment:
```
conda create -n codeaide python=3.11
conda activate codeaide
```

2. Ensure you're in the project root directory.

### Step 2: Run the Build Script

1. Make the build script executable:
```
chmod +x build_codeaide.sh
```

2. Run the build script:

For local testing (without notarization):
```
./build_codeaide.sh
```

For building a distributable version (with notarization):
```
./build_codeaide.sh --notarize
```

4. (Optional) Add an icon:
- Create a .icns file for your app icon
- Place it in `CodeAide.app/Contents/Resources/icon.icns`

### Step 4: Create the DMG

1. Install create-dmg:
```
brew install create-dmg
```

2. Create the DMG:
```
create-dmg \
--volname "CodeAide Installer" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "CodeAide.app" 200 190 \
--hide-extension "CodeAide.app" \
--app-drop-link 600 185 \
"CodeAide.dmg" \
"CodeAide.app"
```

### Step 5: Test The Application
If you choose to notarize, you will be prompted to enter:
- Your Developer ID Application certificate name
- Your Apple Developer Team ID
- Your Apple ID
- Your app-specific password

Make sure you have these details ready before running the script with the --notarize option.

### Step 3: Test The Application

Always test the DMG on a clean macOS installation to ensure it works as expected.

Troubleshooting
## Troubleshooting

If you encounter issues with resource files not being found:
If you encounter issues:

1. Ensure all necessary files (like `examples.yaml`) are included in the PyInstaller command with the correct path.
2. Check the console output for any error messages.
3. Verify that the paths in `general_utils.py` are correct for both development and packaged environments.
1. Check the console output for any error messages.
2. Ensure all necessary files are included in the `codeaide.spec` file.
3. Verify that the paths in your code are correct for both development and packaged environments.
4. If you're having issues with PyInstaller, try updating it to the latest version:
```
pip install --upgrade pyinstaller
```

Updating the Application
## Updating the Application

When updating the application:

1. Increment the version number in `Info.plist`.
2. Rebuild the application following the steps above.
3. Create a new DMG with the updated version.
1. Update the version number in the `build_codeaide.sh` script (look for `CFBundleShortVersionString`).
2. Rebuild the application by running the build script.

Notes
## Notes

- This README assumes you're building on macOS. The process may differ for other operating systems.
- This build process is designed for macOS. The process may differ for other operating systems.
- Ensure you're in the correct conda environment (`codeaide`) when running these commands.
- The `codeaide.spec` file is crucial for correct packaging. If you make changes to your project structure or dependencies, update the spec file accordingly.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ https://github.com/user-attachments/assets/8aa729ff-c431-4a61-a9ef-d17050a27d02
### Prerequisites

- Python 3.9 or higher
- Conda (Miniconda or Anaconda)

### Setup

Expand All @@ -47,14 +48,28 @@ https://github.com/user-attachments/assets/8aa729ff-c431-4a61-a9ef-d17050a27d02
pip install -r requirements.txt
```

4. Set up your Anthropic API key:
- Set up a developer account with Anthropic and get an API key at https://console.anthropic.com/dashboard
- You'll need to pre-fund your account to cover API costs. Current costs (as of Sept 15, 2024) are $0.003 and $0.015 per 1000 tokens for input and output, respectively. Long conversations will obviously cost more. Fund your account with something small (maybe $5) to start with, then add more if you find this tool useful.
- Create a `.env` file in the project root
- Add your API key to the file:
```
ANTHROPIC_API_KEY="your_api_key_here" # make sure the key is in quotes
```
Note: These instructions should work for most systems (macOS, including Apple Silicon, Windows, and Linux). If you encounter any architecture-specific issues, please refer to the troubleshooting section below or open an issue on GitHub.

### Troubleshooting

If you experience architecture-specific issues (e.g., on Apple Silicon Macs), try the following:

1. Ensure Conda is using the correct architecture:
```
conda info
```
Look for the "platform" field to confirm it matches your system architecture.

2. If needed, you can force Conda to use a specific architecture:
```
CONDA_SUBDIR=osx-arm64 conda create -n codeaide python=3.11 # For Apple Silicon
conda activate codeaide
conda config --env --set subdir osx-arm64 # For Apple Silicon
```

3. Then proceed with step 3 of the regular installation process.

For other architecture-specific issues, please open an issue on GitHub with details about your system and the problem you're encountering.

## Usage

Expand Down
64 changes: 64 additions & 0 deletions build_scripts/build_codeaide.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Exit on any error
set -e

# Activate the correct conda environment
eval "$(conda shell.bash hook)"
conda activate codeaide

# Get the path to the Python interpreter in the conda environment
PYTHON_PATH=$(which python)

# Change directory to the project root
cd "$(dirname "$0")/.."

# Ensure log directory exists
echo "Ensuring log directory exists..."
mkdir -p ~/Library/Logs/CodeAide

# Ensure application data directory exists
echo "Ensuring application data directory exists..."
mkdir -p ~/Library/Application\ Support/CodeAide

# Install required packages
echo "Installing required Python packages..."
$PYTHON_PATH -m pip install --upgrade pip
$PYTHON_PATH -m pip install -r requirements.txt

# Check if Whisper is installed
echo "Checking Whisper installation..."
$PYTHON_PATH -c "import whisper; print('Whisper version:', whisper.__version__)"

# Package the application
echo "Packaging the application..."
yes | $PYTHON_PATH -m PyInstaller build_scripts/codeaide.spec

# Create the DMG
echo "Creating DMG..."
APP_NAME="CodeAide"
DMG_NAME="${APP_NAME}.dmg"
SOURCE_DIR="dist/${APP_NAME}.app"
FINAL_DMG="${DMG_NAME}"

# Create a temporary directory for DMG contents
TEMP_DIR=$(mktemp -d)
cp -R "${SOURCE_DIR}" "${TEMP_DIR}"
ln -s /Applications "${TEMP_DIR}"

# Create the DMG
hdiutil create -volname "${APP_NAME}" -srcfolder "${TEMP_DIR}" -ov -format UDZO "${FINAL_DMG}"

# Clean up the temporary directory
rm -rf "${TEMP_DIR}"

# Verify that the DMG was created
if [ -f "${FINAL_DMG}" ]; then
echo "DMG created successfully: ${FINAL_DMG}"
else
echo "Error: DMG creation failed"
exit 1
fi

echo "Build process completed successfully!"
echo "The DMG is ready for testing. (Not signed or notarized)"
Loading