File size: 4,524 Bytes
c032460 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# Development Environment Setup
## Learning Objectives
By the end of this section, you will be able to:
- Install and configure pixi for Python package management
- Set up GitHub Copilot for AI-assisted development
- Configure VS Code or your preferred IDE for Python development
- Verify your development environment is working correctly
## Installing Pixi
Pixi is a modern, cross-platform package manager that simplifies Python project management and dependency handling.
### Installation
```bash
# Install pixi (works on Linux, macOS, and Windows)
curl -fsSL https://pixi.sh/install.sh | bash
# Verify installation
pixi --version
```
### Why Pixi?
- **Fast**: Uses conda packages with parallel downloads
- **Reproducible**: Lock files ensure consistent environments
- **Cross-platform**: Works identically on all operating systems
- **Modern**: Built with Rust for performance and reliability
## Setting Up GitHub Copilot
GitHub Copilot is an AI pair programmer that helps you write code faster and with fewer errors.
### Prerequisites
- GitHub account with Copilot subscription (free for students and open-source maintainers)
- VS Code or compatible IDE
### Installation Steps
1. **Install VS Code** (if not already installed)
- Download from [code.visualstudio.com](https://code.visualstudio.com/)
2. **Install GitHub Copilot Extension**
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "GitHub Copilot"
- Click Install
3. **Sign In**
- Click "Sign in to GitHub" when prompted
- Authorize VS Code to access your GitHub account
- Complete the authentication flow
4. **Verify Setup**
- Create a new Python file
- Start typing a function definition
- You should see gray suggestions from Copilot
### Copilot Best Practices
- **Write clear comments**: Copilot uses comments to understand your intent
- **Use descriptive names**: Function and variable names guide suggestions
- **Review suggestions**: Always review and understand generated code
- **Iterate**: If the first suggestion isn't right, try rephrasing your comment
## Installing Git
Git is essential for version control and collaboration.
```bash
# Linux (Debian/Ubuntu)
sudo apt install git
# macOS (with Homebrew)
brew install git
# Windows
# Download from git-scm.com
```
Verify installation:
```bash
git --version
```
## IDE Configuration
### VS Code Extensions
Install these recommended extensions:
- **Python** (Microsoft) - Python language support
- **GitHub Copilot** - AI pair programmer
- **Pylance** - Fast Python language server
- **Ruff** - Fast Python linter
- **GitLens** - Enhanced Git capabilities
### VS Code Settings
Create or update `.vscode/settings.json` in your project:
```json
{
"python.linting.enabled": true,
"python.linting.ruffEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"github.copilot.enable": {
"*": true,
"python": true
}
}
```
## Verification
Let's verify everything is working:
```bash
# Check pixi
pixi --version
# Check Git
git --version
# Check Python (via pixi)
pixi run python --version
```
## Creating Your First Pixi Project
```bash
# Create a new directory
mkdir my-first-cli
cd my-first-cli
# Initialize pixi project
pixi init
# Add Python
pixi add python
# Create a simple script
mkdir src
echo 'print("Hello from Kashi Coding Handbook!")' > src/hello.py
# Run it
pixi run python src/hello.py
```
You should see: `Hello from Kashi Coding Handbook!`
## Troubleshooting
### Pixi not found after installation
- **Linux/macOS**: Add pixi to your PATH by restarting your terminal or running:
```bash
source ~/.bashrc # or ~/.zshrc
```
- **Windows**: Restart your terminal or add pixi to your system PATH
### Copilot not showing suggestions
- Verify you're signed in to GitHub in VS Code
- Check that Copilot is enabled in VS Code settings
- Try reloading VS Code (Ctrl+Shift+P → "Reload Window")
### Permission errors with pixi
- Don't use `sudo` with pixi
- Ensure you have write permissions in your home directory
## Next Steps
Now that your development environment is set up, proceed to the next section to learn about modern Python project structure.
## Resources
- [Pixi Documentation](https://pixi.sh/latest/)
- [GitHub Copilot Docs](https://docs.github.com/en/copilot)
- [VS Code Python Tutorial](https://code.visualstudio.com/docs/python/python-tutorial)
|