Skip to main content

Load Poetry package sources from environment variables

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.

Installation

poetry self add poetry-source-env

Usage

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

[[tool.poetry.source]]
name = "my-epic-source"
url = "https://pkg.celsiusnarhwal.dev"
default = false
secondary = false

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

export POETRY_REPOSITORIES_MY_EPIC_SOURCE_URL=https://pkg.celsiusnarhwal.dev
export POETRY_REPOSITORIES_MY_EPIC_SOURCE_DEFAULT=false
export POETRY_REPOSITORIES_MY_EPIC_SOURCE_SECONDARY=false

If you prefer to keep the source defined in pyproject.toml, you can opt to conceal parts of its definition behind environment variables:

export INDEX_URL="https://pkg.celsiusnarhwal.dev"
[[tool.poetry.source]]
name = "my-epic-source"
url = "${INDEX_URL}"
default = false
secondary = false

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

export POETRY_HTTP_BASIC_MY_EPIC_SOURCE_USERNAME=celsiusnarhwal
export POETRY_HTTP_BASIC_MY_EPIC_SOURCE_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-1.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

poetry_source_env-1.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file poetry_source_env-1.1.0.tar.gz.

File metadata

  • Download URL: poetry_source_env-1.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.1 Linux/5.15.0-1036-azure

File hashes

Hashes for poetry_source_env-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bdad5a6d629512f4c2c1408319fcf1082647a16fc757a64a3aec200ff7e6620f
MD5 941126ddcb6b5d64830f746f733e88d3
BLAKE2b-256 2f9469416b9e18932a904f0b6a68acff920c5964a506a9c989d8aa70fd92397c

See more details on using hashes here.

File details

Details for the file poetry_source_env-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: poetry_source_env-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.11.1 Linux/5.15.0-1036-azure

File hashes

Hashes for poetry_source_env-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d618f43bb1a906e9895d94e18e8a50310236b5e121aa867ed48fa17d205992
MD5 3ad4848e0f839f2c88a67061c5804cbe
BLAKE2b-256 3e44413af0224437a6feb11d673d13f65b27a8f43ec751db5bb8da16939b0794

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page