gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
240 stars 49 forks source link

Fix docs build #252

Closed gjoseph92 closed 1 month ago

gjoseph92 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

gjoseph92 commented 1 month ago

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.