Skip to content

Commit

Permalink
Added better utility scripts that are platform independent
Browse files Browse the repository at this point in the history
  • Loading branch information
adalfarus committed Jun 9, 2024
1 parent 1c9cdad commit 0e905a6
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 101 deletions.
10 changes: 0 additions & 10 deletions 0.1.5_checklist.txt

This file was deleted.

2 changes: 1 addition & 1 deletion aplustools/_direct_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def install_all_dependencies():
"opencv-python==4.9.0.80", "brotli==1.1.0",
"zstandard==0.22.0", "py7zr==0.21.0", "pillow_heif==0.15.0", "numpy==1.26.4",
"speedtest-cli==2.1.3", "windows-toasts==1.1.1; os_name == 'nt'",
"quantcrypt==0.4.2; os_name == 'nt'", "scipy==1.13.0",
"quantcrypt>=0.4.2; os_name == 'nt'", "scipy==1.13.0",
"scikit-learn==1.4.1.post1; os_name == 'nt'",
"scikit-learn==1.5.0; os_name != 'nt'"])
if not success:
Expand Down
124 changes: 124 additions & 0 deletions apt_build_master.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
@echo off
setlocal enabledelayedexpansion

REM Command line arguments processing
if not "%~1"=="" (
set "choice=%1"
goto process_choice_no_pause
)

REM Function to display the menu
:show_menu
cls
echo.
echo ==============================================================
echo AplusTools Main Menu
echo ==============================================================
echo 1. Install pytest and run tests
echo 2. Build the project
echo 3. Clear dist directory and build
echo 4. Install the newly built package
echo 5. Run all steps in order (1, 2 ^& 4)
echo 0. Exit
echo ==============================================================
echo.
set /p choice="Enter your choice (0-5, or multiple choices): "

goto process_choice

REM Function to process the choice
:process_choice
setlocal enabledelayedexpansion
for /l %%i in (0,1,31) do (
set "opt=!choice:~%%i,1!"
if "!opt!" == "1" call :run_tests
if "!opt!" == "2" call :build_project
if "!opt!" == "3" call :clear_and_build
if "!opt!" == "4" call :install_package
if "!opt!" == "5" call :run_all
if "!opt!" == "0" goto end
)
pause
goto end

REM Process choice without pause
:process_choice_no_pause
setlocal enabledelayedexpansion
for /l %%i in (0,1,31) do (
set "opt=!choice:~%%i,1!"
if "!opt!" == "1" call :run_tests
if "!opt!" == "2" call :build_project
if "!opt!" == "3" call :clear_and_build
if "!opt!" == "4" call :install_package
if "!opt!" == "5" call :run_all
if "!opt!" == "0" goto end
)
goto end

REM Function to run tests
:run_tests
@echo off
REM Install pytest
py -m pip install pytest

REM Ensure test_data directory exists and is empty
set "DIR=test_data"
if exist "%DIR%" (
echo Clearing directory %DIR%...
rmdir /s /q "%DIR%"
)
echo Creating directory %DIR%...
mkdir "%DIR%"

REM Run tests
echo Running tests...
pytest aplustools/tests
echo Tests completed.
exit /b

REM Function to build the project
:build_project
@echo off
echo Building the project...
py -m build
echo Build completed.
exit /b

REM Function to clear dist directory and build
:clear_and_build
@echo off
echo Clearing dist directory...
del /Q ".\dist\*.*"
call :build_project
exit /b

REM Function to install the newly built package
:install_package
@echo off
for %%F in (dist\*.whl) do (
py -m pip install "%%F" --force-reinstall
)
echo Package installation completed.
exit /b

REM Function to run all steps
:run_all
@echo off
call :run_tests
call :build_project
call :install_package
exit /b

:end
echo Exiting...
endlocal
exit /b

REM Command line arguments processing
if "%1" NEQ "" (
set "choice=%1"
goto process_choice
)

REM Show the menu by default
goto show_menu
125 changes: 125 additions & 0 deletions apt_build_master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/bash

# Function to display the menu
show_menu() {
clear
echo
echo "=============================================================="
echo " AplusTools Main Menu"
echo "=============================================================="
echo "1. Install pytest and run tests"
echo "2. Build the project"
echo "3. Clear dist directory and build"
echo "4. Install the newly built package"
echo "5. Run all steps in order (1, 2 & 4)"
echo "0. Exit"
echo "=============================================================="
echo
read -p "Enter your choice (0-5, or multiple choices): " choice
process_choice
}

# Function to process the choice
process_choice() {
local len=${#choice}
for (( i=0; i<$len; i++ )); do
local opt=${choice:i:1}
case $opt in
1) run_tests ;;
2) build_project ;;
3) clear_and_build ;;
4) install_package ;;
5) run_all ;;
0) end ;;
*) echo "Invalid choice: $opt" ;;
esac
done
pause
end
}

# Function to process the choice without pause
process_choice_no_pause() {
local len=${#choice}
for (( i=0; i<$len; i++ )); do
local opt=${choice:i:1}
case $opt in
1) run_tests ;;
2) build_project ;;
3) clear_and_build ;;
4) install_package ;;
5) run_all ;;
0) end ;;
*) echo "Invalid choice: $opt" ;;
esac
done
end
}

# Function to pause the script
pause() {
read -p "Press any key to continue..." -n1 -s
}

# Function to run tests
run_tests() {
# Install pytest
python3 -m pip install pytest

# Ensure test_data directory exists and is empty
DIR="test_data"
if [ -d "$DIR" ]; then
echo "Clearing directory $DIR..."
rm -rf "$DIR"
fi
echo "Creating directory $DIR..."
mkdir "$DIR"

# Run tests
echo "Running tests..."
pytest aplustools/tests
echo "Tests completed."
}

# Function to build the project
build_project() {
echo "Building the project..."
python3 -m build
echo "Build completed."
}

# Function to clear dist directory and build
clear_and_build() {
echo "Clearing dist directory..."
rm -rf dist/*
build_project
}

# Function to install the newly built package
install_package() {
for file in dist/*.whl; do
python3 -m pip install "$file" --force-reinstall
done
echo "Package installation completed."
}

# Function to run all steps
run_all() {
run_tests
build_project
install_package
}

# Function to end the script
end() {
echo "Exiting..."
exit 0
}

# Command line arguments processing
if [ -n "$1" ]; then
choice=$1
process_choice_no_pause
else
show_menu
fi
13 changes: 0 additions & 13 deletions build.bat

This file was deleted.

15 changes: 0 additions & 15 deletions install.bat

This file was deleted.

16 changes: 0 additions & 16 deletions install2.bat

This file was deleted.

15 changes: 0 additions & 15 deletions install3.bat

This file was deleted.

31 changes: 0 additions & 31 deletions run_tests.bat

This file was deleted.

0 comments on commit 0e905a6

Please sign in to comment.