Poetry Uploads

python poetry packaging

Uploading Packages to PyPi With Poetry

Setting a pypi repository token:

  1. create a token on pypi. Create a specific token for each package.

  2. copy the token and put it somewhere safe.

  3. Save your token with poetry. Poetry will try to use keyring to store the token:

    poetry config pypi-token.dover-test

    poetry config pyi-token.pypi my-token

this is what poetry does

  1. fetches the repo url from your local config file (On Linux Mint this is located here: ~/.config/pypoetry/config.toml. )

    [repositories.dover-test]
    url = "https://test.pypi.org/legacy"
    
  2. fetches the token by name and username.

The name is the repo name - in this case “dover-test”. Username is token which is defined by PyPI’s API.

  1. generates a keyring entry name:

This consists of the poetry namespace name and the repo name:

The namespace is: poetry-repository Repo name: dover-test

Keyring Service Name: poetry-repository-dover-test Keyring User Name: token

Setting and Accessing a Keyring Token Manually

First you need keyring installed.

  1. Setting the token:

    
    ... keyring set poetry-repository-dover-test __token__
    Password for '__token__' in 'poetry-repository-dover-test':
    
  2. Getting the token:

    ... keyring get poetry-repository-dover-test __token__
    pypi-indwi87kk276l2396-3387sdlk.....
    
Setting and Access Token With Poetry
  1. Setting the token:

    ...  poetry config pypi-token.pypi my-token
    

    This is translated into the keyring form of: keyring set poetry-repository-pypi __token__ my-token