versionfinder.versionfinder module

class versionfinder.versionfinder.VersionFinder(package_name, package_file=None, log=False, caller_frame=None)[source]

Bases: object

_dist_version_url(dist)[source]

Get version and homepage for a pkg_resources.Distribution

Parameters:dist – the pkg_resources.Distribution to get information for
Returns:2-tuple of (version, homepage URL)
Return type:tuple
_find_git_info(gitdir)[source]

Find information about the git repository, if this file is in a clone.

Parameters:gitdir (str) – path to the git repo’s .git directory
Returns:information about the git clone
Return type:dict
_find_pip_info()[source]

Try to find information about the installed package from pip. This should be wrapped in a try/except.

Returns:information from pip about self.package_name.
Return type:dict
_find_pkg_info()[source]

Find information about the installed package from pkg_resources.

Returns:information from pkg_resources about self.package_name
Return type:dict
_git_repo_path

Attempt to determine whether this package is installed via git or not; if so, return the path to the git repository.

Return type:str
Returns:path to git repo, or None
_package_top_dir

Find one or more directories that we think may be the top-level directory of the package; return a list of their absolute paths.

Returns:list of possible package top-level directories (absolute paths)
Return type:list
find_package_version()[source]

Find the installed version of the specified package, and as much information about it as possible (source URL, git ref or tag, etc.)

This attempts, to the best of our ability, to find out if the package was installed from git, and if so, provide information on the origin of that git repository and status of the clone. Otherwise, it uses pip and pkg_resources to find the version and homepage of the installed distribution.

This class is not a sure-fire method of identifying the source of the distribution or ensuring AGPL compliance; it simply helps with this process _iff_ a modified version is installed from an editable git URL _and_ all changes are pushed up to the publicly-visible origin.

Returns a dict with keys ‘version’, ‘tag’, ‘commit’, and ‘url’. Values are strings or None.

Parameters:package_name (str) – name of the package to find information for
Returns:information about the installed version of the package
Return type:VersionInfo
versionfinder.versionfinder.chdir(*args, **kwds)[source]