microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
python/ta/make.bat
80lines · 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"=="build" goto build |
| 17 | if /I "%~1"=="venv" goto venv |
| 18 | if /I "%~1"=="install-uv" goto install-uv |
| 19 | if /I "%~1"=="clean" goto clean |
| 20 | if /I "%~1"=="help" goto help |
| 21 | |
| 22 | echo Unknown command: %~1 |
| 23 | goto help |
| 24 | |
| 25 | :format |
| 26 | if not exist ".venv\" call make.bat venv |
| 27 | echo Formatting code... |
| 28 | .venv\Scripts\black typeagent test |
| 29 | goto end |
| 30 | |
| 31 | :check |
| 32 | if not exist ".venv\" call make.bat venv |
| 33 | echo Running checks... |
| 34 | .venv\Scripts\pyright --pythonpath .venv\Scripts\python typeagent test |
| 35 | goto end |
| 36 | |
| 37 | :test |
| 38 | if not exist ".venv\" call make.bat venv |
| 39 | echo Running tests... |
| 40 | .venv\Scripts\python -m pytest test |
| 41 | goto end |
| 42 | |
| 43 | :build |
| 44 | if not exist ".venv\" call make.bat venv |
| 45 | echo Building package... |
| 46 | .venv\Scripts\python -m build --wheel --installer uv |
| 47 | goto end |
| 48 | |
| 49 | :venv |
| 50 | echo Creating virtual environment... |
| 51 | uv sync -q |
| 52 | .venv\Scripts\python --version |
| 53 | .venv\Scripts\black --version |
| 54 | .venv\Scripts\pyright --version |
| 55 | .venv\Scripts\python -m pytest --version |
| 56 | goto end |
| 57 | |
| 58 | :install-uv |
| 59 | echo Installing uv requires Administrator mode! |
| 60 | echo 1. Using PowerShell in Administrator mode: |
| 61 | echo Invoke-RestMethod https://astral.sh/uv/install.ps1 ^| Invoke-Expression |
| 62 | echo 2. Add ~/.local/bin to $env:PATH, e.g. by putting |
| 63 | echo $env:PATH += ";$HOME\.local\bin |
| 64 | echo in your PowerShell profile ($PROFILE) and restarting PowerShell. |
| 65 | echo (Sorry, I have no idea how to do that in cmd.exe.) |
| 66 | goto end |
| 67 | |
| 68 | :clean |
| 69 | if exist build rmdir /s /q build |
| 70 | if exist dist rmdir /s /q dist |
| 71 | if exist typeagent.egg-info rmdir /s /q typeagent.egg-info |
| 72 | if exist .venv rmdir /s /q .venv |
| 73 | if exist .pytest_cache rmdir /s /q .pytest_cache |
| 74 | goto end |
| 75 | |
| 76 | :help |
| 77 | echo Usage: .\make [format^|check^|test^|build^|venv^|install-uv^|clean^|help] |
| 78 | goto end |
| 79 | |
| 80 | :end |
| 81 | |