Coverage for pyquickhelper/pycode/windows_scripts.py: 100%

32 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-03 02:21 +0200

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#: build script for Windows 

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

263 

264windows_any_setup_command = windows_any_setup_command_base + """ 

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

266rem set PYTHONPATH=additional_path 

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

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

269@echo #######################################################6 

270""" + copy_to_pypiserver 

271 

272################# 

273#: call the setup 

274################# 

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

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

277 

278################# 

279#: build setup script for Windows 

280################# 

281 

282windows_build_setup = windows_any_setup_command_base + """ 

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

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

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

286pushd %current% 

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

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

289popd 

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

291""" + copy_to_pypiserver 

292 

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

294#: build script MAIN SCRIPT 

295################# 

296windows_build = windows_any_setup_command_base + """ 

297@echo #######################################################_unit 

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

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

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

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

302@echo #######################################################6 

303 

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

305%pythonexe% %current%setup.py clean_pyd 

306pushd %current% 

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

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

309popd 

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

311pushd %current% 

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

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

314popd 

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

316pushd %current% 

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

318%pythonexe% %current%setup.py bdist_msi 

319popd 

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

321pushd %current% 

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

323%pythonexe% %current%setup.py bdist_wheel 

324popd 

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

326@echo #######################################################7 

327 

328:documentation: 

329@echo ~LABEL documentation 

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

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

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

333@echo #######################################################8 

334 

335:copyfiles: 

336@echo ~LABEL copyfiles 

337if not exist dist\\html mkdir dist\\html 

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

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

340@echo ~COPY chm 

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

342@echo ~COPY pdf 

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

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

345 

346:end: 

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

348 

349################# 

350#: build script for Windows BASE + virtual environment 

351################# 

352 

353copy_sphinx_to_dist = """ 

354@echo SCRIPT: copy_sphinx_to_dist 

355if not exist dist\\html mkdir dist\\html 

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

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

358@echo ~COPY chm 

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

360@echo ~COPY pdf 

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

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

363""" 

364 

365################# 

366#: notebooks 

367################# 

368windows_notebook = """ 

369@echo off 

370@echo SCRIPT: windows_notebook 

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

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

373set pythonexe=%1 

374goto nextn: 

375 

376:default_value: 

377@echo ~LABEL default_value 

378set pythonexe=__PY??_X64__ 

379@echo ~SET pythonexe=__PY??_X64__ 

380 

381:nextn: 

382@echo ~LABEL nextn 

383set current=%~dp0 

384 

385set current=%~dp0 

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

387set current=%current%..\\ 

388cd .. 

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

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

391exit /b 1 

392 

393:current_is_setup: 

394@echo ~SET current=%current% 

395 

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

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

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

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

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

401@echo on 

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

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

404 

405################# 

406#: publish a module 

407################# 

408windows_publish = """ 

409@echo SCRIPT: windows_publish 

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

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

412pushd %current% 

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

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

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

416set /P NVERSION=< version.txt 

417git tag v%NVERSION% 

418git push origin v%NVERSION% 

419popd 

420""" 

421 

422################# 

423#: publish the documentation 

424################# 

425windows_publish_doc = """ 

426@echo SCRIPT: windows_publish_doc 

427pushd %current% 

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

429popd 

430""" 

431 

432################# 

433#: run a pypi server 

434################# 

435windows_pypi = """ 

436@echo SCRIPT: windows_pypi 

437set pythonexe=__PY??_X64__ 

438@echo ~SET pythonexe=__PY??_X64__ 

439 

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

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

442set portpy=%2 

443@echo ~SET portpy=%2 

444goto run: 

445 

446:default_port: 

447@echo ~LABEL default_port 

448set portpy=__PORT__ 

449@echo ~SET portpy=__PORT__ 

450 

451:run: 

452@echo ~LABEL run 

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

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

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

456 

457################# 

458#: script for Jenkins 

459################# 

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

461 "\n__PACTHPQb__\n" + \ 

462 jenkins_windows_setup + " build_script\n" + \ 

463 "\n__PACTHPQe__\n" + \ 

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

465 windows_error 

466 

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

468 "\n__PACTHPQb__\n" + \ 

469 jenkins_windows_setup + " build_script\n" + \ 

470 "\n__PACTHPQe__\n" + \ 

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

472 windows_error 

473 

474#################### 

475#: script for Jenkins 27 

476#################### 

477 

478_second_part = """ 

479@echo SCRIPT: _second_part 

480:requirements: 

481@echo ~LABEL requirements 

482@echo #######################################################_auto_setup_dep.py 

483cd build\\auto_setup 

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

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

486if exist %pythonexe_rel% goto auto_setup_relpath: 

487set pythonexe_rel=%jenkinspythonexe% 

488@echo ~SET pythonexe_rel=%jenkinspythonexe% 

489 

490:auto_setup_relpath: 

491@echo ~LABEL auto_setup_relpath 

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

493%pythonexe_rel% auto_setup_dep.py install 

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

495cd ..\\.. 

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

497 

498@echo #######################################################_requirements_begin 

499echo ~SET %jenkinspythonpip% 

500""" 

501 

502windows_jenkins_unittest27_conda = (""" 

503@echo off 

504set CURRENT_PATH=%WORKSPACE% 

505@echo ~SET CURRENT_PATH=%WORKSPACE% 

506set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27 

507set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

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

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

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

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

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

513set jenkinspythonexe=%virtual_env_py%_conda27vir\\python 

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

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

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

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

518 

519windows_jenkins_unittest27_def_header = """ 

520set CURRENT_PATH=%WORKSPACE% 

521@echo ~SET CURRENT_PATH=%WORKSPACE% 

522set ROOT_VIRTUAL_ENV=%CURRENT_PATH%\\_virtualenv27 

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

524if not exist %ROOT_VIRTUAL_ENV% mkdir %ROOT_VIRTUAL_ENV% 

525set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__ 

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

527""" 

528 

529windows_jenkins_unittest27_def = (windows_jenkins_unittest27_def_header + """ 

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

531mkdir %virtual_env_py%_vir%virtual_env_suffix% 

532 

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

534set KEEPPATH=%PATH% 

535@echo ~SET KEEPPATH=%PATH% 

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

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

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

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

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

541 

542@echo on 

543rem _PATH_VIRTUAL_ENV_ 

544@echo off 

545 

546:with_virtual: 

547@echo ~LABEL with_virtual 

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

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

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

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

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

553 

554windows_jenkins_27_conda = [ 

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

556 + "\n__PACTHPQb__\n" 

557 + jenkins_windows_setup + " build_script\n" 

558 + windows_error 

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

560 # next script # 

561 "\n__PACTHPQe__\n" + 

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

563 windows_jenkins_unittest27_conda + 

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

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

566 # next script # 

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

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

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

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

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

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

573 # next script # 

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

575 

576windows_jenkins_27_def = [ 

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

578 "\n__PACTHPQb__\n" + 

579 jenkins_windows_setup + " build_script\n" + 

580 windows_error + 

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

582 windows_error, 

583 # next script # 

584 "\n__PACTHPQe__\n" + 

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

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

587 windows_jenkins_unittest27_def + 

588 "\n\n__REQUIREMENTS__\n\n" + 

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

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

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

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

593 # next script # 

594 windows_jenkins_unittest27_def_header + 

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

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

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

598 # next script # 

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

600 

601################## 

602#: auto setup 

603################## 

604setup_script_dependency_py = """ 

605import sys 

606from distutils.core import setup, Extension 

607import distutils.sysconfig as SH 

608from setuptools import find_packages 

609 

610project_var_name = "dependencies___MODULE__" 

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

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

613 

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

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

616else: 

617 jup = [] 

618 

619setup( 

620 name=project_var_name, 

621 version=versionPython, 

622 install_requires=[ 

623 "autopep8", 

624 "codecov", 

625 "docutils", 

626 "matplotlib>=1.5.1", 

627 "numpy>=1.11.1", 

628 "sphinx>=1.4.5", 

629 "pandas>=0.18.1", 

630 "python-dateutil"] + jup, 

631) 

632""" 

633######################### 

634#: copy27 

635######################### 

636 

637copy_dist_to_local_pypi = """ 

638 

639set current=%~dp0 

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

641set current=%current%..\\ 

642cd .. 

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

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

645exit /b 1 

646 

647:current_is_setup: 

648@echo ~SET current=%current% 

649 

650@echo SCRIPT: copy_dist_to_local_pypi 

651if not exist ..\\..\\local_pypi mkdir ..\\..\\local_pypi 

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

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

654""" 

655 

656############### 

657#: blog post 

658############### 

659windows_blogpost = """ 

660@echo SCRIPT: windows_blogpost 

661%pythonexe% auto_rss_server.py 

662""" 

663 

664##################### 

665#: documentation server 

666##################### 

667windows_docserver = """ 

668@echo SCRIPT: windows_docserver 

669%pythonexe% auto_doc_server.py 

670""" 

671 

672######## 

673#: pyproj 

674######## 

675 

676pyproj_template = """ 

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

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

679 <PropertyGroup> 

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

681 <SchemaVersion>2.0</SchemaVersion> 

682 <ProjectGuid>__GUID__</ProjectGuid> 

683 <ProjectHome>.</ProjectHome> 

684 <SearchPath> 

685 </SearchPath> 

686 <WorkingDirectory>.</WorkingDirectory> 

687 <OutputPath>.</OutputPath> 

688 <Name>__NAME__</Name> 

689 <RootNamespace>__NAME__</RootNamespace> 

690 </PropertyGroup> 

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

692 <DebugSymbols>true</DebugSymbols> 

693 <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> 

694 </PropertyGroup> 

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

696 <DebugSymbols>true</DebugSymbols> 

697 <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> 

698 </PropertyGroup> 

699 <ItemGroup> 

700__INCLUDEFILES__ 

701 </ItemGroup> 

702 <ItemGroup> 

703__INCLUDEFOLDERS__ 

704 </ItemGroup> 

705 <PropertyGroup> 

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

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

708 </PropertyGroup> 

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

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

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

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

713 the BeforeBuild and AfterBuild targets below. --> 

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

715 <Target Name="BeforeBuild"> 

716 </Target> 

717 <Target Name="AfterBuild"> 

718 </Target> 

719</Project> 

720"""