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.2.tar.gz (4.9 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.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for poetry_dynamic_caching-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8d411441d5aa560821a5ad12b9984d21c6084015d911116d822838b666032659
MD5 30bcabdea399c77dba2f38922639cf87
BLAKE2b-256 de999723265e4548771bf15f11ceb16dd6257f2655d06896bc0bf042a072fe04

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for poetry_dynamic_caching-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ae0f6e11346785bc5c90166224bcacb4b9cf9effbbe33ab15d7b7ad69f9ecb
MD5 7d53533f365a55d57f5df6276c0f2cb1
BLAKE2b-256 fe27fd4c9e7f039ec407dac00a1d015f9662867b244dcb7654226f00070e831b

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