arcesium / poetry-plugin-pypi-mirror

Poetry plugin that adds support for pypi.org mirrors and pull-through caches
BSD 3-Clause "New" or "Revised" License
43 stars 11 forks source link

Support for several pypi mirrors? #6

Open lucharo opened 1 year ago

lucharo commented 1 year ago

Hi,

First of all thanks for writing this plugin. I write packages in a corporate environment with no access to pypi and poetry was for my purpose unusable or at least quite annoying to use because of this lack of support of a global pypi url.

I happen to actually use several pypi mirrors for downloading packages in my environment. Does your plugin support having several mirrors configured and if so how would I set that up in the poetry config file?

lucharo commented 1 year ago

I envision the config being similar to secondary source in the standard pyproject.toml.

[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
default = false
secondary = false

https://python-poetry.org/docs/repositories/#private-repository-example

lucharo commented 1 year ago

The overall implementation I am thinking is that you could have the config file looking like the one below and even include credentials there:

[plugins]
[plugins.pypi_mirror.example_repo]
url = "https://example.org/repository/pypi-proxy/simple/"

[plugins.pypi_mirror.enterpise_repo_1]
url = "https://myenterprise.org/pypi/simple"
username = "me"
password = "s3cr3t"

[plugins.pypi_mirror.enterpise_repo_2]
url = "https://myenterprise.org/pypi-internal/simple"
username = "me"
password = "s3cr3t"

And then have that handled in your src/plugins.py:

https://github.com/arcesium/poetry-plugin-pypi-mirror/blob/b650dc5e97945e0c9d52483da3a93ed08ce759ad/src/poetry_plugin_pypi_mirror/plugins.py#L31-L33

I am not familiar on how to parse toml so I am going to try an open a PR implementing this, I might need help on the handling credentials side of things