JetBrains Space Help

Publish Python Packages

Suppose you have a Python package that you want to publish to your Python Package Index in Space using one of the tools:

Publish packages using the Twine command-line tool

  1. Connect to the repository in Space:

    1. Add a repository link to the .pypirc file. For example:

      [distutils] index-servers = space-mypypi [space-mypypi] repository = https://pypi.pkg.jetbrains.space/mycompany/p/my-python-project/mypypi/legacy

      Here index-servers is an identifier of our Space repository. You can specify any name for it.

    2. Generate a personal token.

    3. Use the keyring tool to save the generated token. For example, if your Space username is Anna:

      keyring set https://pypi.pkg.jetbrains.space/mycompany/p/my-python-project/mypypi/legacy Anna

      When asked for a password, provide the generated token.

      An alternative to the keyring tool would be storing the token in the .pypirc file. Note that this way is less secure. For example, if your username is Anna and the token is abc1234:

      [distutils] index-servers = space-mypypi [space-mypypi] repository = https://pypi.pkg.jetbrains.space/mycompany/p/my-python-project/mypypi/legacy username = Anna password = abc1234
  2. Upload the package to the repository using the twine tool. For example, we suppose that the package is located in the ./dist directory:

    twine upload -r space-mypypi dist/*

Publish packages using the Poetry command-line tool

  1. Connect to the repository in Space:

    1. Add a repository link using the poetry config command:

      poetry config repositories.space-python https://pypi.pkg.jetbrains.space/mycompany/p/my-python-project/mypypi/legacy
    2. Generate a personal token.

    3. Use the poetry config command to store credentials for your repository. For example, if your Space username is Anna:

      poetry config http-basic.space-python Anna token_goes_here
  2. Publish the package to the repository using the poetry publish command:

    poetry publish --repository=space-python
Last modified: 23 November 2022