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

plugin should warn if POETRY_PYPI_MIRROR_URL is not set #1

Closed mfriedenhagen closed 1 year ago

mfriedenhagen commented 2 years ago

After install the plugin with poetry self add poetry-plugin-pypi-mirror I forgot to set the environment variable.

When running poetry install in a project without a lock file, poetry was stuck:

❯ poetry install   
Creating virtualenv mamyp2-anHiv22_-py3.10 in /Users/XXX/Library/Caches/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (470.3s)^C

It looks like https://github.com/arcesium/poetry-plugin-pypi-mirror/blob/05cd8dd5604394b6e19d440610c1c5122a6e3187/src/poetry_plugin_pypi_mirror/plugins.py does always return immediately and may no repositories are set?

After setting the environment variable, it ran tremendously fast (< 2 seconds) and succeeded.

System setup:

❯ poetry -V     
Poetry (version 1.2.2)

❯ poetry env info

Virtualenv
Python:         3.10.8
Implementation: CPython
Path:           /Users/XXX/Library/Caches/pypoetry/virtualenvs/mamyp2-anHiv22_-py3.10
Executable:     /Users/XXX/Library/Caches/pypoetry/virtualenvs/mamyp2-anHiv22_-py3.10/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.10.8
Path:       /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10
Executable: /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/bin/python3.10
JacobHenner commented 2 years ago

When running poetry install in a project without a lock file, poetry was stuck

mfriedenhagen commented 2 years ago

So basically resolving the dependencies does not work.

JacobHenner commented 2 years ago
  • I do have access to the internet from my workstation (but not from our CI-system, there I have to go via an Artifactory instance).

    • This was a new project without a poetry.lock file.

    • Given I unset POETRY_PYPI_MIRROR_URL and poetry.lock does exist When I run poetry install again Then everything is fine. poetry does not need no resolve stuff but probably just checks the SHASUMs.

    • GIven I change the environment (poetry env use /usr/local/bin/python3.9) and poetry.lock does exist When I run poetry install Then poetry is able to install all dependencies into the new environment.

    • Given I delete poetry lock And use the python3.9 environment When I run poetry install Then poetry runs into a timeout.

    • Given I delete poetry lock And use the python3.9 environment When I run poetry lock Then poetry runs into a timeout.

    • Given I set POETRY_PYPI_MIRROR_URL And use the python3.9 environment When I run poetry lock Then the lock file is created in 5 seconds.

    • Given poetry.lock does exist And I unset POETRY_PYPI_MIRROR_URL When I run poetry lock again Then I run into a timeout again.

So basically resolving the dependencies does not work.

This is the behavior you run into within your CI system, right? Do you also encounter this on your workstation that has access to pypi.org?

mfriedenhagen commented 2 years ago

No, this is the behavior on my workstation where I have access to pypi.org but forgot the set the environment variable.

JacobHenner commented 2 years ago

I have not been able to reproduce the condition you're encountering, could you run through the steps you're following with -vvv appended and share the output?

As for displaying a warning in general when POETRY_PYPI_MIRROR_URL is not set, I'm not sure if this is the right behavior. I imagine that there are situations where the plugin is installed yet the user would like to use a PyPI mirror in some situations but not others. Displaying a warning would be disruptive when the user has deliberately left POETRY_PYPI_MIRROR_URL, and AFAIK there's no way to toggle plugins on/off easily (e.g. per-project).

Perhaps the plugin should keep track of projects that used a mirror at some point, and warn when poetry interacts with those projects subsequently without POETRY_PYPI_MIRROR_URL set? I'd need to think about this possibility some more, and decide how information about such projects would be persisted.