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

sphinx builds locally but not via github action #102

Open
ablot opened this issue Feb 6, 2024 · 5 comments
Open

sphinx builds locally but not via github action #102

ablot opened this issue Feb 6, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@ablot
Copy link

ablot commented Feb 6, 2024

Describe the bug
A clear and concise description of what the bug is. If possible, please submit a Minimal Reproducible Example.

After starting my repository, sphinx-build docs/source docs/build works locally on my machine (in my conda environement) but when pushing I get import errors. For instance:

Extension error (sphinx.ext.autosummary):
Handler <function process_generate_options at 0x7fecb6b64cc0> for event 'builder-inited' threw an exception (exception: no module named image_tools.registration.masked_phase_correlation)
Error: Process completed with exit code 2.

It's not a typo or naming error, any import from my repo (image_tools) fails, as if sphinx was running from an environment before installing the package. Do I need to add steps to configure?

To Reproduce
Please enter full details of how to reproduce this bug.

Run the cookiecutter and push to main

Expected behaviour
A clear and concise description of what you expected to happen.

Successful build

@ablot ablot added the bug Something isn't working label Feb 6, 2024
@niksirbi
Copy link
Member

niksirbi commented Feb 6, 2024

Hi @ablot, thanks for raising this!
I think I've encountered something like this before. Here is what I think is happening:

When GitHub actions build the docs, they do it in a separate environment in which they install the requirements that are specific to the docs, i.e. those defined in docs/requirements.txt. Your own package, and its requirements (the ones defined in pyproject.toml) are not automatically installed during this process.

To solve your issue, you'd have to add -e . to the docs/requirements.txt file (see example). This will force the relevant GitHub Actions to also install your own package (from the repo source) in the environment in which the docs are built.

Please do let me know if this solution works for you. If yes, we will make sure to adjust the README or even include -e . in docs/requirements.txt by default.

@ablot
Copy link
Author

ablot commented Feb 6, 2024

Indeed! Success ✅
Thanks!

@niksirbi
Copy link
Member

niksirbi commented Feb 6, 2024

@adamltyson what do you think about including -e . to the docs/requirements.txt file by default?

@adamltyson
Copy link
Member

I didn't know you could do this, but if it works, sounds good. Would be worth documenting it though in case it causes any unforeseen issues.

@niksirbi
Copy link
Member

niksirbi commented Feb 6, 2024

Agreed. In theory, you don't need it if your are not building API docs, but I guess most people will be using it in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants