Skip to main content

Introduction to the ft_yde_goes_package

This package was created as a requirement to the last exercise of Day 00 during the Python for Data Science piscine at 42 School. The objective was to teach the students how to create a Python package and how to distribute it.

Package structure

packaging_tutorial/
├── LICENSE
├── pyproject.toml
├── README.md
├── src/
│   └── example_package_YOUR_USERNAME_HERE/
│       ├── __init__.py
│       └── example.py
└── tests/

Above is the package structure used as a reference:

  • __init.py__: this file must located at each sub-directory, which is also the sub-module of a given package. It will map all the methods present in each sub-module;
  • pyproject.toml: contains the key-value configuration of the package with all its related information to build it. It's also possible to use a setup.py or setup.cfg instead.

How to test the package

To test the package, run the command below at the same folder where pyproject.toml is located:

pip install --editable .

To check if the package was successfully installed, run:

pip show -v ft-package

To uninstall the package, run:

pip uninstall <package_name>

Create a Python program at the same folder where pyproject.toml is located to see if you can use the package module without any problems when running it with python3.

How to build and distribute the package

We're going to need to packages:

python3 -m pip install twine
python3 -m pip install build

Then we need to build the source distribution and the wheel, which checks if the package contains pure Python to adjust the compilation settings accordingly.

python3 -m build --sdist
python3 -m build --wheel

To distribute the package, we need to create an account at PyPi, enable 2FA and create an API token. It's recommend to save the account information at ~/HOME/.pypirc.

Last but not least, update the package:

twine upload dist/* --verbose

References

Build your first Python package by freeCodeCamp

Official PyPi Website

Setuptools Official Docs:

Metadata

Release files for ft-yde-goes-package 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ft-yde-goes-package 0.0.2
File Size Uploaded
ft_yde_goes_package-0.0.2.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ft-yde-goes-package 0.0.2
File Interpreter ABI Platform
ft_yde_goes_package-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / ft_yde_goes_package-0.0.2.tar.gz

Download URL ft_yde_goes_package-0.0.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1daf7bf5cb4dbf6029a3ed266cb0b444373478fcaf21bcd10dc44f6ead292ef1
BLAKE2b-256 checksum
How to use checksums
caf81a26da6a5e7121df01d7e0ed76a877ba37913351cb34a5ca01a7ce870dd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / ft_yde_goes_package-0.0.2-py3-none-any.whl

Download URL ft_yde_goes_package-0.0.2-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
020fe4e6e73d4c6ad4585d816989d12cbaf88b04e92b2802a2fd486f5b2d9bee
BLAKE2b-256 checksum
How to use checksums
a37dc1a59bc4c54cebfcaed5844da811974228111928c3105908c01640dfb181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

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