Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing conflicts when deploying multiple distros to PyPI using Travis-CI

Tags:

pypi

travis-ci

I'd like Travis CI to build and deploy the following artefacts to PyPI whenever a new commit hits the master branch:

  • Python 2 wheel
  • Python 3 wheel
  • Source

To make this happen, I've added the following to .travis.yml:

language: python
python:
  - '2.7'
  - '3.5'
  - '3.6'
deploy:
  on:
    branch: master
  provider: pypi
  distribution: bdist_wheel sdist

For normal build/test, the configuration works great. However, it introduces a race condition when deploying to PyPI:

Uploading distributions to https://upload.pypi.org/legacy/
Uploading PyOTA-2.0.0b1.tar.gz
HTTPError: 400 Client Error: File already exists. for url: https://upload.pypi.org/legacy/

What changes should I make to .travis.yml to get Travis CI to deploy the correct artefacts to PyPI?

like image 741
todofixthis Avatar asked Sep 24 '17 06:09

todofixthis


2 Answers

I ran into this problem today and eventually found this under-documented gem:

deploy:
  provider: pypi
  skip_existing: true
  ...

I use skip_existing: true on a project to get source and wheels published once even though I test across a couple of different configurations and python versions. Handy. More details in this resolved github issue. I also submitted a documentation diff.

like image 84
user2076663 Avatar answered Oct 22 '22 14:10

user2076663


Some days I think outside the box; other days it's just a really big box.

Previously, this project needed separate wheels for Python 2 and Python 3, so I needed Travis CI to build wheels using different versions of Python.

But recently I got the project to build universal wheels correctly, so now Travis can build all of the deployment artefacts using any one version of Python.

I modified .travis.yml accordingly, and everything is working great:

deploy:
  on:
    branch: master
    python: '3.6'
like image 20
todofixthis Avatar answered Oct 22 '22 14:10

todofixthis