DEV Community

Qiwen Yu
Qiwen Yu

Posted on

Release the TextHTMLPress package to PyPI

In this blog, we are focusing software releases and getting our code into the hands of users from a GitHub repository. My static html generator, TextHTMLPress was used as the package to be published on PyPI.

Setup the Python Packge structure

Based on references on setup Python project, package structure, and a production-level Python package, I refactor the package as shown below:

TextHTMLPress/
|-- tests/
|   |-- inputs/
|   |-- test.py
|   |
|-- TextHTMLPress/
|   |-- __main__.py
|   |-- __init__.py
|   |-- generator.py
|   
|-- .gitignore
|-- config.yml
|-- requirements.txt
|-- LICENSE
|-- CONTRIBUTING.md
|-- setup.cfg
|-- pyproject.toml
|-- README.md
Enter fullscreen mode Exit fullscreen mode

Write pyproject.toml and setup.cfg

To build a Python Package with setuptools and wheel, pyproject.toml and setup.cfg files are required. Follow the documentation, one thing worth noting is that now, static metadata setup.cfg should be preferred over setup.py, and now setup.py is not required.

Entry point

Adding a console script entry point in setup.cfg allows the package to define a user-friendly name for installers of the package to execute, seeing the reference.

Build and Upload

Register at PyPI.

python -m build
python -m twine upload dist/*
Enter fullscreen mode Exit fullscreen mode

The final package can be found at here.

Top comments (0)