- For a given package, package-locator locates its source code repository and the sub-directory within the package's repository.
- Covers packages from npm, PyPI, RubyGems, Composer, and Cargo.
- Locates repository from metadata collected from registry APIs.
- Validates repository and locates sub-directory through a set of heuristics for each package ecosystem. Package-locator looks at the manifest file for npm, Composer, and Cargo packages (
package.json
,composer.json
, andCargo.toml
) to locate package-specific code. For RubyGems and PyPI packages, package-locator either looks at the manifest file (gemspec
file) or compares the files present in the registry with the files present in the repository.
You can install package-locator via pip from PyPI:
$ pip install package-locator
from package_locator.locator import get_repository_url_and_subdir
is the primary function offered by package-locator. The function takes two inputs - ecosystem and package. The ecosystem names need to be provided as defined within package-locator. You can import from package-locator.common import CARGO, NPM, PyPI, COMPOSER, RUBYGEMS
and then use the constant values to indicate the ecosystem name. The function returns the source code repository URL and the sub-directory within the repository where the input package resides. For example, get_repository_url_and_subdir(NPM, "react")
call returns ("https://github.com/facebook/react", "./packages/react")
.
This package was created with cookietemple using Cookiecutter based on Hypermodern_Python_Cookiecutter.