Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@brief 

3@file Batch file use to automate some of the tasks (setup, unit tests, help, pypi). 

4""" 

5import sys 

6 

7 

8def _sversion(): 

9 return "PY%d%d" % sys.version_info[:2] 

10 

11################# 

12#: stop if error 

13################# 

14 

15 

16windows_error = "if %errorlevel% neq 0 exit /b %errorlevel%" 

17 

18################# 

19#: prefix 

20################# 

21windows_prefix = """ 

22@echo off 

23@echo SCRIPT: windows_prefix 

24if "%1"=="" goto default_value_python: 

25if "%1"=="default" goto default_value_python: 

26set pythonexe=%1 

27goto start_script: 

28 

29:default_value_python: 

30set pythonexe=__PY??_X64__\\python 

31 

32@echo ~SET pythonexe=%pythonexe% 

33 

34:start_script: 

35set current=%~dp0 

36if EXIST %current%setup.py goto current_is_setup: 

37set current=%current%..\\ 

38cd .. 

39if EXIST %current%setup.py goto current_is_setup: 

40@echo Unable to find %current%setup.py 

41exit /b 1 

42 

43:current_is_setup: 

44@echo ~SET current=%current% 

45 

46""".replace("PY??", _sversion()) 

47 

48################# 

49#: prefix 27 

50################# 

51windows_prefix_27 = """ 

52@echo off 

53@echo SCRIPT: windows_prefix_27 

54if "%1"=="" goto default_value_python: 

55if "%1"=="default" goto default_value_python: 

56set pythonexe27=%1 

57goto start_script: 

58 

59:default_value_python: 

60set pythonexe27=__PY27_X64__\\python 

61:start_script: 

62@echo PY27: ~SET pythonexe27=%pythonexe27% 

63""" 

64 

65################# 

66#: run unit test 27 

67################# 

68windows_unittest27 = """ 

69@echo off 

70@echo SCRIPT: windows_unittest27 

71set PYTHONPATH= 

72@echo run27: ~SET PYTHONPATH= 

73@echo pythonexe27=%pythonexe27% 

74set current=%~dp0 

75cd %current%..\\dist_module27\\_unittests 

76 

77@echo run27: check existing for nose in %pythonexe27%\\..\\Scripts\\nosetests.exe 

78if NOT EXIST %pythonexe27%\\..\\Scripts\\nosetests.exe dir %pythonexe27%\\..\\Scripts 

79 

80rem errorlevel does not work well in a loop 

81rem for /d %%d in (ut_*) do ( 

82rem @echo ~CALL %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d 

83rem %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d 

84rem if %errorlevel% neq 0 exit /b %errorlevel% 

85rem ) 

86 

87@echo run27: start the loop 

88 

89rem we are in a virtual environnement 

90@echo if not exist %pythonexe27%\\..\\Scripts set pythonexe27=%pythonexe27%\\..\\..\\Scripts 

91if not exist %pythonexe27%\\..\\Scripts set pythonexe27=%pythonexe27%\\..\\..\\Scripts 

92@echo looking for nosetests.exe in %pythonexe27% 

93 

94__LOOP_UNITTEST_FOLDERS__ 

95 

96""" + windows_error + "\ncd ..\\.." 

97 

98############ 

99#: copy to local pypiserver 

100############ 

101 

102copy_to_pypiserver = """ 

103@echo SCRIPT: copy_to_pypiserver 

104@echo ~LABEL end 

105rem we copy the wheel on a local folder to let a pypiserver take it 

106if not exist ..\\..\\local_pypi mkdir ..\\..\\local_pypi 

107if not exist ..\\..\\local_pypi\\local_pypi_server mkdir ..\\..\\local_pypi\\local_pypi_server 

108@echo ~CALL if exist dist copy /Y dist\\*.whl ..\\..\\local_pypi\\local_pypi_server 

109if exist dist copy /Y dist\\*.whl ..\\..\\local_pypi\\local_pypi_server 

110""" 

111 

112#################################################### 

113#: build any script for Windows from a virtual environment 

114#################################################### 

115windows_any_setup_command_base = """ 

116 

117set current=%~dp0 

