# 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)