CircleCI + Pypi deploy

Hello. I’m trying to upload my python project to a private pypi after the build is successful for tags or branches. I couldn’t find anything in the documentation about it. Is this possible? How?

Thanks in advance!

Not sure there is a separate article about that, subject is too specific to cover in general documentation from my perspective.

We do use Circle standard stages to do the package build, for 1.0 it looks like:

    branch: master
      - ./

for 2.0 it is something like:

      - type: deploy
        name: Build Package
        command: ./

Where is something like:

#!/usr/bin/env bash

if [ -z "$CI" ]; then
    echo "Will only continue on CI"

if [[ $CIRCLE_BRANCH != "master" ]]; then
    echo "Will only continue for master builds"

# build package and upload to private pypi index
echo "[distutils]" >> ~/.pypirc
echo "index-servers = pypi-private" >> ~/.pypirc
echo "[pypi-private]" >> ~/.pypirc
echo "repository=https://$PYPI_HOST" >> ~/.pypirc
echo "username=$PYPI_USERNAME" >> ~/.pypirc
echo "password=$PYPI_PASSWORD" >> ~/.pypirc

python sdist upload -r pypi-private

Of course in this setup you have to specify PYPI_HOST, PYPI_USERNAME and PYPI_PASSWORD in your circle.yml environment variables section.