Skip to main content

A python package which adds simple cli tools to your python project.

Project description

Pypi package template

This is a template for pypi packages.

Default this comes with a MIT licence.

Before you start

Add your package's source code to the "src" directory.

Make sure to change your project's info in the setup file!

Building your package

To build your package you will need to install build with pip.

Install pip:

Windows:

Download the get-pip.py file, then execute this python script, which will install pip for you.

Linux (apt):

For python3:

sudo apt update
sudo apt install python3-pip

For python2:

sudo apt update
sudo apt install python-pip

Install build:

Now that pip has been installed, we can use it to install build:

pip install build

Now that build is installed, we can build our package:

python3 -m build

This will generate a source archive (tar.gz) and a build distribution (.whl) in the directory "dist". These are the files we want to upload to the registery.

Publishing your package

To upload our package to the pypi registery, we will need twine:

pip install twine

Now that twine is installed, we can finally publish our package.

Follow the next steps for uploading your package to PyPi, but it might be smart to try TestPyPi first, as this is a registery like PyPi made for testing and experimenting.

PyPi

As PyPi is twine's default registery, it's a pretty simple command that we need:

python3 -m twine upload dist/*

This command will ask for your credentials (username and password), you need to log in before uploading. You can create an account here.

Click here to see how you can install and use your package in another python project.

TestPyPi

As TestPyPi is not twine's default registery, we need to specify the registery we want to use in the command:

python3 -m twine upload --repository testpypi dist/*

This command will ask for your credentials (username and password), you need to log in before uploading. Be aware, TestPyPi uses it's own servers, and you need a different account then for PyPi. You can create a TestPyPi account here.

Click here to see how you can install and use your package in another python project.

Importing your package

Now that your package is uploaded to the python registery, you can install it with pip, and use it in other python projects.

Install from PyPi

As PyPi is pip's default registery, we don't need to specify it, use following command to install a pip package (ofcourse, change [package name] to the name of your own package):

pip install [package name]

Install from TestPyPi

As TestPyPi is not pip's default registery, we need to specify that we're using it, use following command to install a pip package (ofcourse, change [package name] to the name of your own package):

pip install -i https://test.pypi.org/simple/ [package name]

Importing the package

Now that we have succesfully installed our pip package, we can move on.

If you are not sure, you can get a list of all currently installed pip packages with following command:

pip list

Now you can import the package in another python module like this:

from example_package import example

example.add_one(4) # This will return 5

This example package is used as example on how to import above

Be aware, after from doesn't come the name of the package, it is the name of a module specified in the src directory.

Goodluck

I don't know who will ever read this, but if you are reading this now, thank you!

I wish you good luck on your next coding adventures, and hope you will one day create an amazing pip package!

@2022 Jef van der Aviort

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

JefvdA_python_clitools-0.0.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

JefvdA_python_clitools-0.0.1-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page