[READ-ONLY] Mirror of https://github.com/just-cameron/pyron. less hateful pip management
0

Configure Feed

Select the types of activity you want to include in your feed.

init commit

+211 -1
+94 -1
README.md
··· 1 1 # pyron 2 - Simple pip management 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 + Manage virtual python environments with ease. 29 + 30 + Creates and activates a `.pyron` virtual environment in your current directory. 31 + 32 + ## Features 33 + 34 + - Automatically creates or activates a `.pyron` virtual environment 35 + - Works in both bash and zsh 36 + - Performs Python version checks 37 + - Updates pip to latest version on environment creation 38 + - Provides clear feedback and error messages 39 + 40 + ## Usage 41 + 42 + ## Installation 43 + 44 + ### Option 1: Manual Installation 45 + 46 + 1. Download the script: 47 + ```bash 48 + mkdir -p ~/.local/bin 49 + curl -o ~/.local/bin/pyron.sh https://raw.githubusercontent.com/YOUR_USERNAME/pyron/main/pyron.sh 50 + ``` 51 + 52 + 2. Add to your shell configuration: 53 + 54 + For zsh (add to `~/.zshrc`): 55 + ```zsh 56 + source ~/.local/bin/pyron.sh 57 + ``` 58 + 59 + For bash (add to `~/.bashrc`): 60 + ```bash 61 + source ~/.local/bin/pyron.sh 62 + ``` 63 + 64 + ### Option 2: Using git 65 + 66 + ```bash 67 + git clone https://github.com/YOUR_USERNAME/pyron.git 68 + cd pyron 69 + ./install.sh 70 + ``` 71 + 72 + ## Usage 73 + 74 + Simply run `pyron` in any directory where you want to create or activate a Python virtual environment: 75 + 76 + ```bash 77 + cd your-project 78 + pyron 79 + python blah-blah-blah.py 80 + ``` 81 + 82 + This will: 83 + 1. Create a `.pyron` virtual environment if it doesn't exist 84 + 2. Activate the environment 85 + 3. Update pip to the latest version (on first creation) 86 + 4. Display the Python and pip versions being used 87 + 88 + ## Requirements 89 + 90 + - Python 3.7 or higher 91 + - bash or zsh shell 92 + 93 + ## License 94 + 95 + MIT License - see LICENSE file for details
+45
install.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + # Installer for pyron 4 + 5 + set -e 6 + 7 + # Configuration 8 + INSTALL_DIR="$HOME/.local/bin" 9 + SCRIPT_NAME="pyron.sh" 10 + 11 + # Create installation directory if it doesn't exist 12 + mkdir -p "$INSTALL_DIR" 13 + 14 + # Copy the script to the installation directory 15 + cp "$(dirname "$0")/$SCRIPT_NAME" "$INSTALL_DIR/$SCRIPT_NAME" 16 + 17 + # Make the script executable 18 + chmod +x "$INSTALL_DIR/$SCRIPT_NAME" 19 + 20 + # Detect shell and add source line to appropriate rc file 21 + add_source_line() { 22 + local rc_file="$1" 23 + local source_line="source $INSTALL_DIR/$SCRIPT_NAME" 24 + 25 + if ! grep -q "^$source_line" "$rc_file" 2>/dev/null; then 26 + echo "" >> "$rc_file" 27 + echo "# Added by pyron installer" >> "$rc_file" 28 + echo "$source_line" >> "$rc_file" 29 + echo "Added source line to $rc_file" 30 + else 31 + echo "Source line already exists in $rc_file" 32 + fi 33 + } 34 + 35 + # Add to appropriate shell configuration files 36 + if [ -f "$HOME/.zshrc" ]; then 37 + add_source_line "$HOME/.zshrc" 38 + fi 39 + 40 + if [ -f "$HOME/.bashrc" ]; then 41 + add_source_line "$HOME/.bashrc" 42 + fi 43 + 44 + echo "Installation complete! Please restart your shell or run:" 45 + echo " source $INSTALL_DIR/$SCRIPT_NAME"
+72
pyron.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + pyron() { 4 + # Default configuration 5 + VENV_NAME=".pyron" 6 + MIN_PYTHON_VERSION="3.7" 7 + 8 + # Function to compare version numbers 9 + version_compare() { 10 + printf '%s\n' "$1" "$2" | sort -V | head -n 1 11 + } 12 + 13 + # Function to check if we're in zsh 14 + is_zsh() { 15 + [ -n "$ZSH_VERSION" ] 16 + } 17 + 18 + # Function to get the appropriate activate script 19 + get_activate_script() { 20 + if is_zsh; then 21 + echo "source \"$VENV_NAME/bin/activate\"" 22 + else 23 + echo ". \"$VENV_NAME/bin/activate\"" 24 + fi 25 + } 26 + 27 + # Check if Python 3 is available 28 + if ! command -v python3 >/dev/null 2>&1; then 29 + echo "Error: Python 3 is not installed or not in PATH" >&2 30 + return 1 31 + fi 32 + 33 + # Check Python version 34 + PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') 35 + if [ "$(version_compare "$PYTHON_VERSION" "$MIN_PYTHON_VERSION")" = "$PYTHON_VERSION" ]; then 36 + echo "Error: Python $MIN_PYTHON_VERSION or higher is required (found $PYTHON_VERSION)" >&2 37 + return 1 38 + fi 39 + 40 + # Create or activate the virtual environment 41 + if [ ! -d "$VENV_NAME" ]; then 42 + echo "Creating new virtual environment '$VENV_NAME'..." 43 + python3 -m venv "$VENV_NAME" || { 44 + echo "Error: Failed to create virtual environment" >&2 45 + return 1 46 + } 47 + eval "$(get_activate_script)" || { 48 + echo "Error: Failed to activate virtual environment" >&2 49 + return 1 50 + } 51 + pip install --upgrade pip || { 52 + echo "Error: Failed to upgrade pip" >&2 53 + return 1 54 + } 55 + echo "Virtual environment created and activated successfully!" 56 + else 57 + echo "Found existing virtual environment '$VENV_NAME'" 58 + eval "$(get_activate_script)" || { 59 + echo "Error: Failed to activate virtual environment" >&2 60 + return 1 61 + } 62 + echo "Virtual environment activated successfully!" 63 + fi 64 + 65 + # Display environment information 66 + echo "Using Python: $(python --version)" 67 + echo "Using pip: $(pip --version)" 68 + echo "Environment location: $(which python)" 69 + } 70 + 71 + # Make the function available in the current shell 72 + # No need for export -f as sourcing the script makes the function available