Saturday, August 12, 2023

[How To] Create A Python Package

Step 1
- Create src and tests folders and add

(Optionally, you can add docs and scripts directories and other files like CHANGES.txt and

Step 2 - Add modules with functionalities.

Step 3 - Create pyproject.toml and setup.cfg (or

Step 4 - Create and LICENSE.txt.

Step 5 - Run the following commands:
pip install --upgrade pip setuptools wheel tqdm twine build

python3 -m build
Step 6 - Create an account on TestPyPi and/or PyPi and generate respective API tokens (alternatively, you can use your account username and password). Use __token__ as username if using API token.

Step 7 
- for TestPyPi - python3 -m twine upload --repository testpypi dist/*
- for PyPi - python3 -m twine upload dist/*

Step 8 - Install and test your package:
pip install <your_package_name>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.