I published my first python package Mitype.
pip have made it so easy to install software!
This is all it takes.
pip install package_name
It is equally easy to share and distribute your awesome program through PyPI. Or is it?
I tried and failed multiple times. Publishing the package is the easy part. Getting it working the way you want it to be is not.
1. A version once published can't be reused❗
Say you published version 0.1 for your project. And then when you tested it out you realized that you missed to include that important database file! You have no option other than re-publishing a later version. Be careful whenever you publish that version on pypi. The same version cannot be edited or reused. You can delete it, but you cannot reuse it, even when deleted.
2. TestPyPI is your best friend
I so badly wish that I knew this earlier. You can first publish your package to test pypi, without affecting the actual index. You can also test the package version by installing it just like a regular python package.
3. Getting that sweet version update takes time
I would publish the version and get the success message. But then when I tried installing that version, I would get an error:
ERROR: Could not find a version that satisfies the requirement mitype
I'd get so upset thinking "What went wrong?!".
But then it would work! It just takes time, sometimes about 20 minutes. No need to worry!
I am just a beginner, and Mitype was my very first project on PyPI. It was one of my very proud moments!
All of you have your own different story! What is something that you wish you knew before publishing a python package?
Top comments (4)
This is great! I really identify with that third issue. I've been maintaining my own script on PyPI, and I've found the following command helpful:
Apparently, pip caches the project page after an install for a bit, so if you need to update the package shortly afterwards, you'll find that you may have to wait up to 10 minutes. This command should eliminate that issue.
Of course, I'm not an expert on this, so here are some sources where I pieced this knowledge together:
Oh. Makes sense. I'll try that for the next version. Thank you! <3
Other tips I whish I knew:
Check that your long_description renders without warnings by using a README.rst file and checking it with
rst2html5.py(from the docutils package)
Take the time to create a release on github too, because downstream users may try and find the sources there and not on pypi
Use setup.cfg, poetry or flint instead of actual python code in setup.py if you can
I can totally relate with these points. Especially the first one. Rst format can get so tricky. I had to spend a good amount of time understanding it and getting it working. Even today I have some problems with it. Like for example, centering text in Rst seems impossible!
Thanks for adding these points!