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
45 stars 11 forks source link

Read config from pyproject.toml #18

Closed georgexsh closed 3 months ago

georgexsh commented 6 months ago

try to configure the mirror url in pyproject.toml doesn't work:

[tool.poetry.plugins.pypi_mirror]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"

using: poetry 1.8.3 poetry-plugin-pypi-mirror 0.4.2

I guess poetry doesn't support access tool.poetry.plugins.* via poetry.config interface?

georgexsh commented 6 months ago

It is possible to retrieve pypi_mirror.url from poetry._pyproject.poetry_config object, but obviously this is not a public API:

(Pdb) pp poetry.pyproject.poetry_config['plugins']['pypi_mirror']
{'url': 'https://example.net/simple'}
JacobHenner commented 5 months ago

Hi @georgexsh,

Could you explain your use-case a bit more? Typically this plugin is used when all requests for PyPI.org are intended to be directed to a mirror/pull-through cache, without introducing changes to pyproject.toml that would make it difficult to collaborate with others who would not be using the same mirror.

If you're going to be editing pyproject.toml, why not declare a new primary source without adding PyPI?

georgexsh commented 3 months ago

why not declare a new primary source without adding PyPI?

changing the primary source would indroduce too much noise to the lock file.

without introducing changes to pyproject.toml that would make it difficult to collaborate with others

this makes sense, I've switched to using environ to config the mirror, thanks!