microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
python/ta/make.bat
87lines · modecode
| 1 | :: Copyright (c) Microsoft Corporation. |
| 2 | :: Licensed under the MIT License. |
| 3 | |
| 4 | :: This is a batch file to run common actions. |
| 5 | :: It can format the code, check the code, run the tests, |
| 6 | :: build the package, create a virtual environment, and clean up. |
| 7 | :: To avoid having to type `./make` all the time, |
| 8 | :: use `set-alias make ".\make.bat"` in PowerShell. |
| 9 | |
| 10 | @echo off |
| 11 | if "%~1"=="" goto help |
| 12 | |
| 13 | if /I "%~1"=="format" goto format |
| 14 | if /I "%~1"=="check" goto check |
| 15 | if /I "%~1"=="test" goto test |
| 16 | if /I "%~1"=="demo" goto demo |
| 17 | if /I "%~1"=="build" goto build |
| 18 | if /I "%~1"=="venv" goto venv |
| 19 | if /I "%~1"=="install-uv" goto install-uv |
| 20 | if /I "%~1"=="clean" goto clean |
| 21 | if /I "%~1"=="help" goto help |
| 22 | |
| 23 | echo Unknown command: %~1 |
| 24 | goto help |
| 25 | |
| 26 | :format |
| 27 | if not exist ".venv\" call make.bat venv |
| 28 | echo Formatting code... |
| 29 | .venv\Scripts\black typeagent test |
| 30 | goto end |
| 31 | |
| 32 | :check |
| 33 | if not exist ".venv\" call make.bat venv |
| 34 | echo Running checks... |
| 35 | .venv\Scripts\pyright --pythonpath .venv\Scripts\python typeagent test |
| 36 | goto end |
| 37 | |
| 38 | :test |
| 39 | if not exist ".venv\" call make.bat venv |
| 40 | echo Running tests... |
| 41 | .venv\Scripts\python -m pytest test |
| 42 | goto end |
| 43 | |
| 44 | :demo |
| 45 | if not exist ".venv\" call make.bat venv |
| 46 | echo Running demo... |
| 47 | .venv\Scripts\python -m tools.utool |
| 48 | goto end |
| 49 | |
| 50 | :build |
| 51 | if not exist ".venv\" call make.bat venv |
| 52 | echo Building package... |
| 53 | .venv\Scripts\python -m build --wheel --installer uv |
| 54 | goto end |
| 55 | |
| 56 | :venv |
| 57 | echo Creating virtual environment... |
| 58 | uv sync -q |
| 59 | .venv\Scripts\python --version |
| 60 | .venv\Scripts\black --version |
| 61 | .venv\Scripts\pyright --version |
| 62 | .venv\Scripts\python -m pytest --version |
| 63 | goto end |
| 64 | |
| 65 | :install-uv |
| 66 | echo Installing uv requires Administrator mode! |
| 67 | echo 1. Using PowerShell in Administrator mode: |
| 68 | echo Invoke-RestMethod https://astral.sh/uv/install.ps1 ^| Invoke-Expression |
| 69 | echo 2. Add ~/.local/bin to $env:PATH, e.g. by putting |
| 70 | echo $env:PATH += ";$HOME\.local\bin |
| 71 | echo in your PowerShell profile ($PROFILE) and restarting PowerShell. |
| 72 | echo (Sorry, I have no idea how to do that in cmd.exe.) |
| 73 | goto end |
| 74 | |
| 75 | :clean |
| 76 | if exist build rmdir /s /q build |
| 77 | if exist dist rmdir /s /q dist |
| 78 | if exist typeagent.egg-info rmdir /s /q typeagent.egg-info |
| 79 | if exist .venv rmdir /s /q .venv |
| 80 | if exist .pytest_cache rmdir /s /q .pytest_cache |
| 81 | goto end |
| 82 | |
| 83 | :help |
| 84 | echo Usage: .\make [format^|check^|test^|build^|venv^|install-uv^|clean^|help] |
| 85 | goto end |
| 86 | |
| 87 | :end |
| 88 | |