diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index d22ba67..619e924 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -11,7 +11,7 @@ __author__ = "Davide Testa" __email__ = "davide@davte.it" __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __license__ = "GNU General Public License v3.0" -__version__ = "2.10.12" +__version__ = "2.10.13" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/update_package.sh b/update_package.sh index 8e4a23f..92a2dbe 100755 --- a/update_package.sh +++ b/update_package.sh @@ -1,24 +1,56 @@ #!/bin/bash +set -e # Get current directory this_script_directory=$(cd "$(dirname "$0")" && pwd) -packenv=""; -# Python virtual environment directory: packenv variable in my_config.sh -source "$this_script_directory"/my_config.sh; +# Python virtual environment directory +packenv="" -# Ensure the success of importing procedure -if [ -z "${packenv}" ]; -then - printf "Please set in ""my_config.sh"" the path to bot python virtual environment\n\nExample:\npackenv=""path/to/virtual/env""\n"; - exit; +# shellcheck disable=SC1091 +source "${this_script_directory}/my_config.sh" + +# Validate configuration +if [ -z "$packenv" ]; then + printf 'Please set "packenv" in my_config.sh\n\nExample:\npackenv="path/to/virtual/env"\n' + exit 1 fi -# Push, build and publish package to pypi.org -bash "$this_script_directory"/push_to_remotes.sh; -rm -rf "$this_script_directory/build"; -rm -rf "$this_script_directory/dist"; -rm -rf "$this_script_directory/davtelepot.egg-info"; -"$packenv"/python setup.py sdist; -"$packenv"/pip wheel --no-index --no-deps --wheel-dir dist dist/*.tar.gz; -"$packenv"/twine upload --skip-existing dist/*; +# Validate virtual environment +if [ ! -x "${packenv}/bin/python" ]; then + echo "Python executable not found: ${packenv}/bin/python" + exit 1 +fi + +python="${packenv}/bin/python" +twine="${packenv}/bin/twine" + +if [ ! -x "$twine" ]; then + echo "Twine not found. Install it with: ${python} -m pip install twine" + exit 1 +fi + +# Push changes to remotes +bash "$this_script_directory/push_to_remotes.sh" + +# Clean previous builds +rm -rf + "$this_script_directory/build" + "$this_script_directory/dist" + "$this_script_directory/davtelepot.egg-info" + +cd "$this_script_directory" || exit 1 + +# Build source distribution +"${python}" setup.py sdist + +# Build wheel using locally installed build dependencies +"${python}" -m pip wheel \ + --no-index \ + --no-deps \ + --no-build-isolation \ + --wheel-dir dist \ + dist/*.tar.gz + +# Publish to PyPI +"${twine}" upload --skip-existing dist/*