Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds broken with poetry 1.8 #11150

Closed
etianen opened this issue Feb 25, 2024 · 16 comments · Fixed by #11152
Closed

Builds broken with poetry 1.8 #11150

etianen opened this issue Feb 25, 2024 · 16 comments · Fixed by #11152
Labels
Needed: design decision A core team decision is required

Comments

@etianen
Copy link

etianen commented Feb 25, 2024

Following the install dependencies with poetry guide, I get the following error with poetry 1.8:

no theme named 'furo' found (missing theme.conf?)

However, the theme is clearly installed!

- Installing furo (2024.1.29)

Specifically installing poetry 1.7 with fixes the issue:

- pip install 'poetry~=1.7.0'

I don't see anything in the poetry 1.8 release notes to as a cause for the breakage. If you can pin down what the problem is, I'll gladly follow-up with an issue on the poetry issue tracker. 🙇

Details

Expected Result

The build to pass with poetry 1.8 👍

Actual Result

The build fails with poetry 1.8 👎

@ewjoachim
Copy link
Contributor

Looks like we have the same issue: #11149

@ewjoachim
Copy link
Contributor

I'm noting that 1.8.0 has been released in december, but it only started failing recently, so something changed, that is different in Poetry 1.8.0 and 1.7.0 but chances are it's not poetry itself.

@ewjoachim
Copy link
Contributor

Hmpf, I completely misread. Poetry 1.8 was released 5 hours ago.

@ewjoachim
Copy link
Contributor

ewjoachim commented Feb 25, 2024

So there's python-poetry/poetry#9025 for tracking the issue in Poetry.

So far, it seems it's a consequence of python-poetry/poetry#8970 that makes detection of venv more strict. Because RTD doesn't expose VIRTUAL_ENV, Poetry doesn't consider this a virtualenv, and installs to the base Python instead of the one in the venv.

Poetry folks indicate that RTD should not advocate using poetry config virtualenvs.create false, it only worked because of a bug.

So what now ?

  • Should we use a different technique for installing poetry deps ? (e.g. poetry export + pip install ?)
  • Should we make it so that the build sets the VIRTUAL_ENV envvar as part of the yaml instructions ?
  • Should the VIRTUAL_ENV variable be set by RTD itself for every build ?

Quoting the Poetry discord:

I don't think there is an official way to use a specific python, which is not an activated venv. You can only fake an activated venv by setting PATH and VIRTUAL_ENV.

@etianen
Copy link
Author

etianen commented Feb 25, 2024 via email

@humitos humitos added the Needed: design decision A core team decision is required label Feb 25, 2024
@dimbleby
Copy link

Should the VIRTUAL_ENV variable be set by RTD itself for every build ?

If that means that the variable is also set at the moment that you execute pip install poetry - then this also is not correct. Poetry must be in a different environment than the project under management: else installing the project dependencies can break the environment for poetry.

I do not see a solution that can avoid changing the instructions.

(This probably means that both poetry and readthedocs will be dealing with duplicate reports of this for some time to come: until fixed instructions eventually work their way through the system...)

@etianen
Copy link
Author

etianen commented Feb 25, 2024 via email

@humitos
Copy link
Member

humitos commented Feb 25, 2024

How about making pipx be available on runners (maybe it is already?!).

It's not, but it can be installed via

python3 -m pip install --user pipx
python3 -m pipx ensurepath

(from https://pipx.pypa.io/stable/#on-linux)

If that's the best way to install and execute poetry, we can update the documentation to reflect that.

@humitos
Copy link
Member

humitos commented Feb 25, 2024

Poetry folks indicate that RTD should not advocate using poetry config virtualenvs.create false

This is required because there are other Python commands executed by Read the Docs (e.g. sphinx-build) that need to be executed using the current virtualenv where all the requirements were installed --that's why poetry and the requirements for building the documentation has to be installed in the same virtualenv.

These commands are executed by Read the Docs,

python -m pip install --upgrade --no-cache-dir pip setuptools              
python -m pip install --upgrade --no-cache-dir sphinx readthedocs-sphinx-ext
python -m sphinx -T -b html -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html

and these should work without any modification. Note that we cannot prepend them with pipx run or similar.

@etianen
Copy link
Author

etianen commented Feb 25, 2024 via email

@humitos
Copy link
Member

humitos commented Feb 25, 2024

I'm happy to update our documentation with a different solution if you have one that does work for this particular use case.

It would be lovely to have pipx already installed

Unfortunately, we can't do this in the short term at least; but it's easy to install it as I showed before.

@humitos
Copy link
Member

humitos commented Feb 25, 2024

@ewjoachim

Poetry folks indicate that RTD should not advocate using poetry config virtualenvs.create false, it only worked because of a bug.

BTW, do you know what's the bug that they fixed that changed this behavior? Their documentation for virtualenvs.create (https://python-poetry.org/docs/configuration#virtualenvscreate) still says that it should work in the way we expect to work: don't create a new virtualenv when installing dependencies --but it seems it doesn't work like that anymore.

@etianen
Copy link
Author

etianen commented Feb 25, 2024 via email

@ewjoachim
Copy link
Contributor

BTW, do you know what's the bug that they fixed that changed this behavior? Their documentation for virtualenvs.create (python-poetry.org/docs/configuration#virtualenvscreate) still says that it should work in the way we expect to work: don't create a new virtualenv when installing dependencies --but it seems it doesn't work like that anymore.

Not really. They don't create a virtualenv, so it works as intended. The behaviour is "if we're in a venv, use the venv. If not, install to the system python."
Because RTD doesn't set VIRTUAL_ENV (as virtualenv and python -m venv do when using source bin/activate), they don't detect they're in a virtualenv, so they don't do that. I suspect that they used to do something along the lines of python -m pip ... and they now do $(readlink python) -m pip ... (if they don't detect a venv). I don't think it contradicts the doc.

@ewjoachim
Copy link
Contributor

For the record, I got a running build in RTD with:

version: 2

build:
  os: "ubuntu-22.04"
  tools:
    python: "3.10"
  jobs:
    post_create_environment:
      - python -m pip install poetry
    post_install:
      - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --with docs

I'll open a PR for this to become "the way". When we can improve this, we will.

@jfagoagas
Copy link

For the record, I got a completed build in RTF with:

version: 2

build:
  os: "ubuntu-22.04"
  tools:
    python: "3.11"
  jobs:
    post_create_environment:
      # Install poetry and the export plugin for pip
      - python -m pip install poetry poetry-plugin-export
    post_install:
      - poetry export -f requirements.txt --without-hashes --only docs -o only-docs.txt
      - pip install --requirement only-docs.txt

I prefer you workaround @ewjoachim since is simpler.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: design decision A core team decision is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants