Skip to content
Snippets Groups Projects
Antoine Lambert's avatar
Antoine Lambert authored
Instead of implementing the versions sorting in each package loader
prefer  to have a base implementation in swh.loader.package.PackageLoader
class through the get_sorted_versions method. It relies on the looseversion
module enabling to interact with heterogeneous version schemes which works
pretty well with a large majority of package loaders.

The get_default_version method of the PackageLoader class now also has a
base implementation returning the last element from the list returned by
the get_sorted_versions method. As a consequence, each snapshot produced
by a package loader contains a HEAD alias branch targeting the branch
for the highest version number of a package.

Both methods can be reimplemented in package loaders for special cases
like debian for instance.

Also remove the use of the packaging module to parse versions as it is
only dedicated to parse Python package versions.

Related to swh/devel/swh-lister#4711.
555e4171
History

Software Heritage - Loader foundations

The Software Heritage Loader Core is a low-level loading utilities and helpers used by loaders.

The main entry points are classes:

Package loaders

This package also implements many package loaders directly, out of convenience, as they usually are quite similar and each fits in a single file.

They all roughly follow these steps, explained in the swh.loader.package.loader.PackageLoader.load documentation. See the Package Loader tutorial for details.

VCS loaders

Unlike package loaders, VCS loaders remain in separate packages, as they often need more advanced conversions and very VCS-specific operations.

This usually involves getting the branches of a repository and recursively loading revisions in the history (and directory trees in these revisions), until a known revision is found