Skip to main content

"A way to specify publicly available sources (e.g. files/zips) to cache locally and then resolve these sources (e.g. copy/unzip) to a local directories for use."

Project description

dependency-resolver

Define external dependencies for a project using a JSON file, then fetch and resolve them into the project.

Ideally for python versions > 3.11, but should be cope with 3.10, although different dependencies will be introduced (see requirements.txt)

For list of supported commands run dependency-resolver/resolve.py -h

Better notes will be added here in due course!

Description

Define external dependencies (publicly (https) available files) for a project using a JSON file, then fetch and resolve them into the project.

The JSON file can then be versioned controlled with the project instead of the dependencies themselves.

Each dependency has a source and a target that defines where the dependency is and where it should be resolved to locally.

### Fetching and Resolving Getting dependencies is a two-step process.

  1. The dependency source is fetched (downloaded) and added to a local cache as is.
  2. This source can then be resolved from the cache to the local dependency target.

Each dependency can specify an action to be carried out when resolving the source from the cache to the dependency target:

  • Copy the fetched file.
  • Unzip the fetched .zip.
  • Untar the fetched .tar.

Multiple dependencies can use the same source and each can resolve it to different target locations using different actions.

Using a cache means the same dependency source is fetch only once for all dependencies that use it, but resolved any number of times.

Static dependencies can only be fetched on its initial run, and dynamic ones can be fetched every time its run.

Configuration

The JSON configuration file (examples are in the examples folder in the repository): { "project" : "MyProject", // The name of the project (mandatory). This will also determine the top level of the cache where all sources are fetched to, allowing different projects to have different caches.

"dependencies" :
[
    {
                                                            // Example of a dependency which is copied to a target directory.   
        "name" : "Download_Latest_Version",                 // The name of the dependency (mandatory). Must be unique.
        "description" : "The latest version of myThing.",   // A description for this dependency (optional).
        "target_dir" : "/put/latest/here",                  // The local directory to resolve this dependency to (mandatory).
        "target_name" : "myThing.app",                      // The target file name (optional).
        "source" : "latest"                                 // The source to use (mandatory).
    },
    {
                                                // Example of a dependency which is unzipped to a target directory.   
        "name" : "Unzip_Useful_Stuff",          // The name of the dependency (mandatory). Must be unique.
        "description" : "A useful zip file.",   // A description for this dependency (optional).
        "target_dir" : "/useful/stuff/",        // The local directory to resolve this dependency to (mandatory).
        "source" : "myfiles",                   // The source to use (mandatory).
        "source_path" : "this/zip/useful.zip",  // A path relative to the "base" directory defined in the source (optional, unless using a source with a protocol of 'filesystem').
        "resolve_action" : "unzip"              // The action to perform when resolving the dependency (optional). Options: unzip, untar, copy - defaults to copy.
    }
],
"sources" :
[
    {
        "name" : "internal",        // The name of the source (mandatory). Must be unique.
        "protocol" : "filesystem",  // The protocol used to fetch the source (optional). Options: filesystem (from some local directory), https - defaults to https.
        "type" : "project"          // Options are: project (the dependency's source_path is relative to this configuration file) or absolute (the dependency's source_path is an absolute path) - defaults to project.
    },
    {
        "name" : "latest",                                                          // The name of the source (mandatory). Must be unique.
        "protocol" : "https",                                                       // The protocol used to fetch the source (optional). Options: filesystem (from some local directory), https - defaults to https.
        "base" : "https://downloads.example.com/latest/myThing_5_13_5_linux64.app"  // The address of the source (mandatory). The dependency's 'source_path' can extend this address.
    },       
    {
        "name" : "myfiles",                             // The name of the source (mandatory). Must be unique.
        "protocol" : "https",                           // The protocol used to fetch the source (optional). Options: filesystem (from some local directory), https - defaults to https.
        "base" : "https://downloads.example.com/stuff"  // The address of the source (mandatory). The dependency's 'source_path' can extend this address.
    }
]

}

Installation

Create a virtual environment (optional)

python3 -m venv .env/dependency-resolver
. .env/dependency-resolver/bin/activate

Install archive-and-release

pip install dependency-resolver

Exit the virtual environment

deactivate

Commands

See all commands/help

dependency-resolver -h

Individual command options/help

dependency-resolver <cmd> -h

Print the configuration JSON

Can be used to make sure the configuration JSON file being used is the expected one.

dependency-resolver print_config --configPath examples/sample.json

Test the configuration JSON

Tests the given JSON file to make sure it valid. Its quite a basic test, but should detect anything glaring.

dependency-resolver validate_config --configPath examples/sample.json

Print dependency target

This can be used to programmatically determine where a given dependency will be resolved to. This could be used to refer to the dependency from other places in your project.

dependency-resolver print_dependency_target --configPath examples/sample.json --name Download_Latest_Version

Fetch all dependencies

Downloads all sources into the cache.

dependency-resolver update_cache --configPath examples/sample.json

Empty the cache and then download all sources into the cache. dependency-resolver update_cache --configPath examples/sample.json --clean

Resolve all fetched dependencies

Resolves all dependencies that have previously been fetched. If they have not been fetched then this will thrown an error.

dependency-resolver resolve_from_cache --configPath examples/sample.json

Fetch and resolve all dependencies

Fetches all sources (if required) and resolves them. dependency-resolver resolve --configPath examples/sample.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dependency_resolver-1.0.0.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dependency_resolver-1.0.0-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

Details for the file dependency_resolver-1.0.0.tar.gz.

File metadata

  • Download URL: dependency_resolver-1.0.0.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dependency_resolver-1.0.0.tar.gz
Algorithm Hash digest
SHA256 163e2e750a9815e43d4fdf98784972eae1275c11c5953d06b209e5477e78955a
MD5 b509a23f7ee1b73c3b62f53af6103343
BLAKE2b-256 bd6a283d4ce87c19effa6b66979cea596cb067f98f3fd3cf3e8a5f787d28c2ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for dependency_resolver-1.0.0.tar.gz:

Publisher: build-release.yml on dan-east/dependency-resolver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dependency_resolver-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dependency_resolver-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4df1b579a87b93602fc6455e96ac8602c06895aa5d39df6e99dceb135908b717
MD5 b433408827d5d5048294958a22dd01cb
BLAKE2b-256 0b8b160d8c0bf1446dd9be681eba5be04eb069fdbc28ead03dca32748cc11f5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dependency_resolver-1.0.0-py3-none-any.whl:

Publisher: build-release.yml on dan-east/dependency-resolver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page