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

Fix docs build #252

Merged
merged 7 commits into from
Aug 10, 2024
Merged

Fix docs build #252

merged 7 commits into from
Aug 10, 2024

Conversation

gjoseph92
Copy link
Owner

@gjoseph92 gjoseph92 commented Aug 9, 2024

What a goose chase. Removing --no-isolation got it working. (Previously it didn't work without this.)

The problem, I think, was something about non-isolated PEP-517 build process not fully inheriting the readthedocs virtual environment?

You can see that the Running PEP 517 backend to build a wheel for <Link file:///home/docs/checkouts/readthedocs.org/user_builds/stackstac/checkouts/252 (from None)> fails in a build like this one: https://readthedocs.org/projects/stackstac/builds/25268793/

What I notice in the traceback is that at first, PDM is running in its own self-managed venv in /home/docs/.local:

  File "/home/docs/.local/share/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 86, in wrapper
    raise BuildError(str(e)) from e

But then we get

  File "/home/docs/.local/share/pdm/venv/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
    obj = import_module(mod_path)
  File "/home/docs/.asdf/installs/python/3.8.19/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pdm'

Notice this is running in /home/docs/.asdf instead of /home/docs/.local. So a different environment.

I don't know much about PEP-517 builds or the PDM internals, but my guess here is kinda that, in non-isolated mode, PDM is supposed to ensure that the PEP-517 build-system.requires packages (pdm-pep517) are installed in the current(?) environment, then invoke the Python executable as a subprocess to do the actual build. But I think it's invoking the wrong subprocess / not ensuring that subprocess is in the same environment. So it basically runs "system" Python (the Python shim installed by asdf??), where pdm-pep517 isn't actually installed.

tl;dr I'm guessing that in non-isolated mode, PDM is ensuring pdm-pep517 is installed in the current environment before calling a subprocess to build the wheel, but doesn't actually run that subprocess in the current environment.

@gjoseph92 gjoseph92 marked this pull request as ready for review August 10, 2024 02:20
@gjoseph92 gjoseph92 merged commit 761bf7c into main Aug 10, 2024
1 check passed
@gjoseph92 gjoseph92 deleted the fix-docs-build branch August 10, 2024 02:20
@gjoseph92
Copy link
Owner Author

FYI @frostming. No need to look at this, but if you're interested, maybe there's an issue with non-isolated PEP 517 builds? I don't honestly know if it's a PDM bug, or just that the readthedocs environment setup is so strange. But removing --no-isolation got it to work for now. With that, I was getting ModuleNotFoundError: No module named 'pdm' during the wheel build in the subprocess.

@frostming
Copy link

This PR change is correct. No need to use --no-isolation here.

@gjoseph92
Copy link
Owner Author

Good, thanks. I was just wondering why it failed in that way when I did use --no-isolation, and curious if it was a PDM bug or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants