Cheuk Ting Ho
Developer advocate / Data Scientist - support open-source and building the community.
Online Absolute Beginner Python Tutorials
Every Sunday 2pm (UK time/ BST)
by Cheuk Ting Ho
Get this slide deck:
slides.com/cheukting_ho/python-packaging
Beginner topics:
Python objects, Control flows,
Functions, modeuls, classes and decorators
strings operations and regex with re
Testing:
pytest with fixtures and mock
property-based testing
python linters & auto-formatters
TDD
Intermedite topics:
Iterators, generators, async
Packaging:
generating docs
There are some tasks in Python that are specific for a common application.
e.g. scrapping webpages, scitific calculations, testing codes, deal with timezones and datatimes.
The standard library cannot cover everyone's need.
We want to share the code that we have writen for those specific tasks for people doing the same tasks
We need a way to share those codes easily.
So we wrap up those codes as a package and upload it to The Python Package Index (PyPI) for others to download and install. (pip install)
⚠️ Everyone can upload to PyPI so make sure you know the package before pip install and make sure you type the name correctly
The Python Packaging Authority (PyPA) is a working group that maintains a core set of software projects used in Python packaging.
pip
setuptools
twine
wheel
Warehouse
Pipenv
virtualenv
build the wheel
using bdist_wheel
upload to PyPI
using twine
https://packaging.python.org/tutorials/packaging-projects/
packaging_tutorial
├── LICENSE
├── README.md
├── example_pkg
│ └── __init__.py
├── setup.py
└── tests
GitHub
Check the test tutorials
🌟
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="example-pkg-YOUR-USERNAME-HERE", # Replace with your own username
version="0.0.1",
author="Example Author",
author_email="author@example.com",
description="A small example package",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pypa/sampleproject",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives
How to set up PyPI token on Travis: https://docs.travis-ci.com/user/deployment/pypi/
How to tag a release in git: https://git-scm.com/book/en/v2/Git-Basics-Tagging
Sunday 2pm (UK time/ BST)
There are also Mid Meet Py every Wednesday 1pm
By Cheuk Ting Ho
Developer advocate / Data Scientist - support open-source and building the community.