A small example package
Project description
Python Library Packaging and Distribution Project
This is a sample project that demonstrates how to create a Python library and publish it to the Python Package Index (PyPI). The project is designed to provide a clear example of the steps involved in packaging and distributing a Python library.
Reference Documentation
For detailed information on packaging and distributing Python projects, you can refer to the Packaging Python Projects tutorial on the official Python packaging website.
Project Structure
Make sure your project follows this structure:
packaging_tutorial/
├── LICENSE
├── pyproject.toml
├── README.md
├── src/
│ └── example_package_YOUR_USERNAME_HERE/
│ ├── __init__.py
│ └── example.py
└── tests/
- The
src
directory contains your project's source code, and you should have an__init__.py
file inside theproject_name
folder to mark it as a Python package. - Include a
LICENSE
file to specify the licensing terms of your project. - Write your project's README in Markdown format in the
README.md
file. - Place your project's tests in the
tests
directory. - The
pyproject.toml
file contains the project metadata and configuration.
Pyproject.toml Configuration
Here is an example of a pyproject.toml
configuration for your project:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "example_package_zhaohany"
version = "0.0.1"
authors = [
{ name = "Zhaohan Yan", email = "zhaohany@outlook.com" },
]
description = "A small example package"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
[project.urls]
homepage = "https://github.com/zhaohany/example_package_zhaohany"
bug-tracker = "https://github.com/zhaohany/example_package_zhaohany"
Building and Distributing
To build and distribute your package, follow these steps:
- Install required tools:
sudo apt install python3-pip
pip3 install build
sudo apt install python3.10-venv
- Build source distribution (sdist) and/or build distribution (wheel):
python3 -m build --sdist /path/to/your/project
python3 -m build --wheel /path/to/your/project
- Install Twine for uploading:
sudo apt install twine
- Upload your distribution files to PyPI:
twine upload dist/example_package_zhaohany-0.0.1.tar.gz dist/example_package_zhaohany-0.0.1-py3-none-any.whl
API Token for PyPI Upload
If you encounter an API token issue during upload, create an API token on PyPI:
- Username:
__token__
- Password: Your generated token
This is a basic outline of the steps required to create, package, and distribute a Python library to PyPI. For more details and troubleshooting, refer to the Packaging Python Projects tutorial on the official Python packaging website.
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
File details
Details for the file example_package_zhaohany-0.0.2.tar.gz
.
File metadata
- Download URL: example_package_zhaohany-0.0.2.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c93b7b0e54417a51e363a0bfd70b4fb8c1da17d111fb5480435fbe241aa6b21 |
|
MD5 | e80ad076631a0a4385ff0ee7cf415cea |
|
BLAKE2b-256 | d633fe012d9d6218ca04f3a6e32109b5a8dd37eefd68a257fd92a4d76b2bf93f |
File details
Details for the file example_package_zhaohany-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: example_package_zhaohany-0.0.2-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ffecd74a0a6403e7f7783a429477694f8448f90f2ec50c35976f0f222e4f4f |
|
MD5 | d04b5cc276a5fc1bfccd8a405cb357f6 |
|
BLAKE2b-256 | 54792c932b15176b6731e2ae483489915a51939330200dbd72e0b9f2fd103fe7 |