Skip to main content

Load Poetry package sources from environment variables with pydantic > 2

Project description

poetry-source-env

PyPI - Python Version PyPI GitHub release (latest SemVer) PyPI - License Code style: Black

poetry-source-env is a Poetry plugin that lets you define private package sources for your project without exposing their URLs in pyproject.toml. It can load package source definitions from environment variables and expand environment variables in the tool.poetry.source section of pyproject.toml.

This plugin is intended as a workaround for python-poetry/poetry#5958 and will be deprecated if comparable functionality is ever implemented in Poetry itself.

Note that poetry-source-env cannot resolve repositories when installing other Poetry plugins (Poetry does not load plugins when running poetry self commands). If you need a python-poetry/poetry#5958 workaround for installing Poetry plugins, see https://github.com/python-poetry/poetry/issues/5958#issuecomment-1479183720.

Installation

poetry self add poetry-source-env

Usage

Normally, you would define a package source in pyproject.toml like this:

[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple"
priority = "supplemental"

With poetry-source-env, you can define this source via environment variables, similar to how you can already configure publishable repositories:

export POETRY_REPOSITORIES_FOO_URL=https://foo.bar/simple
export POETRY_REPOSITORIES_FOO_PRIORITY=supplemental

If you prefer to keep the source defined in pyproject.toml, you can opt to conceal its name or URL, in whole or in part, behind environment variables:

export FOO_INDEX_NAME="foo"
export FOO_INDEX_URL="https://foo.bar/simple"
[[tool.poetry.source]]
name = "${FOO_INDEX_NAME}"
url = "${FOO_INDEX_URL}"
priority = "supplemental"

If your source requires authentication, Poetry already supports defining its credentials via environment variables:

export POETRY_HTTP_BASIC_FOO_USERNAME=celsiusnarhwal
export POETRY_HTTP_BASIC_FOO_PASSWORD=superdupersecret

Configuration

poetry-source-env's behavior can be configured via the tool.poetry-source-env section of pyproject.toml.

Supported configuration options include:

Name Type Description Required? Default
prefix string The prefix which poetry-source-env should expect source-defining environment variables to use. Has no effect if env is false. No POETRY_REPOSITORIES_
env boolean Whether to read package source definitions from environment variables. No true
toml boolean Whether to expand environment variables in the tool.poetry.source section of pyproject.toml. No true

License

poetry-source-env is licensed under the MIT License.

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_source_env_zp-2.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

poetry_source_env_zp-2.0.4-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file poetry_source_env_zp-2.0.4.tar.gz.

File metadata

  • Download URL: poetry_source_env_zp-2.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Darwin/24.1.0

File hashes

Hashes for poetry_source_env_zp-2.0.4.tar.gz
Algorithm Hash digest
SHA256 94e1ec98d85f0723a8b0857f189da1b795e54541fb95758e68e1d9de570479af
MD5 b1e0d96016c20d54d3fd3e5bd5ab276d
BLAKE2b-256 7b72134028eb92fbfa7dbfecfc9cd84f2a7c42b5ae7e0bd3ef6b6c200cfb8648

See more details on using hashes here.

File details

Details for the file poetry_source_env_zp-2.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_source_env_zp-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 12179702a2d25b5174465c7cbe6fd77b3ce0bfcf9cb322b1af290f0440dbee14
MD5 00d5315558852b8253f386575b651afe
BLAKE2b-256 d1b25e622e22b61fe79fd40a176044101339dd1739d1f8e0cea27b60399acbca

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