A sample test package
Project description
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 asetup.pyorsetup.cfginstead.
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
Setuptools Official Docs:
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ft_yde_goes_package-0.0.2.tar.gz.
File metadata
- Download URL: ft_yde_goes_package-0.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1daf7bf5cb4dbf6029a3ed266cb0b444373478fcaf21bcd10dc44f6ead292ef1
|
|
| MD5 |
288ff009c53f8c54031560df901873e3
|
|
| BLAKE2b-256 |
caf81a26da6a5e7121df01d7e0ed76a877ba37913351cb34a5ca01a7ce870dd2
|
File details
Details for the file ft_yde_goes_package-0.0.2-py3-none-any.whl.
File metadata
- Download URL: ft_yde_goes_package-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
020fe4e6e73d4c6ad4585d816989d12cbaf88b04e92b2802a2fd486f5b2d9bee
|
|
| MD5 |
69cb837508bf7e24729e770186ee5945
|
|
| BLAKE2b-256 |
a37dc1a59bc4c54cebfcaed5844da811974228111928c3105908c01640dfb181
|