pypi: Move extraction of package metadata into its own function