Skip to content

Commit

Permalink
fix batch scripts
Browse files Browse the repository at this point in the history
->'print_heading' was not found + erratic behaviour
+ replace 'echo' by 'print_heading' in 'create_venv.bat'
+ fix doc:  'create_venv_win.bat' to 'create_venv.bat
  • Loading branch information
hansipie committed Sep 21, 2024
1 parent 0cd1431 commit aac1824
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Please follow the [fork and pull request](https://docs.github.com/en/get-started
1. Clone the repository.
2. Create a virtual environment:
- For Unix, use `./scripts/create_venv.sh`.
- For Windows, use `.\scripts\create_venv_win.bat`.
- For Windows, use `.\scripts\create_venv.bat`.
- This setup will:
- Create a `phienv` virtual environment in the current directory.
- Install the required packages.
Expand Down
3 changes: 3 additions & 0 deletions scripts/_utils.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@echo off
call :%~1 "%~2"
goto :eof

:: Collection of helper functions to import in other scripts

:: Function to pause the script until a key is pressed
Expand Down
16 changes: 8 additions & 8 deletions scripts/create_venv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."
set "VENV_DIR=%REPO_ROOT%\phienv"

call "%CURR_DIR%_utils.bat"
set "UTILS_BAT=%CURR_DIR%_utils.bat"

echo phidata dev setup
echo Creating venv: %VENV_DIR%
call "%UTILS_BAT%" print_heading "phidata dev setup"
call "%UTILS_BAT%" print_heading "Creating venv: %VENV_DIR%"

echo Removing existing venv: %VENV_DIR%
call "%UTILS_BAT%" print_heading "Removing existing venv: %VENV_DIR%"
rd /s /q "%VENV_DIR%"

echo Creating python3 venv: %VENV_DIR%
call "%UTILS_BAT%" print_heading "Creating python3 venv: %VENV_DIR%"
python -m venv "%VENV_DIR%"

echo Upgrading pip to the latest version
call "%UTILS_BAT%" print_heading "Upgrading pip to the latest version"
call "%VENV_DIR%\Scripts\python.exe" -m pip install --upgrade pip
if %ERRORLEVEL% neq 0 (
echo Failed to upgrade pip. Please run the script as Administrator or check your network connection.
exit /b %ERRORLEVEL%
)

echo Installing base python packages
call "%UTILS_BAT%" print_heading "Installing base python packages"
call "%VENV_DIR%\Scripts\pip" install pip-tools twine build
if %ERRORLEVEL% neq 0 (
echo Failed to install required packages. Attempting to retry installation...
Expand All @@ -34,6 +34,6 @@ if %ERRORLEVEL% neq 0 (
call "%VENV_DIR%\Scripts\activate"
call "%CURR_DIR%install.bat"

echo Activate using: call %VENV_DIR%\Scripts\activate
call "%UTILS_BAT%" print_heading "Activate using: call %VENV_DIR%\Scripts\activate"

endlocal
12 changes: 6 additions & 6 deletions scripts/format.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."

:: Ensure that _utils.bat is correctly located and called
call "%CURR_DIR%\_utils.bat"
set "UTILS_BAT=%CURR_DIR%_utils.bat"

:main
call :print_heading "Formatting phidata"
call "%UTILS_BAT%" print_heading "Formatting phidata"

call :print_heading "Running: ruff format %REPO_ROOT%"
call "%UTILS_BAT%" print_heading "Running: ruff format %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\ruff" format "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed to format with ruff.
goto :eof
)

call :print_heading "Running: ruff check %REPO_ROOT%"
call "%UTILS_BAT%" print_heading "Running: ruff check %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\ruff" check "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed ruff check.
goto :eof
)

call :print_heading "Running: mypy %REPO_ROOT%"
call "%UTILS_BAT%" print_heading "Running: mypy %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\mypy" "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed mypy check.
goto :eof
)

call :print_heading "Running: pytest %REPO_ROOT%"
call "%UTILS_BAT%" print_heading "Running: pytest %REPO_ROOT%"
call "%REPO_ROOT%\phienv\Scripts\pytest" "%REPO_ROOT%"
if %ERRORLEVEL% neq 0 (
echo Failed pytest.
Expand Down
8 changes: 4 additions & 4 deletions scripts/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

set "CURR_DIR=%~dp0"
set "REPO_ROOT=%~dp0.."
call "%CURR_DIR%_utils.bat"
set "UTILS_BAT=%CURR_DIR%_utils.bat"

:main
call :print_heading "Installing phidata"
call "%UTILS_BAT%" print_heading "Installing phidata"

call :print_heading "Installing requirements.txt"
call "%UTILS_BAT%" print_heading "Installing requirements.txt"
call "%REPO_ROOT%\phienv\Scripts\pip" install --no-deps -r "%REPO_ROOT%\requirements.txt"

call :print_heading "Installing phidata with [dev] extras"
call "%UTILS_BAT%" print_heading "Installing phidata with [dev] extras"
call "%REPO_ROOT%\phienv\Scripts\pip" install --editable "%REPO_ROOT%[dev]"

goto :eof

0 comments on commit aac1824

Please sign in to comment.