-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake.bat
More file actions
205 lines (169 loc) · 7.11 KB
/
make.bat
File metadata and controls
205 lines (169 loc) · 7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
@echo off
for /f "tokens=1,* delims= " %%a in ("%*") do set EXTRA_ARGS=%%b
if [%1] == [] call:main && goto:eof
if "%~1" == "install-dev" call:install-dev && goto:eof
REM if "%~1" == "gui" goto gui
if "%~1" == "docs" call:docs %EXTRA_ARGS% && goto:eof
if "%~1" == "venv" call:venv && goto:eof
if "%~1" == "venvclean" call:venvclean && goto:eof
if "%~1" == "test" call:test && goto:eof
if "%~1" == "test-mypy" call:mypy %EXTRA_ARGS% && goto:eof
if "%~1" == "build" call:build && goto:eof
if "%~1" == "wheel" call:wheel && goto:eof
if "%~1" == "sdist" call:sdist && goto:eof
if "%~1" == "freeze" call:freeze && goto:eof
if "%~1" == "clean" call:clean && goto:eof
if "%~1" == "help" call:help && goto:eof
if not %ERRORLEVEL% == 0 exit /b %ERRORLEVEL%
goto :error %*
EXIT /B 0
:: ============================================================================
:: Display help information about available options
:: ============================================================================
:help
echo Available options:
echo make install-dev Installs the development requirements into active python environment
echo make venv Creates a virtualenv with development requirements
echo make venvclean Removes the generated virtualenv
echo make build Creates a build in the build directory
echo make docs Generates html documentation into the docs/build/html directory
echo make test Runs tests
echo make test-mypy Runs MyPy tests
echo wheel Build a Python built distribution wheel
echo sdist Build a Python source distribution
echo make freeze Creates a Windows Release build with CX_Freeze
echo make clean Removes generated files
goto :eof
:: ============================================================================
:: Default target if no options are selected
:: ============================================================================
:main
call:sdist
call:wheel
call:docs --build-dir dist/docs
goto :eof
:: ============================================================================
:: Setup a development environment
:: ============================================================================
:install-dev
call:venv
setlocal
echo Installing development requirements
call venv\Scripts\activate.bat
pip install -r requirements-dev.txt
pip install -r requirements.txt
endlocal
goto :eof
:: ============================================================================
:: Build a virtualenv sandbox for development
:: ============================================================================
:venv
if exist "venv" echo %CD%\venv folder already exists. To activate virtualenv, use venv\Scripts\activate.bat & goto :eof
echo Creating a local virtualenv in %CD%\venv
setlocal
REM Create a new virtualenv in the venv path
py -m venv venv
endlocal
goto :eof
:: ============================================================================
:: Remove virtualenv sandbox
:: ============================================================================
:venvclean
if exist "venv" echo removing venv & RD /S /Q venv
goto :eof
:: ============================================================================
:: Build the target
:: ============================================================================
:build
call:install-dev
setlocal
call venv\Scripts\activate.bat && python setup.py build
endlocal
goto :eof
:: ============================================================================
:: Create a wheel distribution
:: ============================================================================
:wheel
call:install-dev
setlocal
call venv\Scripts\activate.bat && python setup.py bdist_wheel
endlocal
goto :eof
:: ============================================================================
:: Create a source distribution
:: ============================================================================
:sdist
call:install-dev
setlocal
call venv\Scripts\activate.bat && python setup.py sdist
endlocal
goto :eof
:: ============================================================================
:: Create a cx_freeze distribution
:: ============================================================================
:freeze
call:install-dev
setlocal
call venv\Scripts\activate.bat
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
python -m pip install -r requirements-freeze.txt
python cx_setup.py bdist_msi --add-to-path=true -k --bdist-dir build/msi
call build\\msi\\hathivalidate.exe --pytest
endlocal
goto :eof
:: ============================================================================
:: Run unit tests
:: ============================================================================
:test
call:install-dev
setlocal
call venv\Scripts\activate.bat && python setup.py test
endlocal
goto :eof
:: ============================================================================
:: Test code with mypy
:: ============================================================================
:mypy
call:install-dev
setlocal
call venv\Scripts\activate.bat && mypy -p hathi_validate %*
endlocal
goto :eof
:: ============================================================================
:: Build html documentation
:: ============================================================================
:docs
call:install-dev
echo Creating docs
setlocal
call venv\Scripts\activate.bat && python setup.py build_sphinx %*
endlocal
goto :eof
:: ============================================================================
:: Clean up any generated files
:: ============================================================================
:clean
setlocal
call venv\Scripts\activate.bat
echo Calling cx_setup.py clean
python cx_setup.py clean --all --quiet
echo Calling setup.py clean
python setup.py clean --all --quiet
echo Cleaning docs
call docs\make.bat clean
if exist .cache rd /q /s .cache && echo Removed .cache
if exist .reports rd /q /s .reports && echo Removed .reports
if exist .mypy_cache rd /q /s .mypy_cache && echo Removed .mypy_cache
if exist .eggs rd /q /s .eggs && echo Removed .eggs
if exist .tox rd /q /s .tox && echo Removed .tox
if exist HathiValidate.egg-info rd /q /s HathiValidate.egg-info && echo Removed HathiValidate.egg-info
endlocal
goto :eof
:: ============================================================================
:: If user request an invalid target
:: ============================================================================
:error
echo Unknown option: %*
call :help
goto :eof