[PYTHON] Upload packages to PyPI using tokens

Introduction

In Python, you can upload the library you created to PyPI for easier installation with pip.

At this time, it is usually necessary to manually enter the user name and password in the console when uploading, but if you issue an API token, you can omit these user names and passwords.

Upload to PyPI (without tokens)

pipenv install --dev wheel twine

Put wheel and twine in dev for packaging and uploading. wheel is a form of package and a library for creating that form. (Like a gem) twine is a library for uploading to PyPI.

When uploading, I use the following shell script.

#!/usr/bin/env bash

rm -f -r {your-library-name}.egg-info/* dist/*
python setup.py bdist_wheel
twine upload dist/*

At this time, you need to enter the user name and password when using twine.

API token

It can be issued from Add API token. After issuing the API token, put the following contents in your home directory as ~/.pypirc.

.pypirc


[pypirc]
servers =
    pypi
[pypi]
username: __token__
password: your_token

__token__ is a name that feels like putting tokens with different names individually, but you can just type __token__ in plain text as it is. For password, you need to set it, and you need to write the API token issued earlier.

Reference link

Recommended Posts

Upload packages to PyPI using tokens
Settings for uploading Python packages locally to PyPI
Upload images to S3 with GUI using tkinter
How to upload to a shared drive using pydrive
Using Python #external packages
Publish / upload a library created in Python to PyPI
Conveniently upload to kaggle Dataset
Upload videos using YouTube API
Upload a file to Dropbox
Post to Twitter using Python
How to register on pypi
Start to Selenium using python
Introduction to discord.py (3) Using voice
Upload and manage packages that are not in conda to anaconda.org
Regularly upload files to Google Drive using the Google Drive API in Python