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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for JefvdA_python_clitools-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1223ef3e9b9e1a4386f1f8188f4cde76d3f1ef4d8fa267e3acb105ba053097df |
|
MD5 | a808498ea4fe0705b632d0f8e0b35f7e |
|
BLAKE2b-256 | fe6d2b6cb3e050ab75e5dd032e0ff94c8445d7525757cea95974d2b4b7d8b6c2 |
Hashes for JefvdA_python_clitools-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eebb4fce60154dd108a4258a1d86ebc7cf8317e6a38edba3ceca16f932379c43 |
|
MD5 | dd2c36e8c1552d147b55d9879d7f67c6 |
|
BLAKE2b-256 | 3b057ad1fd68c5527f8ee6a06ad1f3669c51232c88bbcc0e99b54c4fa8ad1e99 |