Upload your python files to PyPi with libtool

The Python Package Index logo with the text ‘with libtool’

What is PyPI?

From their website:

How to upload?

There are several ways to do this, I am going to show you the simplest way: upload with libtool python library.

What is libtool?

From the PyPi website:

In short, it does all the work for you. You need only to:

  • make libConfig file
  • make test file
  • make pypi account
  • type a simple command

and the libtool will create and manage your library !

Make libConfig.ini file:

Create a file called libConfig.ini with the text editor of your choice. Write a text like this:

You can use this site to choose license

Make test file:

Create file called test.py with your text editor of choice. Write code that imports and tests your functions and classes. The library created will be the same name as your package name. The more examples the better, as they are added to your README file:

Make a PyPi account:

You can make PyPi account on this site. You will need your username and your password to upload the library.

Create library from your code with libtool:

You need to install libtool:

# the first line is not always necessary but it might prevent errors
pip install --upgrade setuptools wheel
pip install libtool

Now create your library:

libtool c libConfig.ini

it will print output like this:

create __init__.py
create setup.py
create Licence.txt
create README.md
you want to open editor for README.md? (y\n)>

I recommend to type y in the question because it will open a Markdown editor and then you can check the README that was created.

Now you can upload your library to PyPi.

Upload your library to PyPi with libtool:

First cd to folder with setup.py then type:

libtool u

it will open a CMD window and a lot of output. The output will end with “Press any key to continue . . .”

After you continue by pressing any key ,you need to fill the details like this:

Enter your username: {your pypi username}
Enter your password: {your pypi password (you will not see what you write )}

after you type the password you will see:

Uploading distributions to https://upload.pypi.org/legacy/
Enter your username:{your pypi username}
Enter your password:
Uploading {yourlibrary}-0.0.1-py3-none-any.whl
100%|████████| 1.0k/1.0k [00:01<00:00, 1kB/s]
Uploading {yourlibrary}-0.0.1.tar.gz
100%|████████| 1.0k/1.0k [00:00<00:00, 1kB/s]
View at:
https://pypi.org/project/{yourlibrary}

And you’re done!

If there is an error before pressing any key, try to search error in github python packaging-problems.

If you see any errors after entering name and password try to find it in github twine issues.

Changing your library:

If you wish to publish an update to your library, after you change the source code, you need to:

  1. Change your library version
  2. Upload your library again

Change your library version:

Simply type the command:

libtool v 

and you need to write the next version you want after the ‘->’ :

enter new version:
0.0.1 ->{here}

Upload your library again

Do again the commands in “Upload your library to PyPi with libtool” section.

Install your library:

To test that the library was uploaded properly, you can install your library from PyPi. Simply type the command:

pip install --upgrade {your library}

Troubleshooting:

If, after checking the links above, you still encounter an error please open a new github issue in libtool.

View examples here

Thanks you for reading and happy uploading !

Matan H is the creator of a number of Python libraries including libtool and mhyt.