118if EXIST %current%setup.py goto current_is_setup: 

119set current=%current%..\\ 

120cd .. 

121if EXIST %current%setup.py goto current_is_setup: 

122@echo Unable to find %current%setup.py 

123exit /b 1 

124 

125:current_is_setup: 

126@echo ~SET current=%current% 

127 

128@echo SCRIPT: windows_any_setup_command_base 

129@echo off 

130if "%1"=="" @echo usage: SCRIPT [pythonpath] [suffix] [command] [...] 

131set CURRENT_THIS=%~dp0 

132 

133if EXIST %current%setup.py goto current_is_setup: 

134set current=%current%..\\ 

135cd .. 

136if EXIST %current%setup.py goto current_is_setup: 

137@echo Unable to find %current%setup.py 

138exit /b 1 

139 

140:current_is_setup: 

141@echo ~SET CURRENT_THIS=%CURRENT_THIS% 

142 

143IF EXIST dist del /Q dist\\*.* 

144IF EXIST build del /Q build\\*.* 

145 

146if "%2"=="" goto default_value_suffix: 

147if "%2"=="default" goto default_value_suffix: 

148set virtual_env_suffix=%2 

149goto default_value_suffix_next: 

150:default_value_suffix: 

151set virtual_env_suffix=_anyenv 

152:default_value_suffix_next: 

153@echo ~SET set virtual_env_suffix=%virtual_env_suffix% 

154 

155if "%1"=="" goto default_value: 

156if "%1"=="default" goto default_value: 

157set pythonexe=%1 

158goto default_value_next: 

159:default_value: 

160set pythonexe=__PY??_X64__\\python 

161:default_value_next: 

162 

163echo ###----################################################5 

164echo ###----################################################5 

165echo ###----################################################5 

166echo %pythonexe% 

167echo ###----################################################5 

168echo ###----################################################5 

169echo ###----################################################5 

170SET ROOT_VIRTUAL_ENV=%CURRENT_THIS%_virtualenv 

171if not exist %ROOT_VIRTUAL_ENV% mkdir %ROOT_VIRTUAL_ENV% 

172set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

173@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

174if not exist %pythonexe%\\..\\Scripts\\virtualenv.exe goto conda_virtual_env: 

175 

176if exist %virtual_env_py%_vir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_vir%virtual_env_suffix% 

177mkdir %virtual_env_py%_vir%virtual_env_suffix% 

178 

179if exist %virtual_env_py%_vir%virtual_env_suffix%\\python goto with_virtual: 

180set KEEPPATH=%PATH% 

181@echo ~SET KEEPPATH=%PATH% 

182set PATH=%pythonexe%\\..;%PATH% 

183@echo ~SET PATH=%pythonexe%\\..;%PATH% 

184@echo ~CALL %pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix% 

185%pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix% 

186@echo ### VIRTUAL ENVIRONMENT CREATED in %virtual_env_py%_vir%virtual_env_suffix% 

187 

188@echo on 

189rem _PATH_VIRTUAL_ENV_ 

190@echo off 

191 

192:with_virtual: 

193@echo ~LABEL with_virtual 

194set pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python 

195@echo ~SET pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python 

196set pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip 

197@echo ~SET pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip 

198goto requirements: 

199 

200:conda_virtual_env: 

201@echo ~LABEL conda_virtual_env 

202if exist %virtual_env_py%_condavir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_condavir%virtual_env_suffix% 

203 

204if exist %virtual_env_py%_condavir%virtual_env_suffix%\\python goto with_virtual_conda: 

205 

206@echo ~CALL %pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline 

207%pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline 

208if %errorlevel% neq 0 exit /b %errorlevel% 

209 

210:with_virtual_conda: 

211@echo ~LABEL with_virtual_conda 

212set pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python 

213@echo ~SET pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python 

214set pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip 

215@echo ~SET pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip 

216%pythonpip% install sphinx --upgrade --cache-dir=%virtual_env_py%_condavir%virtual_env_suffix% 

217@echo ~%pythonpip% install sphinx --upgrade --cache-dir=%virtual_env_py%_condavir%virtual_env_suffix% 

218 

219:requirements: 

220@echo #######################################################_auto_setup_dep.py 

221cd build\\auto_setup 

222set pythonexe_rel=..\\..\\%pythonexe%.exe 

223@echo ~SET pythonexe_rel=..\\..\\%pythonexe%.exe 

224if exist %pythonexe_rel% goto auto_setup_relpath: 

225set pythonexe_rel=%pythonexe% 

226@echo ~SET pythonexe_rel=%pythonexe% 

227 

228:auto_setup_relpath: 

229@echo ~LABAL auto_setup_relpath 

230@echo ~CALL %pythonexe_rel% auto_setup_dep.py install 

231%pythonexe_rel% auto_setup_dep.py install > auto_setup_dep.log 

232rem if %errorlevel% neq 0 exit /b %errorlevel% 

233rem we continue to run the script even if it seems to fail 

234cd ..\\.. 

235@echo #######################################################_auto_setup_dep.py END 

236 

237@echo #######################################################_requirements_begin 

238@echo ~SET %pythonpip% 

239__REQUIREMENTS__ 

240if %errorlevel% neq 0 exit /b %errorlevel% 

241@echo #######################################################_requirements_end 

242%pythonpip% freeze 

243@echo #######################################################_requirements_list 

244 

245@echo ~SET pythonexe=%pythonexe% 

246@echo ~CALL %pythonexe% %current%setup.py write_version 

247%pythonexe% %current%setup.py write_version 

248if %errorlevel% neq 0 exit /b %errorlevel% 

249@echo ################# VERSION 

250more %~dp0..\\version.txt 

251if %errorlevel% neq 0 exit /b %errorlevel% 

252@echo ################# VERSION 

253 

254@echo #######################################################_PATH 

255set PYTHONPATH=%PYTHONPATH%;%current%\\src__ADDITIONAL_LOCAL_PATH__;%current%__ADDITIONAL_LOCAL_PATH__ 

256@echo ~SET PYTHONPATH=%PYTHONPATH%;%current%\\src__ADDITIONAL_LOCAL_PATH__;%current%__ADDITIONAL_LOCAL_PATH__ 

257""".replace("PY??", _sversion()) 

258 

259 

260################# 

261#: setup_hook for Windows 

262################# 

263 

264windows_setup_hook = """ 

265@echo SCRIPT: windows_setup_hook 

266@echo #######################################################_setup_hook 

267@echo ~CALL %pythonexe% %current%setup.py setup_hook 

268%pythonexe% %current%setup.py setup_hook 

269if %errorlevel% neq 0 exit /b %errorlevel% 

270@echo #######################################################_END_BASE 

271""" 

272 

273################# 

274#: build script for Windows 

275################# 

276 

277windows_any_setup_command = windows_any_setup_command_base + windows_setup_hook + """ 

278@echo ~CALL %pythonexe% -u %current%setup.py %3 %4 %5 %6 %7 %8 %9 

279rem set PYTHONPATH=additional_path 

280%pythonexe% -u %current%setup.py %3 %4 %5 %6 %7 %8 %9 

281if %errorlevel% neq 0 exit /b %errorlevel% 

282@echo #######################################################6 

283""" + copy_to_pypiserver 

284 

285################# 

286#: call the setup 

287################# 

288windows_setup = "rem set PYTHONPATH=additional_path\n%pythonexe% -u %current%setup.py" 

289jenkins_windows_setup = "%jenkinspythonexe% -u %current%setup.py" 

290 

291################# 

292#: build setup script for Windows 

293################# 

294 

295windows_build_setup = windows_any_setup_command_base + windows_setup_hook + """ 

296@echo ~CALL %pythonexe% %current%setup.py sdist %2 --formats=gztar,zip --verbose 

297%pythonexe% %current%setup.py sdist %2 --formats=gztar,zip --verbose 

298if %errorlevel% neq 0 exit /b %errorlevel% 

299pushd %current% 

300@echo ~CALL %pythonexe% %current%setup.py bdist_wheel %2 

301%pythonexe% %current%setup.py bdist_wheel %2 

302popd 

303if %errorlevel% neq 0 exit /b %errorlevel% 

