How to create a python package on repl.it!
Introduction
In this tutorial, I'm gonna show you how to create a python package and publish it to pypi. Many people say this is impossible on repl.it. It is not. Though you can't do it using a generic approach, but using poetry, you can do it quite easily.
Part 1: coding your package
Start by creating a python repl. Then go to the bash shell (CTRL + SHIFT + S or CMD + SHIFT + S
) and type poetry new mypackage
. **Replace the mypackage with your package name. If when you import it, you want it to have underscores (my_package
) , use dashes (my-package
). Here is what you should see:
Go to package-name/package-name/__init__.py
. You should see one thing:
This is where you add your package code. I'll add some basic stuff:
Part 2: Publishing your package
Now you can publish your package so others can use it! Create an account on pypi. In the bash shell, type cd package-name
. Again, replace package-name with your package name. After that, type poetry update
to update the dependencies for your package. Then type poetry build
. Then poetry publish
. When it asks for them, enter you pypi credentials. You are good to go!
To create a new release, simply change line one of package-name/package-name/__init__.py
to 0.1.1, and line three of package-name/pyproject.toml
. poetry update
, poetry build
, and poetry publish
!
That's it!
Nice, I never knew how to do this
Neither did i till 10 minutes before i posted this :) @IntellectualGuy