-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Poetry 1.8 change regarding virtualenvs behaviour (failing ReadTheDocs builds) #9025
Comments
sounds like you have been relying on a bug
recommend not doing that. Seems like you already have a virtual environment: activate it properly - including setting the environment variable - so that poetry can detect it |
As discussed on discord, I suspect the correct fix here is to activate the virtual environment correctly within the build environment as @dimbleby mentioned. In particular, replace this. poetry config virtualenvs.create false With the following. export VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH For my own reference here is a simplified reproducer. podman run --rm -i --entrypoint bash docker.io/python:3.12 <<EOF
set -xe
export PATH="/root/.local/bin:\${PATH}"
OLD_PYTHON=\$(which python)
# not usually recommended
python -m pip install --disable-pip-version-check -q poetry
# do not do this unless there is a REAL reason for it
export POETRY_VIRTUALENVS_CREATE=false
# create a global virtual env
python -m venv global
NEW_PYTHON="\$(realpath global)/bin/python"
# fake activiate it (this is bad practice)
export PATH="\$(realpath global)/bin:\${PATH}"
poetry new demo
pushd demo
poetry add cowsay
# if active python is ignored and system python gets used the package
# appears here
\${OLD_PYTHON} -m pip show cowsay || :
# if active python is correctly detected the package should be here
\${NEW_PYTHON} -m pip show cowsay || :
EOF |
For the record, those are the new instructions in the RTD docs: version: 2
build:
os: "ubuntu-22.04"
tools:
python: "3.10"
jobs:
post_create_environment:
- pip install poetry
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs |
Ok, the snippet above has been merged in the RTD docs as "this is the way". I'll let you decide whether you want to close this issue, leave it open for a few week for visibility or what, but I'm ok with the state of things so far. |
@ewjoachim great work. Thank you. |
It seems we've been relying on a Poetry bug (or at least on a buggy behavior)[1]. This made our documentation builds to stop working with Poetry 1.8[2]: Running Sphinx v7.2.6 making output directory... done Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main app = Sphinx(args.sourcedir, args.confdir, args.outputdir, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__ self._init_builder() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/application.py", line 342, in _init_builder self.builder.init() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/builders/html/__init__.py", line 219, in init self.init_templates() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/builders/html/__init__.py", line 270, in init_templates self.theme = theme_factory.create(themename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/theming.py", line 230, in create raise ThemeError(__('no theme named %r found (missing theme.conf?)') % name) sphinx.errors.ThemeError: no theme named 'sphinx_rtd_theme' found (missing theme.conf?) Theme error: no theme named 'sphinx_rtd_theme' found (missing theme.conf?) [1] python-poetry/poetry#9025 [2] https://readthedocs.org/projects/ts-results-es/builds/23635323/
It seems we've been relying on a Poetry bug (or at least on a buggy behavior)[1]. This made our documentation builds to stop working with Poetry 1.8[2]: Running Sphinx v7.2.6 making output directory... done Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main app = Sphinx(args.sourcedir, args.confdir, args.outputdir, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__ self._init_builder() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/application.py", line 342, in _init_builder self.builder.init() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/builders/html/__init__.py", line 219, in init self.init_templates() File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/builders/html/__init__.py", line 270, in init_templates self.theme = theme_factory.create(themename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/docs/checkouts/readthedocs.org/user_builds/ts-results-es/envs/109/lib/python3.11/site-packages/sphinx/theming.py", line 230, in create raise ThemeError(__('no theme named %r found (missing theme.conf?)') % name) sphinx.errors.ThemeError: no theme named 'sphinx_rtd_theme' found (missing theme.conf?) Theme error: no theme named 'sphinx_rtd_theme' found (missing theme.conf?) [1] python-poetry/poetry#9025 [2] https://readthedocs.org/projects/ts-results-es/builds/23635323/
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option) and have included the output below.Issue
This issue relates to a problem with Poetry and ReadTheDocs (RTD).
The official RTD integration doc advocates for running the following commands:
In the environment this runs in, there is a virtualenv created with
python -mvirtualenv $READTHEDOCS_VIRTUALENV_PATH
and$READTHEDOCS_VIRTUALENV_PATH/bin
is added in the PATH as the first element, thoughVIRTUAL_ENV
is not set.poetry install
added packages to the$READTHEDOCS_VIRTUALENV_PATH
venv.Consequently, packages added this way are not seen by subsequent steps, and the builds fail.
See Discord discussion at https://discord.com/channels/487711540787675139/487711540787675143/1211368925158183004
See RTD corresponding issue: readthedocs/readthedocs.org#11150
The text was updated successfully, but these errors were encountered: