Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Last active December 1, 2023 05:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LinuxIsCool/b5459ef621cf65518899f34d51719beb to your computer and use it in GitHub Desktop.
Save LinuxIsCool/b5459ef621cf65518899f34d51719beb to your computer and use it in GitHub Desktop.

Publish to Pypi Easily with Python Poetry

  1. Sinup at https://pypi.org/
  2. If you already have your codebase build with poetry. Skip to config pypi poetry
  3. To get started with a new project start here:

Install Python Poetry

https://python-poetry.org/

Initialize package with poetry

cd example/
poetry init
poetry add ...
poetry install
poetry shell

Create your module

mkdir example/
vim example/example.py
def example():
  return "Hello World!"
  
if __name__ == __main__:
  print(example())

Code is running hot and ready to publish!

python example.py

Hello World!

Config Your Pypi Key

poetry config pypi-token.pypi <pypi-key>

Build and Publish

poetry publish --build

Code is now available on pip

pip install example

Access the example function from the example module in the example package

from example.example import example

Hello World!

@bhargavkakadiya
Copy link

neat!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment