Python Publish Package
Reference: How to publish open-source python package to pypi[1]
PEPs about Python Packaging
The most important documents that define how Python packaging works are the following PEPs:
- PEP 427 describes how wheels should be packaged.
- PEP 440 describes how version numbers should be parsed.
- PEP 508 describes how dependencies should be specified.
- PEP 517 describes how a build backend should work.
- PEP 518 describes how a build system should be specified.
- PEP 621 describes how project metadata should be written.
- PEP 660 describes how editable installs should be performed.
Project Structure
In the reference article[1], it shows a demo project:
1 | |
And I will explain their function one by one:
- src: hold all the codes
- reader: the core module
__init__.py: represents the root of your package, store some constant into here__main__.py: Indeed, when executing a package withpython -mas you did earlier, Python runs the contents of__main__.py.In other words,__main__.pyacts as the entry point of your program and takes care of the main flow.config.toml:config.tomlis a configuration file used to specify the URL of the feed of Real Python tutorials.*.py: some otehr codes
- reader: the core module
- tests: create tests by pytest
- pyproject.toml: the profile of the project
The detailed info are shown on the reference site, and here I would like to show an easier example. And here is my project struct:
1 | |
And here is my pyproject.toml file:
1 | |
The last section should be emphasized, there are 2 o2h in the last line:

The first o2h is the name of the module, and the second one is the name of function.
Eventually, I build a connection between the command obs2hexo and the function o2h.
Python Publish Package
http://blog.chivier.site/2023-02-05/2023/Python-Publish-Package/