@@ -302,7 +302,7 @@ get_package_info() {
302302
303303install_python_dev_deps () {
304304 if [ -n " ${VIRTUAL_ENV} " ] || [ -n " ${CONDA_PREFIX} " ]; then
305- run_command ${MONAI_PY_EXE} -m pip install -q -U setuptools pip wheel
305+ run_command ${MONAI_PY_EXE} -m pip install -q -U setuptools pip wheel build
306306 run_command ${MONAI_PY_EXE} -m pip install -q -r ${TOP} /requirements-dev.txt
307307 run_command ${MONAI_PY_EXE} -m pip install -q -r ${TOP} /requirements-examples.txt
308308
@@ -380,8 +380,49 @@ clean_desc() { c_echo 'Clean up temporary files and uninstall monai-deploy-app-s
380380'
381381}
382382clean () {
383- c_echo W ' Cleaning up temporary files and run "' " ${MONAI_PY_EXE} " ' setup.py develop --uninstall "...'
383+ c_echo W ' Cleaning up temporary files and run "' " ${MONAI_PY_EXE} " ' -m pip uninstall monai-deploy-app-sdk "...'
384384
385+ # Remove coverage history
386+ run_command rm -f junit-monai-deploy-app-sdk.xml monai-deploy-app-sdk-coverage.xml
387+
388+ # Uninstall the development package
389+ if [ -n " ${VIRTUAL_ENV} " ] || [ -n " ${CONDA_PREFIX} " ]; then
390+ c_echo W " Uninstalling MONAI Deploy App SDK installation..."
391+ run_command ${MONAI_PY_EXE} -m pip uninstall monai-deploy-app-sdk
392+ fi
393+
394+ # Remove temporary files (in the directory of this script)
395+ c_echo W " Removing temporary files in ${TOP} "
396+ run_command find ${TOP} /monai -type f -name " *.py[co]" -delete
397+ run_command find ${TOP} /monai -type f -name " *.so" -delete
398+ run_command find ${TOP} /monai -type d -name " __pycache__" -delete
399+
400+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " monai_deploy_app_sdk.egg-info" -exec rm -r " {}" +
401+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " build" -exec rm -r " {}" +
402+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " dist" -exec rm -r " {}" +
403+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " .mypy_cache" -exec rm -r " {}" +
404+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " .pytype" -exec rm -r " {}" +
405+ run_command find ${TOP} -depth -maxdepth 1 -type d -name " __pycache__" -exec rm -r " {}" +
406+ }
407+
408+ build_desc () { c_echo ' Build distribution package
409+
410+ Build a distribution package for this SDK using
411+ "build" (https://pypa-build.readthedocs.io/en/stable/index.html).
412+
413+ Arguements:
414+ $1 - destination folder (default: ${TOP}/dist)
415+ '
416+ }
417+ build () {
418+ local dest_path=" ${1:- ${TOP} / dist} "
419+ install_python_dev_deps
420+
421+ run_command rm -rf ${dest_path} /monai-deploy-app-sdk-* .gz ${dest_path} /monai_deploy_app_sdk-* .whl
422+
423+ # Somehow, 'build' package causes an issue without `PIP_NO_CACHE_DIR=off` at Python 3.6 (with pyenv)
424+ # (https://github.com/pypa/pip/issues/2897)
425+ PIP_NO_CACHE_DIR=off run_command ${MONAI_PY_EXE} -m build -o " ${dest_path} "
385426}
386427
387428# ==================================================================================
@@ -834,7 +875,7 @@ test_python() {
834875
835876install_doc_requirements () {
836877 if [ -n " ${VIRTUAL_ENV} " ] || [ -n " ${CONDA_PREFIX} " ]; then
837- run_command ${MONAI_PY_EXE} -m pip install -q -U setuptools pip wheel
878+ run_command ${MONAI_PY_EXE} -m pip install -q -U setuptools pip wheel build
838879 run_command ${MONAI_PY_EXE} -m pip install -q -r ${TOP} /docs/requirements.txt
839880 install_edit_mode
840881 else
@@ -981,6 +1022,74 @@ clean_docs() {
9811022# Section: Release
9821023# ==================================================================================
9831024
1025+ bump_version_desc () { c_echo ' Bump version
1026+
1027+ Executes bump2version(https://github.com/c4urself/bump2version).
1028+ `bump2version` package would be installed if not available.
1029+
1030+ <part>
1031+ - major : a non-negative integer
1032+ - minor : a non-negative integer
1033+ - patch : a non-negative integer
1034+ - release : "a", "b" or "rc"
1035+ - build : a positive integer
1036+
1037+ e.g.)
1038+ 0.1.0a1
1039+ major : 0
1040+ minor : 1
1041+ patch : 0
1042+ release : a
1043+ build : 1
1044+
1045+ Examples:
1046+ ./run bump_version build # 0.1.0a1 -> 0.1.0a2
1047+ ./run bump_version release # 0.1.0a1 -> 0.1.0b1
1048+ ./run bump_version patch # 0.1.0a1 -> 0.1.1
1049+ ./run bump_version minor # 0.1.0a1 -> 0.2.0
1050+
1051+ Arguments:
1052+ $1 - part (major, minor, patch, release, build)
1053+ $@ - additional arguments for bump2version
1054+
1055+ Returns:
1056+ Outputs executed by bump2version
1057+
1058+ Exit code:
1059+ exit code returned from bump2version
1060+ '
1061+ }
1062+ bump_version () {
1063+ local part=${1:- }
1064+ local ret=0
1065+
1066+ if ! command -v bump2version > /dev/null; then
1067+ c_echo G " bump2version" W " doesn't exists. Installing prerequisites..."
1068+ install_python_dev_deps
1069+ fi
1070+
1071+ pushd $TOP > /dev/null
1072+
1073+ case " $part " in
1074+ major|minor|patch|release|build)
1075+ local current_version=" $( bump2version --dry-run --list --allow-dirty $part | grep -Po ' current_version=\K[\d\.]+((a|b|rc)\d+)?' ) "
1076+ local new_version=" $( bump2version --dry-run --list --allow-dirty $part | grep -Po ' new_version=\K[\d\.]+((a|b|rc)\d+)?' ) "
1077+ c_echo W " current_version=" G " ${current_version} "
1078+ c_echo W " new_version=" G " ${new_version} "
1079+
1080+ bump2version " $@ "
1081+ ret=$?
1082+ ;;
1083+ * )
1084+ bump2version " $@ "
1085+ ret=$?
1086+ ;;
1087+ esac
1088+
1089+ popd > /dev/null
1090+
1091+ return $ret
1092+ }
9841093
9851094# ==================================================================================
9861095
0 commit comments