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

Docs build.job recipe for poetry does not work with newer versions #9740

Closed
davidorme opened this issue Nov 17, 2022 · 4 comments · Fixed by #9743
Closed

Docs build.job recipe for poetry does not work with newer versions #9740

davidorme opened this issue Nov 17, 2022 · 4 comments · Fixed by #9743
Assignees
Labels
Accepted Accepted issue on our roadmap Needed: documentation Documentation is required

Comments

@davidorme
Copy link

I'm trying to build a site for a package managed using poetry and following the officially documented approach in the build.jobs docs section. That approach now appears to be failing:

https://readthedocs.org/projects/virtual-rainforest/builds/18663328/

The TLDR on that build log error is that the old get-poetry.py install will not install recent versions (>1.2.0a1) and that the new https://install.python-poetry.org approach must be used instead. I tried using that approach:

build:
  os: ubuntu-20.04
  tools:
    python: "3.9"
  jobs:
    post_create_environment:
      # Install poetry
      - curl -sSL https://install.python-poetry.org | python3 -
      # Tell poetry to not use a virtual environment
      - $HOME/.local/bin/poetry config virtualenvs.create false
      # Install project's dependencies
      - $HOME/.local/bin/poetry install

but that doesn't seem to be working: https://readthedocs.org/projects/virtual-rainforest/builds/18663177/

I know that is an apparent error in my package, but it doesn't occur with local sphinx builds and seems like a problem with the installed environment? I think @humitos tried this approach and also had problems with the resulting build environment :

#9445 (comment)

Originally posted by @davidorme in #9445 (comment)

@browniebroke
Copy link
Contributor

browniebroke commented Nov 20, 2022

I also noticed that the docs were out of date and I tried to update them in #9743

I think I'm facing the same issue: my package doesn't get installed. From what I can tell, the last line poetry install doesn't install the dependecies in the right virtualenv.

EDIT: see pull request for improved version:

Old solution (pre-edit)

I managed to make my build work with the following solution:

build:
  os: ubuntu-20.04
  tools:
    python: "3.9"
  jobs:
    post_create_environment:
      # Install poetry
      # https://python-poetry.org/docs/#osx--linux--bashonwindows-install-instructions
      - curl -sSL https://install.python-poetry.org | python3 -
      # Tell poetry to not use a virtual environment
      - $HOME/.local/bin/poetry config virtualenvs.create false
    pre_install:
      # Export project dependencies to requirements.txt
      - $HOME/.local/bin/poetry export --with docs > docs/requirements.txt

python:
  install:
    # Install exported dependencies
    - requirements: docs/requirements.txt
    # Install the current package itself
    - method: pip
      path: .

Not ideal though.

@browniebroke
Copy link
Contributor

From what I can tell, the last line poetry install doesn't install the dependecies in the right virtualenv.

Just expanding a bit on that. I think this is what happens:

  1. RTD installs the specified Python version with asdf
  2. RTD creates a virtualenv using that Python version
  3. The 1st command in post_create_environment installs Poetry using the Python version from step 1
  4. The 3rd command that calls poetry install installs the project dependencies in the global Python from step 1, NOT in the virtualenv from step 2
  5. The rest of the RTD build runs everything in the virtyalenv, where the Poetry dependencies are not installed

@davidorme
Copy link
Author

Maybe there needs to be an added poetry env use ... to tell poetry explicitly which environment to use?

@humitos humitos added Needed: documentation Documentation is required Accepted Accepted issue on our roadmap labels Nov 21, 2022
@davidorme
Copy link
Author

davidorme commented Nov 22, 2022

Just to note that #9743 fixes this for my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Needed: documentation Documentation is required
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants