Closed zaneselvans closed 4 years ago
Yes, that requirement is being installed becuase of https://github.com/catalyst-cooperative/pudl/blob/5e075d40d76fcf70d763b3661d91c864026f8723/.readthedocs.yml#L22
You can use the READTHEDOCS
environment variable on your setup.py
file
https://docs.readthedocs.io/en/stable/builds.html#build-environment
Hmm. I added that pip install
because otherwise the pudl
package (which is what I'm trying to document!) wasn't getting installed and everything was failing. It seemed odd that additional action was required to get get my own package to install. Is there a different/better way to get the package you're trying to document installed? Some default I've totally missed that wouldn't create this complication?
Are you suggesting generating different lists of install_requires
packages in setup.py
depending on the build environment? Like if READTHEDOCS
then don't require python-snappy
?
Are you suggesting generating different lists of install_requires packages in setup.py depending on the build environment? Like if READTHEDOCS then don't require python-snappy?
Yes
Is there a different/better way to get the package you're trying to document installed?
The way you are installing the project is correct.
Another way is modifying the sys.path
in your conf.py file http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
Thanks for the explanation! I realized after you explained this why I had moved to installing our package rather than just adding it to sys.path
-- I'm using setuptools_scm
to automatically generate the package version, and to access it using pkg_resources.get_distribution()
I need the package to actually be installed, not just importable. Conditionally including python-snappy
in the install_requires
based on the READTHEDOCS
environment variable worked, so this is solved now.
I also posted the question (and more details on the answer) over on Stack Overflow in case anyone else has this issue.
Details
I am attempting to build documentation for a project that depends on packages that include code written in C. For the packages beyond those available via the Read the Docs
system_packages
setting (numpy
,scipy
,pandas
, andmatplotlib
) which fail to compile, I am attempting to mock the modules/packages for import, usingautodoc_mock_imports
in myconf.py
. However, there must be something I don't understand about the process because it keeps trying to compile these modules anyway.The module that is giving me issues right now is the
snappy
compression library, which requires thelibsnappy-dev
(Debian) package to be installed. The python package which provides it is calledpython-snappy
(My assumption was that it's the module name and not the package name that needs to be listed inautodoc_mock_imports
-- but I've tried both to no effect.Like the
system_packages
I have commentedpython-snappy
out in therequirements.txt
file associated with the doc build (which is the output from apip freeze
). The build log reports that the requirement is being found in my project, which is namedpudl
:So I assume the build is trying to compile it because it's listed in my
setup.py
? But I need to leave it there for the real packaging and installation elsewhere.I have wiped the doc build for this branch (
python-packaging
) and re-tried, with the same result.Expected Result
I thought that by adding
snappy
to the list of modules to be mocked, the build would consider the dependency satisfied and not attempt to compile the package.Actual Result
The build fails because of a missing C language header file: