Skip to main content

Plugin for Poetry to dynamically use one or more repositories based on availability.

Project description

poetry-dynamic-caching

A plugin for Poetry that automatically switches to a package cache (like devpi) when it's available, falling back to PyPI when it's not.

Why?

Poetry allows specifying a custom primary repository. However if that repository isn't available Poetry will hang during poetry install or similar commands. This plugin checks if your cache is reachable before each install command and routes traffic accordingly.

[!NOTE] This plugin has been developed and tested for devpi only. Other cache/repository implementations might work as well. If not,let us know and we can look for a solution!

Installation

To install the plugin system wide use:

poetry self add poetry-dynamic-caching

You can also use the plugin only in the context of another Poetry project by adding the following to the pyproject.toml:

[tool.poetry.requires-plugins]
poetry-dynamic-caching = { version = "*" }

After that you can run poetry install --dry-run to install the plugins and not the dependencies.

Configuration

Add the following to your project's pyproject.toml:

[tool.poetry-dynamic-caching]
cache = [
   { type = "devpi", url = "https://my-cache-server.example" },
   { type = "devpi", url = "https://my-cache-server.invalid:1234" }
]

The first available entry in the list will be used.

Alternatively, you can set the DEVPI_URL environment variable.

[!NOTE] The environment variable DEVPI_URL overshadows the cache setting in the pyproject.toml file.

How it works

When you run any installer command (poetry install, poetry add, poetry lock, etc.), the plugin:

  1. Sends a request to <devpi_url>/+status
  2. If the cache responds with 200, removes any PyPI repositories from the internal state of Poetry
  3. Adds the configured cache as a repository to the interal state of Poetry
  4. If the cache isn't responding with 200, do nothing

Enable debug output to see what's happening:

poetry install -vvv

Requirements

  • Python >= 3.12
  • Poetry >= 2.3.1

License

MIT

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

poetry_dynamic_caching-0.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

poetry_dynamic_caching-0.2.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file poetry_dynamic_caching-0.2.1.tar.gz.

File metadata

  • Download URL: poetry_dynamic_caching-0.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.2 Linux/6.17.11-300.fc43.x86_64

File hashes

Hashes for poetry_dynamic_caching-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7b115496d1dd12694354a6610869e110bbc458dd95098976669136a9a8edbaf5
MD5 9165199a119cbd264a4604d9f48c8d3f
BLAKE2b-256 34f68c8c31b322386d8c5aa1de7530524efd3d9ceeea24bb32a533591e02b4db

See more details on using hashes here.

File details

Details for the file poetry_dynamic_caching-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: poetry_dynamic_caching-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.2 Linux/6.17.11-300.fc43.x86_64

File hashes

Hashes for poetry_dynamic_caching-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a31711ba92f74e6c5470f12b661ad0ecbbcfba78b0ccc4703a7fbc55fe69643
MD5 1070835411e876fbc283067780b867d8
BLAKE2b-256 715a28264848bb217fe5f60800629e0bf8eb640b4c2219884e32f0c2edf71713

See more details on using hashes here.

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