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