feat(tinytorch): improve Windows/Git Bash installer support

Improvements based on PR #1105 by @rnjema:
- Add get_platform() function for OS detection
- Use $PYTHON_CMD -m pip for more reliable pip invocation
- Show Windows-specific guidance during installation
- Add text=auto to .gitattributes for cross-platform line endings

Closes #1078

Co-authored-by: rnjema <rnjema@users.noreply.github.com>
This commit is contained in:
Vijay Janapa Reddi
2026-01-27 12:51:38 -05:00
parent f0721f79bf
commit 446993eee6
2 changed files with 26 additions and 3 deletions

View File

@@ -3,3 +3,6 @@ tinytorch/core/*.py linguist-generated=true
tinytorch/**/*.py linguist-generated=true
# Exclude from diff by default (reduces noise)
tinytorch/core/*.py -diff
# Set default line termination behavior for all text files (cross-platform)
# Contributed by @rnjema (PR #1105)
* text=auto

View File

@@ -220,6 +220,19 @@ get_python_cmd() {
echo ""
}
# Find the system platform (linux, macos, windows)
# Contributed by @rnjema (PR #1105)
get_platform() {
local uname_out
uname_out=$(uname -s)
case "${uname_out}" in
Linux*) echo "linux";;
Darwin*) echo "macos";;
CYGWIN*|MINGW*|MSYS*) echo "windows";;
*) echo "unknown";;
esac
}
# ============================================================================
# Pre-flight Checks
# These run before any installation to catch problems early
@@ -266,6 +279,7 @@ check_prerequisites() {
# Check for Python 3.10+
PYTHON_CMD=$(get_python_cmd)
PLATFORM=$(get_platform)
if [ -n "$PYTHON_CMD" ]; then
# We know it's good because get_python_cmd validates it, but we run check again to get the version string
PY_VERSION=$(check_python_version "$PYTHON_CMD")
@@ -293,6 +307,11 @@ check_prerequisites() {
fi
fi
# Show Windows-specific guidance (contributed by @rnjema)
if [ "$PLATFORM" = "windows" ]; then
print_info "Windows detected - using Git Bash/WSL compatible mode"
fi
if [ $errors -gt 0 ]; then
echo ""
print_error "Missing prerequisites. Please fix the issues above."
@@ -472,11 +491,12 @@ do_install() {
# -------------------------------------------------------------------------
# Step 3: Install dependencies
# Uses $PYTHON_CMD -m pip for reliability (contributed by @rnjema)
# -------------------------------------------------------------------------
echo -e "${BLUE}[3/4]${NC} Installing dependencies..."
# Upgrade pip first
pip install --upgrade pip -q 2>/dev/null &
$PYTHON_CMD -m pip install --upgrade pip -q 2>/dev/null &
local pip_pid=$!
spin $pip_pid "Upgrading pip..."
wait $pip_pid
@@ -484,14 +504,14 @@ do_install() {
# Install from requirements.txt
if [ -f "requirements.txt" ]; then
total_pkgs=$(grep -c -E "^[^#]" requirements.txt 2>/dev/null || echo "?")
pip install -r requirements.txt -q 2>/dev/null &
$PYTHON_CMD -m pip install -r requirements.txt -q 2>/dev/null &
local req_pid=$!
spin $req_pid "Installing $total_pkgs packages..."
wait $req_pid
fi
# Install TinyTorch package in editable mode (includes tito CLI)
pip install -e . -q 2>/dev/null &
$PYTHON_CMD -m pip install -e . -q 2>/dev/null &
local tt_pid=$!
spin $tt_pid "Installing TinyTorch..."
wait $tt_pid