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.0.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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poetry_dynamic_caching-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5693dce511a100c28f111c9e48c732e45a90fb4b1f16134a8e95ab96c8346896
MD5 111e4c1959b2d92163daca5e850704de
BLAKE2b-256 848962e67269559c440b11042a11d2789c94e8a33b80da2f10ca6dbf9499c6fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: poetry_dynamic_caching-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9481fb293b94d8163f35a985b972a236fba52250258db4cc05335ed4d7044b07
MD5 5ea849dd62697cbfdce05e64fe6e6f2d
BLAKE2b-256 547e20c6ca06d6a765c972bbe23b8f626fbf42d7e3f449d64f4a9ff671d02c4c

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