Skip to content
Snippets Groups Projects
Commit da193398 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Move PyPI deployment to twine

parent a47fdcb4
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash #!/usr/bin/env bash
# Thu 22 Sep 2016 13:59:03 CEST # Wed 11 Oct 2017 15:00:21 CEST
source $(dirname ${0})/functions.sh source $(dirname ${0})/functions.sh
...@@ -15,12 +15,9 @@ if [ "${VISIBILITY}" != "public" ]; then ...@@ -15,12 +15,9 @@ if [ "${VISIBILITY}" != "public" ]; then
exit 0 exit 0
fi fi
lock_pypirc
log_info "Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..." log_info "Uploading package to ${PYPISERVER} on behalf of ${PYPIUSER}..."
setup_deploy check sdist --formats zip upload --repository production twine register --username ${PYPIUSER} --password ${PYPIPASS} dist/*.zip
twine upload --username ${PYPIUSER} --password ${PYPIPASS} dist/*.zip
unlock_pypirc
condaforge_packages=("bob" \ condaforge_packages=("bob" \
"bob.buildout" \ "bob.buildout" \
......
...@@ -119,89 +119,6 @@ run_cmd() { ...@@ -119,89 +119,6 @@ run_cmd() {
} }
# Prepares ~/.pypirc
lock_pypirc() {
local lockfile=/var/tmp/pypirc_lock
local rc=${HOME}/.pypirc
local maxtries=10
local try=0
local sleeptime=30 #seconds
while true; do
if [[ ${try} -lt ${maxtries} ]]; then
((try++))
if ( set -o noclobber; echo "$$" > "${lockfile}") 2> /dev/null; then
log_info "Successfully acquired ${lockfile}"
echo $$ > ${lockfile}
log_info "trapping on ${lockfile}..."
trap 'rm -f "${lockfile}"; exit $?' INT TERM EXIT
# start: protected code
log_info "Creating ${rc}..."
if [ -e ${rc} ]; then
run_cmd rm -f ${rc}
fi
cat <<EOT >> ${rc}
[distutils]
index-servers =
production
staging
[production]
username: ${PYPIUSER}
password: ${PYPIPASS}
[staging]
repository: ${TESTSERVER}
username: ${PYPIUSER}
password: ${PYPIPASS}
EOT
run_cmd chmod 600 ${rc}
# end: protected code
break
else
log_warn "${lockfile} exists, owned by process $(cat $lockfile)"
log_info "Will retry after a ${sleeptime} seconds sleep (${try}/${maxtries})"
run_cmd sleep ${sleeptime}
fi
else
log_error "I already retried deploying ${try} times. Aborting..."
log_error "You can retry this step when less packages are building."
exit 1
fi
done
}
# Cleans ~/.pypirc, if the lock file belongs to us
unlock_pypirc() {
local lockfile=/var/tmp/pypirc_lock
local rc=${HOME}/.pypirc
# untrap if lock belongs to the running process
if [[ $(cat ${lockfile}) == $$ ]]; then
run_cmd rm -r ${lockfile}
run_cmd rm -rf ${rc}
log_info "$ trap - INT TERM EXIT"
trap - INT TERM EXIT
fi
}
# Runs setup.py in a deployment context. If fails, tries to unlock
# the ${HOME}/.pypirc file lock
setup_deploy() {
log_info "$ ${@}"
${PREFIX}/bin/python setup.py ${@}
local status=$?
if [ ${status} != 0 ]; then
log_error "Command Failed \"${@}\""
unlock_pypirc #just tries
exit ${status}
fi
}
# Uploads a file to our intranet location via curl # Uploads a file to our intranet location via curl
# $1: Path to the file to upload (e.g. dist/myfile.whl) # $1: Path to the file to upload (e.g. dist/myfile.whl)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/) # $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
...@@ -414,8 +331,6 @@ if [ -z "${PREFIX}" ]; then ...@@ -414,8 +331,6 @@ if [ -z "${PREFIX}" ]; then
PREFIX=${CI_PROJECT_DIR}/build-prefix PREFIX=${CI_PROJECT_DIR}/build-prefix
fi fi
TESTSERVER=https://testpypi.python.org/legacy/
check_env OSNAME check_env OSNAME
check_env VISIBILITY check_env VISIBILITY
check_env IS_MASTER check_env IS_MASTER
...@@ -423,7 +338,6 @@ check_env PYVER ...@@ -423,7 +338,6 @@ check_env PYVER
check_env PREFIX check_env PREFIX
export_env PREFIX export_env PREFIX
check_env DOCSERVER check_env DOCSERVER
check_env TESTSERVER
check_env CONDA_FOLDER check_env CONDA_FOLDER
check_env CONDA_ENV check_env CONDA_ENV
export_env BOB_PREFIX_PATH export_env BOB_PREFIX_PATH
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment