Skip to content

Commit 56e1a12

Browse files
committed
Build/deploy/... scripts: code cleaning/refactoring
1 parent e6a7471 commit 56e1a12

File tree

9 files changed

+112
-34
lines changed

9 files changed

+112
-34
lines changed

qwt/tests/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,9 @@ def run(wait=True):
321321
test_env = TestEnvironment()
322322
if test_env.screenshots:
323323
print("Running PythonQwt tests and taking screenshots automatically:")
324-
print("-------------------------------------------------------------")
325324
QC.QTimer.singleShot(100, lambda: take_screenshot(launcher))
326325
elif test_env.unattended:
327326
print("Running PythonQwt tests in unattended mode:")
328-
print("-------------------------------------------")
329327
QC.QTimer.singleShot(0, QW.QApplication.instance().quit)
330328
app.exec_()
331329
launcher.close()

scripts/build_and_upload.bat

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
@echo off
2+
REM ======================================================
3+
REM Package build and upload script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
9+
call %~dp0utils GetScriptPath SCRIPTPATH
210
set UNATTENDED=1
3-
call %~dp0build_doc.bat
4-
call %~dp0build_dist.bat
11+
call %SCRIPTPATH%\build_doc.bat
12+
call %SCRIPTPATH%\build_dist.bat
513
@echo:
614
@echo ==============================================================================
715
choice /t 5 /c yn /cs /d n /m "Do you want to upload packages to PyPI (y/n)?"
@@ -10,7 +18,7 @@ if errorlevel 1 goto :yes
1018
:yes
1119
@echo ==============================================================================
1220
@echo:
13-
cd %~dp0..
21+
cd %SCRIPTPATH%\..
1422
twine upload dist/*
1523
GOTO :continue
1624
:no

scripts/build_dist.bat

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
@echo off
2-
cd %~dp0..\
2+
REM ======================================================
3+
REM Package build script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
9+
call %~dp0utils GetScriptPath SCRIPTPATH
10+
call %FUNC% GetLibName LIBNAME
11+
cd %SCRIPTPATH%\..\
312
if exist MANIFEST ( del /q MANIFEST )
413
if exist build ( rmdir /s /q build )
514
if exist dist ( rmdir /s /q dist )
6-
call %~dp0func SetPythonPath
7-
call %~dp0func UseWinPython
15+
call %FUNC% SetPythonPath
16+
call %FUNC% UseWinPython
817
python setup.py sdist bdist_wheel --universal
918
python setup.py build sdist
10-
call %~dp0func EndOfScript
19+
rmdir /s /q %LIBNAME%.egg-info
20+
call %FUNC% EndOfScript

scripts/build_doc.bat

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
@echo off
2-
call %~dp0func SetPythonPath
3-
call %~dp0func UseWinPython
2+
REM ======================================================
3+
REM Documentation build script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
9+
call %~dp0utils GetScriptPath SCRIPTPATH
10+
call %FUNC% GetLibName LIBNAME
11+
call %FUNC% SetPythonPath
12+
call %FUNC% UseWinPython
413
set PATH=C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip;C:\Program Files\HTML Help Workshop;C:\Program Files (x86)\HTML Help Workshop;%PATH%
5-
cd %~dp0..\
14+
cd %SCRIPTPATH%\..\
615
sphinx-build -b htmlhelp doc build\doc
7-
hhc build\doc\PythonQwt.hhp
8-
copy /y build\doc\PythonQwt.chm doc\_downloads
9-
7z a doc\_downloads\PythonQwt.chm.zip doc\_downloads\PythonQwt.chm
10-
move /y doc\PythonQwt.chm .
16+
hhc build\doc\%LIBNAME%.hhp
17+
copy /y build\doc\%LIBNAME%.chm doc\_downloads
18+
7z a doc\_downloads\%LIBNAME%.chm.zip doc\_downloads\%LIBNAME%.chm
19+
move /y doc\%LIBNAME%.chm .
1120
sphinx-build -b html doc build\doc
12-
call %~dp0func EndOfScript
21+
call %FUNC% EndOfScript

scripts/run_test_launcher.bat

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
@echo off
2+
REM ======================================================
3+
REM Test launcher script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
29
setlocal
3-
call %~dp0func SetPythonPath
4-
call %~dp0func UseWinPython
10+
call %~dp0utils GetScriptPath SCRIPTPATH
11+
call %FUNC% SetPythonPath
12+
call %FUNC% UseWinPython
513
python -m qwt.tests.__init__
6-
call %~dp0func EndOfScript
14+
call %FUNC% EndOfScript

scripts/run_test_venv.bat

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
@echo off
2+
REM ======================================================
3+
REM Virtual environment test script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
29
setlocal
10+
call %~dp0utils GetScriptPath SCRIPTPATH
311
set UNATTENDED=1
4-
call %~dp0build_dist
12+
call %SCRIPTPATH%\build_dist
513
set PYTHONPATH=
6-
call %~dp0func UseWinPython
14+
call %FUNC% UseWinPython
715
call :TestEnv PyQt5
816
call :TestEnv PySide2
917
set UNATTENDED=
10-
call %~dp0func EndOfScript
18+
call %FUNC% EndOfScript
1119
exit /B %ERRORLEVEL%
1220

1321
:TestEnv
14-
call %~dp0func ShowTitle "Testing in %~1-based Python virtual environment"
15-
set VENVPATH=cd %~dp0..\build\testenv
22+
call %FUNC% GetLibName LIBNAME
23+
call %FUNC% ShowTitle "Testing in %~1-based Python virtual environment"
24+
set VENVPATH=%SCRIPTPATH%\..\build\testenv
1625
python -m venv %VENVPATH%
1726
call %VENVPATH%\Scripts\activate
27+
python -m pip install --upgrade pip
1828
pip install %~1
19-
for %%f IN ("%~dp0..\dist\PythonQwt-*.whl") DO ( pip install %%f )
20-
call %VENVPATH%\Scripts\PythonQwt-tests-py3 --mode unattended
29+
for %%f IN ("%SCRIPTPATH%\..\dist\%LIBNAME%-*.whl") DO ( pip install %%f )
30+
call %VENVPATH%\Scripts\%LIBNAME%-tests-py3 --mode unattended
2131
call %VENVPATH%\Scripts\deactivate
2232
exit /B 0

scripts/run_unattended_tests.bat

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
@echo off
2+
REM ======================================================
3+
REM Unattended test script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
29
setlocal
3-
call %~dp0func SetPythonPath
4-
cd %~dp0..\
10+
call %~dp0utils GetScriptPath SCRIPTPATH
11+
call %FUNC% SetPythonPath
12+
cd %SCRIPTPATH%\..\
513

614
if not defined WINPYDIRBASE ( goto :no )
715
choice /t 5 /c yn /cs /d n /m "Do you want to run tests only from %WINPYDIRBASE% (y/n)?"

scripts/take_screenshots.bat

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
@echo off
2+
REM ======================================================
3+
REM Screenshots update script
4+
REM ======================================================
5+
REM Licensed under the terms of the MIT License
6+
REM Copyright (c) 2020 Pierre Raybaut
7+
REM (see LICENSE file for more details)
8+
REM ======================================================
29
setlocal
3-
call %~dp0func SetPythonPath
4-
call %~dp0func UseWinPython
5-
cd %~dp0..\
10+
call %~dp0utils GetScriptPath SCRIPTPATH
11+
call %FUNC% SetPythonPath
12+
call %FUNC% UseWinPython
13+
cd %SCRIPTPATH%\..\
614
python qwt/tests/__init__.py --mode screenshots
7-
call %~dp0func EndOfScript
15+
call %FUNC% EndOfScript

scripts/func.bat renamed to scripts/utils.bat

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
REM Utilities for deployment, test and build scripts
21
@echo off
2+
set FUNC=%0
33
call:%*
44
goto Exit
55

6+
REM ======================================================
7+
REM Utilities for deployment, test and build scripts
8+
REM ======================================================
9+
REM Licensed under the terms of the MIT License
10+
REM Copyright (c) 2020 Pierre Raybaut
11+
REM (see LICENSE file for more details)
12+
REM ======================================================
13+
14+
:GetScriptPath
15+
set _tmp_=%~dp0
16+
if %_tmp_:~-1%==\ set %1=%_tmp_:~0,-1%
17+
EXIT /B 0
18+
19+
:GetLibName
20+
pushd %~dp0..
21+
for %%I in (.) do set %1=%%~nxI
22+
popd
23+
goto:eof
24+
625
:SetPythonPath
726
set PYTHONPATH=%~dp0..
827
goto:eof

0 commit comments

Comments
 (0)