pyTooling.Packaging

A set of helper functions to describe a Python package for setuptools.

Hint

See high-level help for explanations and usage examples.

Functions

Classes

  • Readme: Encapsulates the READMEs file content and MIME type.

  • VersionInformation: Encapsulates version information extracted from a Python source file.


Functions

pyTooling.Packaging.loadReadmeFile(readmeFile)[source]

Read the README file (e.g. in Markdown format), so it can be used as long description for the package.

Supported formats:

  • Markdown (*.md)

Parameters:

readmeFile (Path) – Path to the README file as an instance of Path.

Return type:

Readme

Returns:

A tuple containing the file content and the MIME type.

pyTooling.Packaging.loadRequirementsFile(requirementsFile, indent=0, debug=False)[source]

Reads a requirements.txt file and extracts all specified dependencies into an array.

Special dependency entries like Git repository references are translates to match the syntax expected by setuptools.

Parameters:
  • requirementsFile (Path) – Path to the requirements.txt file as an instance of Path.

  • indent (int)

  • debug (bool)

Return type:

List[str]

Returns:

A list of dependencies.

pyTooling.Packaging.extractVersionInformation(sourceFile)[source]

Extract double underscored variables from a Python source file, so these can be used for single-sourcing information.

Supported variables:

  • __author__

  • __copyright__

  • __email__

  • __keywords__

  • __license__

  • __version__

Parameters:

sourceFile (Path) – Path to a Python source file as an instance of Path.

Return type:

VersionInformation

Returns:

pyTooling.Packaging.DescribePythonPackage(packageName, description, projectURL, sourceCodeURL, documentationURL, issueTrackerCodeURL, keywords=None, license=Apache - 2.0, readmeFile=PosixPath('README.md'), requirementsFile=PosixPath('requirements.txt'), documentationRequirementsFile=PosixPath('doc/requirements.txt'), unittestRequirementsFile=PosixPath('test/requirements.txt'), packagingRequirementsFile=PosixPath('build/requirements.txt'), additionalRequirements=None, sourceFileWithVersion=PosixPath('__init__.py'), classifiers=('Operating System :: OS Independent', 'Intended Audience :: Developers', 'Topic :: Utilities'), developmentStatus='stable', pythonVersions=('3.8', '3.9', '3.10', '3.11', '3.12'), consoleScripts=None, dataFiles=None)[source]
Return type:

Dict[str, Any]

Parameters:
pyTooling.Packaging.DescribePythonPackageHostedOnGitHub(packageName, description, gitHubNamespace, gitHubRepository=None, projectURL=None, keywords=None, license=Apache - 2.0, readmeFile=PosixPath('README.md'), requirementsFile=PosixPath('requirements.txt'), documentationRequirementsFile=PosixPath('doc/requirements.txt'), unittestRequirementsFile=PosixPath('test/requirements.txt'), packagingRequirementsFile=PosixPath('build/requirements.txt'), additionalRequirements=None, sourceFileWithVersion=PosixPath('__init__.py'), classifiers=('Operating System :: OS Independent', 'Intended Audience :: Developers', 'Topic :: Utilities'), developmentStatus='stable', pythonVersions=('3.8', '3.9', '3.10', '3.11', '3.12'), consoleScripts=None, dataFiles=None)[source]
Return type:

Dict[str, Any]

Parameters:

Classes

class pyTooling.Packaging.Readme(Content, MimeType)[source]

Encapsulates the READMEs file content and MIME type.

Inheritance

Inheritance diagram of Readme

Parameters:
  • Content (str)

  • MimeType (str)

__eq__(other)

Return self==value.

__hash__ = None
__init__(Content, MimeType)
Parameters:
  • Content (str)

  • MimeType (str)

Return type:

None

__repr__()

Return repr(self).

class pyTooling.Packaging.VersionInformation(author, email, copyright, license, version, description, keywords)[source]

Encapsulates version information extracted from a Python source file.

Inheritance

Inheritance diagram of VersionInformation

Parameters:
__init__(author, email, copyright, license, version, description, keywords)[source]
Parameters:
Return type:

None

_author: str

Author name(s).

_email: str

Author’s email address.

Copyright information.

_license: str

License name.

_version: str

Version number.

_description: str

Description of the package.

_keywords: List[str]

Keywords.

property Author: str

Name(s) of the package author(s).

property Copyright: str

Copyright information.

property Description: str

Package description text.

property Email: str

Email address of the author.

property Keywords: List[str]

List of keywords.

property License: str

License name.

property Version: str

Version number.

class property HasClassAttributes: bool

Check if class has Attributes.

Returns:

True, if the class has Attributes.

class property HasMethodAttributes: bool

Check if class has any method with Attributes.

Returns:

True, if the class has any method with Attributes.