From df7de4345e7bca677152c3e0ee44e0e3291cb840 Mon Sep 17 00:00:00 2001 From: omsherikar Date: Thu, 18 Dec 2025 02:41:18 +0530 Subject: [PATCH 1/7] quick setup added for Mac/Linux and Windows --- CONTRIBUTING.md | 42 ++++++++++------- README.md | 4 +- setup_dev.bat | 111 ++++++++++++++++++++++++++++++++++++++++++++ setup_dev.sh | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 258 insertions(+), 19 deletions(-) create mode 100644 setup_dev.bat create mode 100755 setup_dev.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7179515..af87872 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,34 +28,42 @@ git clone https://github.com/YOUR_USERNAME/Refactron_lib.git cd Refactron_lib ``` -### 2. Set Up Environment +### 2. Set Up Environment (Automated) + +**Quick way (recommended):** + +```bash +# On macOS/Linux: +./setup_dev.sh + +# On Windows: +setup_dev.bat +``` + +This script will: +- Create a virtual environment +- Install all dependencies +- Set up pre-commit hooks +- Verify the installation +- Run tests to ensure everything works + +**Manual way (if you prefer):** + ```bash # Create virtual environment python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate # Install in development mode -pip install -e . -pip install -r requirements-dev.txt -``` +pip install -e ".[dev]" -### 3. Install Pre-commit Hooks (Optional but Recommended) -```bash +# Install pre-commit hooks pip install pre-commit pre-commit install -``` -### 4. Verify Installation -```bash -# Run tests +# Verify installation pytest - -# Check code quality -black --check refactron tests -flake8 refactron --max-line-length=100 - -# Try the CLI -refactron --help +refactron --version ``` **You're ready to contribute!** See [Making Your First Contribution](#making-your-first-contribution) below. diff --git a/README.md b/README.md index ae7b817..c5f6425 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ Quick start: ```bash git clone https://github.com/Refactron-ai/Refactron_lib.git cd Refactron_lib -pip install -e ".[dev]" -pytest # Make sure tests pass +./setup_dev.sh # macOS/Linux - automatically sets everything up +# OR setup_dev.bat # Windows ``` See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide. We follow the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). diff --git a/setup_dev.bat b/setup_dev.bat new file mode 100644 index 0000000..f9e615e --- /dev/null +++ b/setup_dev.bat @@ -0,0 +1,111 @@ +@echo off +REM Refactron Development Setup Script for Windows +REM This script automates the setup of the development environment + +echo ๐Ÿš€ Setting up Refactron development environment... +echo. + +REM Check if Python is available +python --version >nul 2>&1 +if errorlevel 1 ( + echo โŒ Error: Python is required but not found. + echo Please install Python 3.8 or higher and try again. + exit /b 1 +) + +echo โœ… Python detected +echo. + +REM Create virtual environment if it doesn't exist +if not exist "venv" ( + echo ๐Ÿ“ฆ Creating virtual environment... + python -m venv venv + echo โœ… Virtual environment created +) else ( + echo โœ… Virtual environment already exists +) + +echo. +echo ๐Ÿ”„ Activating virtual environment... +call venv\Scripts\activate.bat + +REM Upgrade pip +echo. +echo โฌ†๏ธ Upgrading pip... +python -m pip install --upgrade pip --quiet +if errorlevel 1 ( + echo โŒ Error: Failed to upgrade pip + exit /b 1 +) + +REM Install the package in editable mode with dev dependencies +echo. +echo ๐Ÿ“ฅ Installing Refactron in development mode... +python -m pip install -e ".[dev]" --quiet +if errorlevel 1 ( + echo โŒ Error: Failed to install Refactron in development mode + exit /b 1 +) + +REM Install additional dev dependencies if requirements-dev.txt exists +if exist "requirements-dev.txt" ( + echo ๐Ÿ“ฅ Installing additional development dependencies... + python -m pip install -r requirements-dev.txt --quiet + if errorlevel 1 ( + echo โŒ Error: Failed to install development dependencies + exit /b 1 + ) +) + +REM Install pre-commit hooks +echo. +echo ๐Ÿ”ง Setting up pre-commit hooks... +python -m pip install pre-commit --quiet +if errorlevel 1 ( + echo โŒ Error: Failed to install pre-commit + exit /b 1 +) +pre-commit install +if errorlevel 1 ( + echo โŒ Error: Failed to install pre-commit hooks + exit /b 1 +) +echo โœ… Pre-commit hooks installed + +REM Verify installation +echo. +echo ๐Ÿงช Verifying installation... +python -c "import refactron; print('โœ… Refactron imported successfully')" 2>nul +if errorlevel 1 ( + echo โŒ Error: Could not import refactron + exit /b 1 +) + +REM Check CLI +echo. +echo ๐Ÿ” Checking CLI... +refactron --version >nul 2>&1 +if errorlevel 1 ( + echo โŒ Error: CLI not working + exit /b 1 +) else ( + for /f "tokens=*" %%i in ('refactron --version') do set VERSION=%%i + echo โœ… CLI working: %VERSION% +) + +echo. +echo โœจ Development environment setup complete! +echo. +echo ๐Ÿ“ Next steps: +echo 1. Activate the virtual environment: venv\Scripts\activate +echo 2. Make your changes +echo 3. Run tests: pytest +echo 4. Format code: black refactron tests +echo 5. Check code quality: flake8 refactron +echo. +echo ๐Ÿ’ก To activate the environment in the future, run: +echo venv\Scripts\activate +echo. +echo Happy coding! ๐Ÿš€ +pause + diff --git a/setup_dev.sh b/setup_dev.sh new file mode 100755 index 0000000..71f2bde --- /dev/null +++ b/setup_dev.sh @@ -0,0 +1,120 @@ +#!/bin/bash + +# Refactron Development Setup Script +# This script automates the setup of the development environment + +set -e # Exit on any error + +echo "๐Ÿš€ Setting up Refactron development environment..." +echo "" + +# Check if Python 3 is available +if ! command -v python3 &> /dev/null; then + echo "โŒ Error: Python 3 is required but not found." + echo "Please install Python 3.8 or higher and try again." + exit 1 +fi + +# Check Python version (must be 3.8+) +PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') +if ! python3 -c "import sys; exit(0 if sys.version_info >= (3, 8) else 1)" 2>/dev/null; then + echo "โŒ Error: Python 3.8 or higher is required. Found Python $PYTHON_VERSION" + exit 1 +fi + +echo "โœ… Python $PYTHON_VERSION detected" + +# Create virtual environment if it doesn't exist +if [ ! -d "venv" ]; then + echo "" + echo "๐Ÿ“ฆ Creating virtual environment..." + python3 -m venv venv + echo "โœ… Virtual environment created" +else + echo "โœ… Virtual environment already exists" +fi + +# Activate virtual environment +echo "" +echo "๐Ÿ”„ Activating virtual environment..." +source venv/bin/activate + +# Upgrade pip +echo "" +echo "โฌ†๏ธ Upgrading pip..." +pip install --upgrade pip --quiet + +# Install the package in editable mode with dev dependencies +echo "" +echo "๐Ÿ“ฅ Installing Refactron in development mode..." +pip install -e ".[dev]" --quiet + +# Install additional dev dependencies if requirements-dev.txt exists +if [ -f "requirements-dev.txt" ]; then + echo "๐Ÿ“ฅ Installing additional development dependencies..." + pip install -r requirements-dev.txt --quiet +fi + +# Install pre-commit hooks +echo "" +echo "๐Ÿ”ง Setting up pre-commit hooks..." +if command -v pre-commit &> /dev/null || pip show pre-commit &> /dev/null; then + pre-commit install + echo "โœ… Pre-commit hooks installed" +else + echo "โš ๏ธ pre-commit not found. Installing..." + pip install pre-commit --quiet + pre-commit install + echo "โœ… Pre-commit hooks installed" +fi + +# Verify installation +echo "" +echo "๐Ÿงช Verifying installation..." +# Use python3 for consistency (venv should have it, but python3 is more reliable) +if python3 -c "import refactron; print('โœ… Refactron imported successfully')" 2>/dev/null; then + echo "โœ… Installation verified" +else + echo "โŒ Error: Could not import refactron" + exit 1 +fi + +# Check CLI +echo "" +echo "๐Ÿ” Checking CLI..." +if refactron --version &> /dev/null; then + VERSION=$(refactron --version) + echo "โœ… CLI working: $VERSION" +else + echo "โŒ Error: CLI not working" + exit 1 +fi + +# Run tests to verify everything works +echo "" +echo "๐Ÿงช Running tests to verify setup..." +if pytest --version &> /dev/null; then + pytest tests/ -v --tb=short -x || { + echo "" + echo "โš ๏ธ Some tests failed, but setup is complete." + echo "You can investigate test failures later." + } +else + echo "โš ๏ธ pytest not found. Setup complete, but tests couldn't run." +fi + +echo "" +echo "โœจ Development environment setup complete!" +echo "" +echo "๐Ÿ“ Next steps:" +echo " 1. Activate the virtual environment: source venv/bin/activate" +echo " 2. Make your changes" +echo " 3. Run tests: pytest" +echo " 4. Format code: black refactron tests" +echo " 5. Check code quality: flake8 refactron" +echo "" +echo "๐Ÿ’ก To activate the environment in the future, run:" +echo " source venv/bin/activate" +echo "" +echo "Happy coding! ๐Ÿš€" + From 8d7950483f488f94688bd273f8de799b61865979 Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 10:58:19 +0530 Subject: [PATCH 2/7] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5f6425..b7034b3 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Quick start: ```bash git clone https://github.com/Refactron-ai/Refactron_lib.git cd Refactron_lib -./setup_dev.sh # macOS/Linux - automatically sets everything up +bash setup_dev.sh # macOS/Linux - automatically sets everything up # OR setup_dev.bat # Windows ``` From 4f589177e91857603d293728afc2c55f0dd83e48 Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 11:19:44 +0530 Subject: [PATCH 3/7] Update setup_dev.bat Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- setup_dev.bat | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/setup_dev.bat b/setup_dev.bat index f9e615e..ee019eb 100644 --- a/setup_dev.bat +++ b/setup_dev.bat @@ -93,6 +93,16 @@ if errorlevel 1 ( echo โœ… CLI working: %VERSION% ) +REM Run test suite with pytest to verify setup +echo. +echo ๐Ÿงช Running test suite with pytest... +pytest +if errorlevel 1 ( + echo โš ๏ธ Warning: Some tests failed. Please review the pytest output above. +) else ( + echo โœ… All tests passed successfully. +) + echo. echo โœจ Development environment setup complete! echo. From 89c4b39dba02b6d0145c6845ad71a4065c688c79 Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 11:20:39 +0530 Subject: [PATCH 4/7] Update setup_dev.bat Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- setup_dev.bat | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup_dev.bat b/setup_dev.bat index ee019eb..71d0f0c 100644 --- a/setup_dev.bat +++ b/setup_dev.bat @@ -13,6 +13,13 @@ if errorlevel 1 ( exit /b 1 ) +REM Check Python version (must be 3.8 or higher) +python -c "import sys; sys.exit(0 if sys.version_info >= (3, 8) else 1)" >nul 2>&1 +if errorlevel 1 ( + echo โŒ Error: Python 3.8 or higher is required. + echo Detected Python version is lower than 3.8. + exit /b 1 +) echo โœ… Python detected echo. From e3c2561d832e1420d3dc816e98e8eb17d6e84fb1 Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 11:22:34 +0530 Subject: [PATCH 5/7] Update CONTRIBUTING.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af87872..1346880 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ cd Refactron_lib ```bash # On macOS/Linux: -./setup_dev.sh +bash setup_dev.sh # On Windows: setup_dev.bat From 97e515a82405038756d9e342b60f91f0ad04bdb2 Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 11:23:18 +0530 Subject: [PATCH 6/7] Update setup_dev.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- setup_dev.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/setup_dev.sh b/setup_dev.sh index 71f2bde..07d1ccc 100755 --- a/setup_dev.sh +++ b/setup_dev.sh @@ -49,10 +49,25 @@ echo "" echo "๐Ÿ“ฅ Installing Refactron in development mode..." pip install -e ".[dev]" --quiet -# Install additional dev dependencies if requirements-dev.txt exists +# Install additional (non-core) dev dependencies if requirements-dev.txt exists +# NOTE: +# - Core development tools (pytest, black, mypy, flake8, isort, etc.) are installed +# via the [dev] extra in pyproject.toml (see the pip install -e ".[dev]" above). +# - To avoid redundant installations and version conflicts, we only use +# requirements-dev.txt for *extra* tools such as documentation dependencies. if [ -f "requirements-dev.txt" ]; then - echo "๐Ÿ“ฅ Installing additional development dependencies..." - pip install -r requirements-dev.txt --quiet + echo "๐Ÿ“ฅ Installing additional documentation/development dependencies from requirements-dev.txt..." + + # Extract Sphinx-related requirements (e.g., sphinx, sphinx-rtd-theme) from + # requirements-dev.txt and install only those. This avoids re-installing tools + # that are already provided by the [dev] extra. + DOC_REQUIREMENTS=$(grep -E '^[[:space:]]*sphinx' requirements-dev.txt || true) + + if [ -n "$DOC_REQUIREMENTS" ]; then + echo "$DOC_REQUIREMENTS" | xargs -n1 pip install --quiet + else + echo "โ„น๏ธ No additional documentation dependencies detected in requirements-dev.txt; skipping." + fi fi # Install pre-commit hooks From 06ed4055c3b18af3835e17b933f9d0fc4e0e34cc Mon Sep 17 00:00:00 2001 From: Om Sherikar Date: Thu, 18 Dec 2025 11:23:49 +0530 Subject: [PATCH 7/7] Update setup_dev.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- setup_dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup_dev.sh b/setup_dev.sh index 07d1ccc..41f560e 100755 --- a/setup_dev.sh +++ b/setup_dev.sh @@ -109,11 +109,11 @@ fi echo "" echo "๐Ÿงช Running tests to verify setup..." if pytest --version &> /dev/null; then - pytest tests/ -v --tb=short -x || { + if ! pytest tests/ -v --tb=short -x; then echo "" echo "โš ๏ธ Some tests failed, but setup is complete." echo "You can investigate test failures later." - } + fi else echo "โš ๏ธ pytest not found. Setup complete, but tests couldn't run." fi