Skip to main content

Packaging Tutorial

This is a tutorial on setting up python packages for PyPi. Steps were learned from: Publishing (Perfect) Python Packages on PyPi

Notes

  1. 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
  1. 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
  1. 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
  1. Remove excessive files with gitignore.io
  2. 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

  1. this package can be installed using pip install PyPipackaging
  2. once installed the python code can be implemented by typing from pypipackaging import Funsum in Python environment
  3. In Python interpreter like Spider you can type import pypipackaging followed by pypipackaging.Funsum(10,10))
  4. I had to restart the kernal in Spyder to recognize the python module

Notes

  1. Install wheel pip install wheel
  2. python setup.py sdist bdist_wheel - this makes sdist build, and .egg-info files in directory
  3. pip install -e . - this installs it locally so it can be tested. use pip list to see local vs. global modules
  4. 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)

Source distribution for PyPipackaging 0.0.8
File Size Uploaded
PyPipackaging-0.0.8.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyPipackaging 0.0.8
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page