Skip to main content

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.

Metadata

Release files for poetry-source-env-zp 2.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poetry-source-env-zp 2.0.8
File Size Uploaded
poetry_source_env_zp-2.0.8.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poetry-source-env-zp 2.0.8
File Interpreter ABI Platform
poetry_source_env_zp-2.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / poetry_source_env_zp-2.0.8.tar.gz

Download URL poetry_source_env_zp-2.0.8.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5230c9ea2edd70d9cdbdbc7f98bab7db9ba62cbf2b33cd34cb33e71c9321e728
BLAKE2b-256 checksum
How to use checksums
0b2845dfaaf912f32c433266efd84168a54b34c214769a6c6fc47d1f44efa73c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.3 Darwin/24.3.0

Release files / poetry_source_env_zp-2.0.8-py3-none-any.whl

Download URL poetry_source_env_zp-2.0.8-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
801f369436eb7a0a8bce90ba25db6be52103c6948434bf6155eeb211205c5488
BLAKE2b-256 checksum
How to use checksums
b393c6a9c3df7ab2ad196a1db6cbfbdf98e3f679dc2ddb2eeb5fa90d5ab819b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.12.3 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

2.0.8 This release

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page