304""" + copy_to_pypiserver 

305 

306################# 

307#: build script MAIN SCRIPT 

308################# 

309windows_build = windows_any_setup_command_base + windows_setup_hook + """ 

310@echo #######################################################_unit 

311@echo ~CALL %pythonexe% -u %current%setup.py unittests 

312rem set PYTHONPATH=additional_path --> we use a virtual environment here 

313%pythonexe% -u %current%setup.py unittests 

314if %errorlevel% neq 0 exit /b %errorlevel% 

315@echo #######################################################6 

316 

317@echo ~CALL %pythonexe% %current%setup.py clean_pyd 

318%pythonexe% %current%setup.py clean_pyd 

319pushd %current% 

320@echo ~CALL %pythonexe% %current%setup.py sdist --formats=gztar,zip --verbose 

321%pythonexe% %current%setup.py sdist --formats=gztar,zip --verbose 

322popd 

323if %errorlevel% neq 0 exit /b %errorlevel% 

324pushd %current% 

325@echo ~CALL %pythonexe% %current%setup.py bdist_wininst --plat-name=win-amd64 

326%pythonexe% %current%setup.py bdist_wininst --plat-name=win-amd64 

327popd 

328if %errorlevel% neq 0 exit /b %errorlevel% 

329pushd %current% 

330@echo ~CALL %pythonexe% %current%setup.py bdist_msi 

331%pythonexe% %current%setup.py bdist_msi 

332popd 

333if %errorlevel% neq 0 exit /b %errorlevel% 

334pushd %current% 

335@echo ~CALL %pythonexe% %current%setup.py bdist_wheel 

336%pythonexe% %current%setup.py bdist_wheel 

337popd 

338if %errorlevel% neq 0 exit /b %errorlevel% 

339@echo #######################################################7 

340 

341:documentation: 

342@echo ~LABEL documentation 

343@echo ~CALL %pythonexe% -u %current%setup.py build_sphinx 

344%pythonexe% -u %current%setup.py build_sphinx 

345if %errorlevel% neq 0 exit /b %errorlevel% 

346@echo #######################################################8 

347 

348:copyfiles: 

349@echo ~LABEL copyfiles 

350if not exist dist\\html mkdir dist\\html 

351@echo ~CALL xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\html dist\\html 

352xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\html dist\\html 

353@echo ~COPY chm 

354if exist _doc\\sphinxdoc\\build\\htmlhelp copy _doc\\sphinxdoc\\build\\htmlhelp\\*.chm dist\\html 

355@echo ~COPY pdf 

356if exist _doc\\sphinxdoc\\build\\latex xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\latex\\*.pdf dist\\html 

357if %errorlevel% neq 0 exit /b %errorlevel% 

358 

359:end: 

360""".replace("PY??", _sversion()) + copy_to_pypiserver 

361 

362################# 

363#: build script for Windows BASE + virtual environment 

364################# 

365 

366copy_sphinx_to_dist = """ 

367@echo SCRIPT: copy_sphinx_to_dist 

368if not exist dist\\html mkdir dist\\html 

369@echo ~CALL xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\html dist\\html 

370xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\html dist\\html 

371@echo ~COPY chm 

372if exist _doc\\sphinxdoc\\build\\htmlhelp copy _doc\\sphinxdoc\\build\\htmlhelp\\*.chm dist\\html 

373@echo ~COPY pdf 

374if exist _doc\\sphinxdoc\\build\\latex xcopy /E /C /I /Y _doc\\sphinxdoc\\build\\latex\\*.pdf dist\\html 

375if %errorlevel% neq 0 exit /b %errorlevel% 

376""" 

377 

378################# 

379#: notebooks 

380################# 

381windows_notebook = """ 

382@echo off 

383@echo SCRIPT: windows_notebook 

384if "%1"=="" goto default_value: 

385if "%1"=="default" goto default_value: 

386set pythonexe=%1 

387goto nextn: 

388 

389:default_value: 

390@echo ~LABEL default_value 

391set pythonexe=__PY??_X64__ 

392@echo ~SET pythonexe=__PY??_X64__ 

393 

394:nextn: 

