Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/justwaitfor-me/pypi-tutorial

How to upload your Python Package
https://github.com/justwaitfor-me/pypi-tutorial

package pip pypi pypi-package pypi-upload python

Last synced: about 1 month ago
JSON representation

How to upload your Python Package

Awesome Lists containing this project

README

        


How to upload a Python package to Pypi?




The Python Package Index, abbreviated as PyPI, is the official repository of software for the Python
programming language. By default, pip — which is the most popular Python package manager — uses PyPI as
the
source for retrieving package dependencies.


PyPI logo

1. PyPi Account



1. Create an account with PyPi here and verify your email
address



2. In your account settings, scroll down and enable two-factor authentication (2FA)


1. Enable *PyPI-Recovery-Codes* and save them in a File
2.
Acivate 2FA and scan the QR Code with an Authenticator


    - Botan (programming
library)

    -
FreeOTP

    - Google
Authenticator

    -
multiOTP

    - Comparison of
TOTP applications


3. Finally, you have to generate an API Token at the bottom of your
account
settings. You will need the Token later!


2. Python Package



1. create a new Folder (package_name) and open it in your favourite
code editor


2. create the Files and Folders in your Folder by using the templates
listed below. Replace the [] with your own names


NOTE: You have to change the Information in every File to
your
Information



LICENSE
MANIFEST.in
pyproject.toml
README.md
requirements.txt
setup.py
/src
    /[package_name]
       
src/__init__.py    
(empty file)
       
[Modul_1].py       
(your code)
       
[Modul_2].py       
(your code)
       
you can add more
Moduls


It should look like this:


Data.png


3. PyPi Package


0. install build and twine


NOTE: Make shure that you have pip installed


pip install twine
pip install build


1. install the Package locally:


cd [package_name]
pip install .


JJSwbLB.md.png


Now your Repo should look like this:


JJSNKIR.png


NOTE: You can Test your Package localy before deploying
it


2. building the Package (this Step can take some time)


python -m build


output (end):


Successfully built Package_Name-0.0.1.tar.gz and
Package_Name-0.0.1-py3-none-any.whl


Now you should have the /dist direcory:


JJSPva4.png


3. deploying the Package


NOTE: The user 'username'
isn't
allowed to upload to project 'package_name'.
means that the Package Name ist allready
taken.


python -m twine upload dist/*


Username = __token__


Password = [your Token]


JJSLU9R.md.png


Your Package is now online on PyPi and can be used by downloading it
with
pip


pip install [package_name]


4. Updating the Package


To update your Package you have to change the version in the pyproject.toml file.


python -m build
python -m twine upload --skip-existing
dist/*


JJSml6P.md.png


To install the new Version:


pip uninstall Package_Name
pip install Package_Name