Search code examples
travis-cipypi

Can I use secure Travis env variables in .travis.yml to upload to PyPI?


I am trying to have Travis to upload to PyPI using the following configuration

deploy:
  provider: pypi
  user: P403n1x87
  password: $PYPI_PASSWORD
  distributions: "sdist bdist_wheel"
  on:
    tags: true

However, the upload fails with

HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://upload.pypi.org/legacy/

The variable PYPI_PASSWORD is defined as a secure env variable for the repository on Travis. The official Travis documentation instructs to use travis-encrypt and to put the result in the secure property under password:.

Is my alternative method not valid at all? Is there an alternative that involves the use of env variables?


Solution

  • It turns out that the method I have used works fine. My password contains characters that need to be escaped since they are fed directly to bash.