395@echo ~LABEL nextn 

396set current=%~dp0 

397 

398set current=%~dp0 

399if EXIST %current%setup.py goto current_is_setup: 

400set current=%current%..\\ 

401cd .. 

402if EXIST %current%setup.py goto current_is_setup: 

403@echo Unable to find %current%setup.py 

404exit /b 1 

405 

406:current_is_setup: 

407@echo ~SET current=%current% 

408 

409set path=%path%;%pythonexe%;%pythonexe%\\Scripts 

410@echo ~SET path=%path%;%pythonexe%;%pythonexe%\\Scripts 

411@echo ~CALL jupyter-notebook --notebook-dir=_doc\\notebooks 

412set PYTHONPATH=%PYTHONPATH%;%current%\\src__ADDITIONAL_LOCAL_PATH__;%current%__ADDITIONAL_LOCAL_PATH__ 

413@echo ~SET PYTHONPATH=%PYTHONPATH%;%current%\\src__ADDITIONAL_LOCAL_PATH__;%current%__ADDITIONAL_LOCAL_PATH__ 

414@echo on 

415jupyter-notebook --notebook-dir=_doc\\notebooks --NotebookApp.token= --NotebookApp.password= 

416""".replace("PY??", _sversion()) 

417 

418################# 

419#: publish a module 

420################# 

421windows_publish = """ 

422@echo SCRIPT: windows_publish 

423%pythonexe% %current%setup.py rotate --match=.whl --keep=10 

424rem %pythonexe% %current%setup.py sdist register 

425pushd %current% 

426%pythonexe% %current%setup.py bdist_wheel sdist --formats=gztar 

427%pythonexe% -m twine %current%/dist upload *.whl 

428%pythonexe% -m twine %current%/dist upload *.gz 

429set /P NVERSION=< version.txt 

430git tag v%NVERSION% 

431git push origin v%NVERSION% 

432popd 

433""" 

434 

435################# 

436#: publish the documentation 

437################# 

438windows_publish_doc = """ 

439@echo SCRIPT: windows_publish_doc 

440pushd %current% 

441%pythonexe% -u %current%setup.py upload_docs --upload-dir=dist/html 

442popd 

443""" 

444 

445################# 

446#: run a pypi server 

447################# 

448windows_pypi = """ 

449@echo SCRIPT: windows_pypi 

450set pythonexe=__PY??_X64__ 

451@echo ~SET pythonexe=__PY??_X64__ 

452 

453if "%2"=="" goto default_port: 

454if "%2"=="default" goto default_port: 

455set portpy=%2 

456@echo ~SET portpy=%2 

457goto run: 

458 

459:default_port: 

460@echo ~LABEL default_port 

461set portpy=__PORT__ 

462@echo ~SET portpy=__PORT__ 

463 

464:run: 

465@echo ~LABEL run 

466@echo ~CALL %pythonexe%\\Scripts\\pypi-server.exe -v -u -p %portpy% --disable-fallback ..\\..\\local_pypi\\local_pypi_server 

467%pythonexe%\\Scripts\\pypi-server.exe -v -u -p %portpy% --disable-fallback ..\\..\\local_pypi\\local_pypi_server 

468""".replace("PY??", _sversion()) 

469 

470################# 

471#: script for Jenkins 

472################# 

473windows_jenkins = "@echo SCRIPT: windows_jenkins\nset jenkinspythonexe=__PYTHON__\n@echo ~SET jenkinspythonexe=__PYTHON__\n" + \ 

474 "\n__PACTHPQb__\n" + \ 

475 jenkins_windows_setup + " build_script\n" + \ 

476 "\n__PACTHPQe__\n" + \ 

477 windows_error + "\nauto_unittest_setup_help.bat %jenkinspythonexe% __SUFFIX__\n" + \ 

478 windows_error 

479 

480windows_jenkins_any = "@echo SCRIPT: windows_jenkins_any\nset jenkinspythonexe=__PYTHON__\n@echo ~SET jenkinspythonexe=__PYTHON__\n" + \ 

481 "\n__PACTHPQb__\n" + \ 

482 jenkins_windows_setup + " build_script\n" + \ 

483 "\n__PACTHPQe__\n" + \ 

484 windows_error + "\nauto_cmd_any_setup_command.bat %jenkinspythonexe% __SUFFIX__ __COMMAND__\n" + \ 

485 windows_error 

486 

487#################### 

488#: script for Jenkins 27 

489#################### 

490 

491_second_part = """ 

