stouputils.continuous_delivery.pypi module#

This module contains utilities for PyPI. (Using build and twine packages)

  • pypi_full_routine: Upload the most recent file(s) to PyPI after updating pip and required packages and building the package (using build and twine)

  • pypi_full_routine_using_uv: Full build and publish routine using ‘uv’ command line tool

stouputils pypi examples
update_pip_and_required_packages() int[source]#

Update pip and required packages.

Returns:

Return code of the os.system call.

Return type:

int

build_package() int[source]#

Build the package.

Returns:

Return code of the os.system call.

Return type:

int

upload_package(repository: str, filepath: str) int[source]#

Upload the package to PyPI.

Parameters:
  • repository (str) – Repository to upload to.

  • filepath (str) – Path to the file to upload.

Returns:

Return code of the os.system call.

Return type:

int

pypi_full_routine(repository: str, dist_directory: str, last_files: int = 1, endswith: str = '.tar.gz', update_all_function: ~collections.abc.Callable[[], int] = <function update_pip_and_required_packages>, build_package_function: ~collections.abc.Callable[[], int] = <function build_package>, upload_package_function: ~collections.abc.Callable[[str, str], int] = <function upload_package>) None[source]#

Upload the most recent file(s) to PyPI after updating pip and required packages and building the package.

Parameters:
  • repository (str) – Repository to upload to.

  • dist_directory (str) – Directory to upload from.

  • last_files (int) – Number of most recent files to upload. Defaults to 1.

  • endswith (str) – End of the file name to upload. Defaults to “.tar.gz”.

  • update_all_function (Callable[[], int]) – Function to update pip and required packages. Defaults to update_pip_and_required_packages().

  • build_package_function (Callable[[], int]) – Function to build the package. Defaults to build_package().

  • upload_package_function (Callable[[str, str], int]) – Function to upload the package. Defaults to upload_package().

Returns:

Return code of the command.

Return type:

int

pypi_full_routine_using_uv() None[source]#

Full build and publish routine using ‘uv’ command line tool.

Steps:
  1. Generate stubs unless ‘–no-stubs’ is passed

  2. Increment version in pyproject.toml (patch by default, minor if ‘minor’ is passed as last argument, ‘major’ if ‘major’ is passed)

  3. Build the package using ‘uv build’

  4. Upload the most recent file to PyPI using ‘uv publish’