Skip to content
← Back to Community
How to create a python package on repl.it!
Profile icon
isaiah08

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:
image

Go to package-name/package-name/__init__.py. You should see one thing:
image

This is where you add your package code. I'll add some basic stuff:
image

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!

What now?

Check out https://python-poetry.org/docs and https://python-poetry.org/docs/pyproject to do more.

That's it!

Voters
Profile icon
ksIsCute
Profile icon
WhatDoWeDoNow
Profile icon
Yek
Profile icon
MrVoo
Profile icon
IntellectualGuy
Profile icon
programmeruser
Profile icon
isaiah08
Comments
hotnewtop
Profile icon
Anpang

there is no pyproject.toml

Profile icon
Anpang

so i cant update it

Profile icon
WhatDoWeDoNow

@Anpang Click "show hidden files" and select pyproject.toml

Profile icon
Anpang

@WhatDoWeDoNow there is no pyproject.toml

Profile icon
Anpang

@WhatDoWeDoNow even if i clicked show hidden filoes

Profile icon
isaiah08

Try creating a new repl and trying it again. You may have deleted it by mistake or something. It should be in the part of the files sidebar that is called "Packager Files"
image
@Anpang

Profile icon
ksIsCute

i know this is old but thank you so much

Profile icon
isaiah08

No problem :) @ksIsCute

Profile icon
isaiah08

No problem :) @ksIsCute

Profile icon
WhatDoWeDoNow

I have automated it: Click here!

Profile icon
isaiah08

Wow, that's really cool! @WhatDoWeDoNow

Profile icon
Anpang

first time didnt work because i accidentally pressed a single enter key when it was installing stuff lol

Profile icon
isaiah08
Profile icon
WhatDoWeDoNow

This is amazing! Thank you so much! If you want to see it, the name of it is "tilecode"

Profile icon
isaiah08

Cool! You can also add change the beginning of pyproject.toml from

[tool.poetry] name = "tilecode" version = "0.0.0" description = "" authors = ["WhatDoWeDoNow"]

to

[tool.poetry] name = "tilecode" version = "0.0.0" description = "" authors = ["WhatDoWeDoNow"] documentation = "<.md file>"

to add documentation!
@WhatDoWeDoNow

Profile icon
WhatDoWeDoNow

@isaiah08 Okay :)

Profile icon
RixTheTyrunt

IT'S IMPOSSIBLE, LOOK BELOW

Profile icon
RixTheTyrunt

I'm trapped when Poetry asks my PyPI password:

Step 1:

Step 2:

Step 3:

Step 4:

AND IT DOESN'T LET ME PUT MY PASSWORD

Profile icon
RixTheTyrunt

NOW IT SAYS A RUNTIMEERROR:

Poetry could not find a pyproject.toml file in /home/runner/commonpy or its parents

Profile icon
isaiah08

Can you invite me to the repl? I might be able to solve it that way. @RixTheTyrunt

Profile icon
isaiah08

The password is hidden. Your still typing it in, but it won't show it. @RixTheTyrunt

Profile icon
isaiah08

You also can't publish a package called commonpy because somebody has already done so: https://pypi.org/project/commonpy/ @RixTheTyrunt

Profile icon
RixTheTyrunt

WUT

Profile icon
RixTheTyrunt

CODEPY???

Profile icon
RixTheTyrunt

PROGRAMPY!!!

Profile icon
RixTheTyrunt

YAHOO!!! I JUST NEEDED TO MAKE A LITTLE BASH CHANGE! ( *bruh* )

Profile icon
IntellectualGuy

Nice, I never knew how to do this

Profile icon
isaiah08

Neither did i till 10 minutes before i posted this :) @IntellectualGuy