492@echo SCRIPT: _second_part 

493:requirements: 

494@echo ~LABEL requirements 

495@echo #######################################################_auto_setup_dep.py 

496cd build\\auto_setup 

497set pythonexe_rel=..\\..\\%jenkinspythonexe%.exe 

498@echo ~SET pythonexe_rel=..\\..\\%jenkinspythonexe%.exe 

499if exist %pythonexe_rel% goto auto_setup_relpath: 

500set pythonexe_rel=%jenkinspythonexe% 

501@echo ~SET pythonexe_rel=%jenkinspythonexe% 

502 

503:auto_setup_relpath: 

504@echo ~LABEL auto_setup_relpath 

505@echo ~CALL %pythonexe_rel% auto_setup_dep.py install 

506%pythonexe_rel% auto_setup_dep.py install 

507if %errorlevel% neq 0 exit /b %errorlevel% 

508cd ..\\.. 

509if %errorlevel% neq 0 exit /b %errorlevel% 

510 

511@echo #######################################################_requirements_begin 

512echo ~SET %jenkinspythonpip% 

513""" 

514 

515windows_jenkins_unittest27_conda = (""" 

516@echo off 

517set CURRENT_PATH=%WORKSPACE% 

518@echo ~SET CURRENT_PATH=%WORKSPACE% 

519set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27 

520set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

521@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

522if exist %virtual_env_py%_conda27vir rmdir /Q /S %virtual_env_py%_conda27vir 

523@echo ~CALL %jenkinspythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_conda27vir --clone %jenkinspythonexe%\\.. --offline 

524%jenkinspythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_conda27vir --clone %jenkinspythonexe%\\.. --offline 

525if %errorlevel% neq 0 exit /b %errorlevel% 

526set jenkinspythonexe=%virtual_env_py%_conda27vir\\python 

527@echo ~SET jenkinspythonexe=%virtual_env_py%_conda27vir\\python 

528set jenkinspythonpip=%virtual_env_py%_conda27vir\\Scripts\\pip 

529@echo ~SET jenkinspythonpip=%virtual_env_py%_conda27vir\\Scripts\\pip 

530""" + _second_part).replace("PY??", _sversion()) 

531 

532windows_jenkins_unittest27_def_header = """ 

533set CURRENT_PATH=%WORKSPACE% 

534@echo ~SET CURRENT_PATH=%WORKSPACE% 

535set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27 

536@echo set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27 

537if not exist %ROOT_VIRTUAL_ENV% mkdir %ROOT_VIRTUAL_ENV% 

538set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

539@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

540""" 

541 

542windows_jenkins_unittest27_def = (windows_jenkins_unittest27_def_header + """ 

543if exist %virtual_env_py%_vir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_vir%virtual_env_suffix% 

544mkdir %virtual_env_py%_vir%virtual_env_suffix% 

545 

546if exist %virtual_env_py%_vir%virtual_env_suffix%\\python goto with_virtual: 

547set KEEPPATH=%PATH% 

548@echo ~SET KEEPPATH=%PATH% 

549set PATH=%jenkinspythonexe%\\..;%PATH% 

550@echo ~SET PATH=%jenkinspythonexe%\\..;%PATH% 

551@echo ~CALL %jenkinspythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix% 

552%jenkinspythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix% 

553@echo ### VIRTUAL ENVIRONMENT CREATED in %virtual_env_py%_vir%virtual_env_suffix% 

554 

555@echo on 

556rem _PATH_VIRTUAL_ENV_ 

557@echo off 

558 

559:with_virtual: 

560@echo ~LABEL with_virtual 

561set jenkinspythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python 

562@echo ~SET jenkinspythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python 

563set jenkinspythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip 

564@echo ~SET jenkinspythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip 

565""" + _second_part).replace("PY??", _sversion()) 

566 

567windows_jenkins_27_conda = [ 

568 "set jenkinspythonexe=__DEFAULTPYTHON__\n@echo ~SET jenkinspythonexe=__DEFAULTPYTHON__\n" 

569 + "\n__PACTHPQb__\n" 

570 + jenkins_windows_setup + " build_script\n" 

571 + windows_error 

572 + "\n@echo ~CALL %jenkinspythonexe% %current%setup.py setup_hook\n%jenkinspythonexe% %current%setup.py setup_hook\n" 

573 + windows_error 

574 + "\nauto_setup_co + y27.bat %jenkinspythonexe%\n" + windows_error, 

575 # next script # 

576 "\n__PACTHPQe__\n" + 

577 "set jenkinspythonexe=__PYTHON27__\n@echo ~SET jenkinspythonexe=__PYTHON27__\n" + 

578 windows_jenkins_unittest27_conda + 

579 "\n\n__REQUIREMENTS__\n\n%jenkinspythonpip% freeze\n" + 

580 "\nauto_cmd_run27.bat %jenkinspythonexe%\n" + windows_error, 

581 # next script # 

582 "set jenkinspythonexe=__PYTHON27__\n@echo ~SET jenkinspythonexe=__PYTHON27__\n" + 

583 "set CURRENT_PATH=%WORKSPACE%\n@echo ~SET CURRENT_PATH=%WORKSPACE%\n" + 

584 "set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27\n" + 

585 "set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__\n@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__\n" + 

586 "set jenkinspythonexe=%virtual_env_py%_conda27vir\\python\n@echo + ~SET jenkinspythonexe=%virtual_env_py%_conda27vir\\python\n" 

587 "\nauto_cmd_build27.bat %jenkinspythonexe%\n" + windows_error, 

588 # next script # 

589 "copy dist_module27\\dist\\*.whl ..\\..\\local_pypi\\local_pypi_server"] 

590 

591windows_jenkins_27_def = [ 

592 "set jenkinspythonexe=__DEFAULTPYTHON__\n@echo ~SET jenkinspythonexe=__DEFAULTPYTHON__\n" + 

593 "\n__PACTHPQb__\n" + 

594 jenkins_windows_setup + " build_script\n" + 

595 windows_error + 

596 "\n@echo ~CALL %jenkinspythonexe% %current%setup.py setup_hook\n%jenkinspythonexe% %current%setup.py setup_hook\n" + 

597 windows_error + 

598 "\nauto_setup_copy27.bat %jenkinspythonexe%\n" + 

599 windows_error, 

600 # next script # 

601 "\n__PACTHPQe__\n" + 

602 "set localpythonexe=__PYTHON27__\n@echo ~SET jenkinspythonexe=__PYTHON27__\n" + 

603 "set jenkinspythonexe=__PYTHON27__\n@echo ~SET jenkinspythonexe=__PYTHON27__\n" + 

604 windows_jenkins_unittest27_def + 

605 "\n\n__REQUIREMENTS__\n\n" + 

606 "\n@echo if NOT EXIST %jenkinspythonexe%\\..\\nosetests.exe %jenkinspythonpip% install nose --upgrade --force\n" + 

607 "\nif NOT EXIST %jenkinspythonexe%\\..\\nosetests.exe %jenkinspythonpip% install nose --upgrade --force\n" + 

608 "\n@echo auto_cmd_run27.bat %jenkinspythonexe%\n\n@echo END RU + 27: %jenkinspythnexe%\n\n" + 

609 "\nauto_cmd_run27.bat %jenkinspythonexe%\n" + windows_error, 

610 # next script # 

611 windows_jenkins_unittest27_def_header + 

612 "set jenkinspythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python\n" + 

613 "@echo ~SET jenkinspythonexe=%virtual_env_py%_vir%virtual_env_su + fix%\\Scripts\\python\n" + 

614 "\nauto_cmd_build27.bat %jenkinspythonexe%\n" + windows_error, 

615 # next script # 

616 "copy dist_module27\\dist\\*.whl ..\\..\\local_pypi\\local_pypi_server"] 

617 

618################## 

619#: auto setup 

620################## 

621setup_script_dependency_py = """ 

