Packaging Tutorial
This is a tutorial on setting up python packages for PyPi. Steps were learned from: Publishing (Perfect) Python Packages on PyPi
Notes
- From the folder level with setup.py : python setup.py sdist bdist_wheel
- Builds a wheel that is appropriate to upload to PyPi
- The name used in the setup.py file is added. This was a point of confusion for me. this name is what you pip install not necessarily the name of the pythjon code that will be imported
- From the folder level with setup.py : pip install –e .
- installs it locally. Tests packaging and makes it useful to your system.
- The ‘–e’ allows it to link to the code you are working on rather than building copies . The ‘ .’ means install in the current directory. Everytime you change the setup.py file you need to run this
- The name used in the setup.py file is added. This was a point of confusion for me
- Test it:
- from python environment in any folder from hellototi import say_hello
- ‘hellototi’ is the python module
- The name ‘PyPipackaging’ is from setup.py -> name=’hellototiname’. It is the name of the python script in the src folder. Within this script is the function say_hello
- Remove excessive files with gitignore.io
- Pip install twine
- Twine upload dist/* user name and pasword from PyPi.com
Folder structure
packaging_tutorial
|-LICENSE.txt **MIT**
|-README.md **edited in markdown**
|-setup.py **name=PyPipackaging, package=src, python module=hellototi**
|-src
|-pypipackaging.py **contains functions**
|-__init__.py ** empty**
Application
- this package can be installed using pip install PyPipackaging
- once installed the python code can be implemented by typing from pypipackaging import Funsum in Python environment
- In Python interpreter like Spider you can type import pypipackaging followed by pypipackaging.Funsum(10,10))
- I had to restart the kernal in Spyder to recognize the python module
Notes
- Install wheel pip install wheel
- python setup.py sdist bdist_wheel - this makes sdist build, and .egg-info files in directory
- pip install -e . - this installs it locally so it can be tested. use pip list to see local vs. global modules
- at this point you can use: import pypipackaging and pypipackaging.Funsum(10,10) from the Python environment. It is locally installed (see pip list from cmd)
Metadata
Release files for PyPipackaging 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| PyPipackaging-0.0.8.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyPipackaging-0.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / PyPipackaging-0.0.8.tar.gz
| Download URL | PyPipackaging-0.0.8.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c7efbcb6dd6287939fd0cfe57c05ee59b36585f002a6a44a80db1d4625a788c
|
|
BLAKE2b-256 checksum How to use checksums |
b4d6b3b057601af9dcaf57929077b6ccd6c708e2207ed30ae92e1a7c1b8d9cc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Release files / PyPipackaging-0.0.8-py3-none-any.whl
| Download URL | PyPipackaging-0.0.8-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d4c5b78a013de89c8439607e715be030378f541720813aef9ca5802377b3af9
|
|
BLAKE2b-256 checksum How to use checksums |
8cadc5d0b4056cad40f50a2d28deb9be732aaceb594d98b7271239d0a4b56c56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|