microsoft/TypeAgent
Publicmirrored from https://github.com/microsoft/TypeAgentAvailable
python/ta/make.bat
70lines · 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"=="clean" goto clean |
| 19 | if /I "%~1"=="help" goto help |
| 20 | |
| 21 | echo Unknown command: %~1 |
| 22 | goto help |
| 23 | |
| 24 | :format |
| 25 | if not exist "venv\" call make.bat venv |
| 26 | echo Formatting code... |
| 27 | venv\Scripts\black typeagent |
| 28 | goto end |
| 29 | |
| 30 | :check |
| 31 | if not exist "venv\" call make.bat venv |
| 32 | echo Running checks... |
| 33 | venv\Scripts\pyright --pythonpath venv\Scripts\python typeagent *.py |
| 34 | goto end |
| 35 | |
| 36 | :test |
| 37 | if not exist "venv\" call make.bat venv |
| 38 | echo Running tests... |
| 39 | venv\Scripts\python -m pytest |
| 40 | goto end |
| 41 | |
| 42 | :build |
| 43 | if not exist "venv\" call make.bat venv |
| 44 | echo Building package... |
| 45 | venv\Scripts\python -m build --wheel |
| 46 | goto end |
| 47 | |
| 48 | :venv |
| 49 | echo Creating virtual environment... |
| 50 | python3.12 -m venv venv |
| 51 | venv\Scripts\pip -q install -r requirements.txt |
| 52 | venv\Scripts\python --version |
| 53 | venv\Scripts\black --version |
| 54 | venv\Scripts\pyright --version |
| 55 | venv\Scripts\python -m pytest --version |
| 56 | |
| 57 | goto end |
| 58 | |
| 59 | :clean |
| 60 | echo Sorry, you have to clean up manually. |
| 61 | echo These are to be deleted: build dist *.egg-info venv |
| 62 | echo Delete venv if the requirements have changed. |
| 63 | echo The others are products of the build step. |
| 64 | goto end |
| 65 | |
| 66 | :help |
| 67 | echo Usage: .\make [format^|check^|test^|build^|venv^|clean^|help] |
| 68 | goto end |
| 69 | |
| 70 | :end |
| 71 | |