622import sys 

623from distutils.core import setup, Extension 

624import distutils.sysconfig as SH 

625from setuptools import find_packages 

626 

627project_var_name = "dependencies___MODULE__" 

628versionPython = "%s.%s" % (sys.version_info.major, sys.version_info.minor) 

629path = "Lib/site-packages/" + project_var_name 

630 

631if "Anaconda" not in sys.version or sys.version_info[0] == 2: 

632 jup = ["IPython>=5.0.0", "jupyter"] 

633else: 

634 jup = [] 

635 

636setup( 

637 name=project_var_name, 

638 version=versionPython, 

639 install_requires=[ 

640 "autopep8", 

641 "codecov", 

642 "docutils", 

643 "matplotlib>=1.5.1", 

644 "numpy>=1.11.1", 

645 "sphinx>=1.4.5", 

646 "pandas>=0.18.1", 

647 "python-dateutil"] + jup, 

648) 

649""" 

650######################### 

651#: copy27 

652######################### 

653 

654copy_dist_to_local_pypi = """ 

655 

656set current=%~dp0 

657if EXIST %current%setup.py goto current_is_setup: 

658set current=%current%..\\ 

659cd .. 

660if EXIST %current%setup.py goto current_is_setup: 

661@echo Unable to find %current%setup.py 

662exit /b 1 

663 

664:current_is_setup: 

665@echo ~SET current=%current% 

666 

667@echo SCRIPT: copy_dist_to_local_pypi 

668if not exist ..\\..\\local_pypi mkdir ..\\..\\local_pypi 

669if not exist ..\\..\\local_pypi\\local_pypi_server mkdir ..\\..\\local_pypi\\local_pypi_server 

670copy /Y dist\\*.whl ..\\..\\local_pypi\\local_pypi_server 

671""" 

672 

673############### 

674#: blog post 

675############### 

676windows_blogpost = """ 

677@echo SCRIPT: windows_blogpost 

678%pythonexe% auto_rss_server.py 

679""" 

680 

681##################### 

682#: documentation server 

683##################### 

684windows_docserver = """ 

685@echo SCRIPT: windows_docserver 

686%pythonexe% auto_doc_server.py 

687""" 

688 

689######## 

690#: pyproj 

691######## 

692 

693pyproj_template = """ 

694<?xml version="1.0" encoding="utf-8"?> 

695<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> 

696 <PropertyGroup> 

697 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 

698 <SchemaVersion>2.0</SchemaVersion> 

699 <ProjectGuid>__GUID__</ProjectGuid> 

700 <ProjectHome>.</ProjectHome> 

701 <SearchPath> 

702 </SearchPath> 

703 <WorkingDirectory>.</WorkingDirectory> 

704 <OutputPath>.</OutputPath> 

705 <Name>__NAME__</Name> 

706 <RootNamespace>__NAME__</RootNamespace> 

707 </PropertyGroup> 

708 <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> 

709 <DebugSymbols>true</DebugSymbols> 

710 <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> 

711 </PropertyGroup> 

712 <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> 

713 <DebugSymbols>true</DebugSymbols> 

714 <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> 

715 </PropertyGroup> 

716 <ItemGroup> 

717__INCLUDEFILES__ 

718 </ItemGroup> 

719 <ItemGroup> 

720__INCLUDEFOLDERS__ 

721 </ItemGroup> 

722 <PropertyGroup> 

723 <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> 

724 <PtvsTargetsFile>$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\Python Tools\\Microsoft.PythonTools.targets</PtvsTargetsFile> 

725 </PropertyGroup> 

726 <Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" /> 

727 <Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\\Microsoft.Common.targets" /> 

728 <!-- Uncomment the CoreCompile target to enable the Build command in 

729 Visual Studio and specify your pre- and post-build commands in 

730 the BeforeBuild and AfterBuild targets below. --> 

731 <!--<Target Name="CoreCompile" />--> 

732 <Target Name="BeforeBuild"> 

733 </Target> 

734 <Target Name="AfterBuild"> 

735 </Target> 

736</Project> 

737"""