Skip to content

Commit

Permalink
This commit fixes the release/deploy script (#987)
Browse files Browse the repository at this point in the history
Before it was not possible to execute this script without errors as
the conda update was broken. I moved the activation of the conda
env to `conda run` which is apparently the recommended way.
  • Loading branch information
ottonemo committed Jun 27, 2023
1 parent 468a9c6 commit 8a1fd6d
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
set -e
set -eu
set -o pipefail

PYTORCH_VERSION=${PYTORCH_VERSION:-""}
PYTHON_VERSION="3.9"
TWINE_VERSION=">3,<4.0.0dev"
TWINE_VERSION="\>3,\<4.0.0dev" # escaped <,> are necessary for conda run
CONDA_ENV="skorch-deploy"

if [[ $# -gt 1 ]] || [[ $1 != "live" && $1 != "stage" ]]; then
Expand All @@ -19,7 +20,8 @@ fi
# check if worktree is not dirty, see https://stackoverflow.com/a/5737794
test -z "$(git status --porcelain --untracked-files=no)"

conda update -q -y conda
# make sure that conda is up-to-date
conda update -n base -c defaults -q -y conda

# Remove previous deploy environment
set +e
Expand All @@ -30,7 +32,6 @@ echo "creating empty conda env"
conda create -y -q -n $CONDA_ENV python=$PYTHON_VERSION

remove_env() {
source deactivate
conda env remove -q -y -n $CONDA_ENV
if [ -d build ]; then
rm -rf build
Expand All @@ -40,30 +41,34 @@ remove_env() {
fi
}

run_in_env() {
# shellcheck disable=SC2068
conda run -n "$CONDA_ENV" --no-capture-output $@
}

trap remove_env EXIT

source activate $CONDA_ENV
echo "installing dependencies"
conda install -c pytorch -y "pytorch==${PYTORCH_VERSION}"
python -m pip install "twine${TWINE_VERSION}"
run_in_env python -m pip install "twine${TWINE_VERSION}"
# Workaround for error `AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'`
# due to outdated system pyOpenSSL - see also: https://askubuntu.com/q/1428181
python -m pip install pyOpenSSL --upgrade
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
python -m pip install .
python -m pip list
run_in_env python -m pip install pyOpenSSL --upgrade
run_in_env python -m pip install -r requirements.txt
run_in_env python -m pip install -r requirements-dev.txt
run_in_env python -m pip install .
run_in_env python -m pip list

pytest -x
run_in_env pytest -x

# check if README can be rendered correctly on PyPI
python -m pip install readme-renderer
python -m readme_renderer README.rst > /dev/null
run_in_env python -m pip install readme-renderer
run_in_env python -m readme_renderer README.rst > /dev/null

python setup.py sdist bdist_wheel
run_in_env python setup.py sdist bdist_wheel

if [[ $1 == "live" ]]; then
twine upload dist/*$(cat VERSION)*
run_in_env twine upload dist/*"$(cat VERSION)"*
else
twine upload --repository-url https://test.pypi.org/legacy/ dist/*$(cat VERSION)*
run_in_env twine upload --repository-url https://test.pypi.org/legacy/ dist/*"$(cat VERSION)"*
fi

0 comments on commit 8a1fd6d

Please sign in to comment.