Skip to main content

Performing Package Publishing through pyproject.toml File

· 2 min read

Configuration details and meta data for APIMatic's Python SDKs is stored in a pyproject.toml file instead of setup.py to make the package publishing process efficient and up to date.

note

This is a prerelease changelog. This change will take effect on 2022-11-04.

Details

Previously, setup.py was the main file required for package publishing in python SDKs. The meta data was described in this particular file. Now, APIMatic’s Python SDKs generate a pyproject.toml file to list down the specifications needed to publish a package.

Why is this change required?

The setup.py file contains the information that is required to run the file. But the file is not runnable unless the contents of the file are known which is only possible when the file is programmatically run. This issue was worked on but the solution has limitations as claimed by the Python community is this rationale.

What has changed?

  • The build system dependencies is now stored in a file named pyproject.toml which is written in the TOML format.
  • The setup.py file is removed to prevent redundant data from being stored.
  • A setup.cfg file is added to ensure that the packages can be installed in an editable mode as Setuptools v62.6 doesn't support editable installs with just pyproject.toml. Hence this file will stay until the support is complete.

The CI command

The CI commands to build and distribute a package have changed due to the use of the pyproject.toml file. To build a package, run the following command in the directory where the pyproject file is located.

py -m build

To upload a package to PYPI using twine, run the following command:

py -m twine upload dist/*

For more information on package publishing read https://packaging.python.org/en/latest/tutorials/packaging-projects/.