I am currently developing a toolbox as a Python package. I have written the documentation using sphinx, and I am in the process of uploading the documentation to ReadTheDocs. My package has a bunch of dependencies, including PyAudio. I know from other posts that PyAudio needs PortAudio to function properly. However, it seems that to build the documentation from my GitHub repository, ReadTheDocs uses a virtual environment to compile it, and I keep on getting the following error:
ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects
Here is the content of my pyproject.toml
file:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my_toolbox"
version = "0.0"
authors = [
{ name="Ann Onym", email="ann.onym@example.com" },
]
description = "A cool toolbox"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
]
dependencies = [
"scipy >= 1.11.0, < 2",
"numpy >= 1.25.0, < 2",
"chardet >= 5.2.0, < 6",
"matplotlib >= 3.7, < 4",
"seaborn >= 0.12.2, < 1",
"opencv-python == 4.8.0.76",
"openpyxl >= 3.1, < 4",
"pygame >= 2.5, < 3",
"PyAudio >= 0.2.13, <1",
"praat-parselmouth > 0.4, < 1"
]
[project.urls]
"Homepage" = "https://github.com/AnnOnym/MyCoolToolbox"
"Bug Tracker" = "https://github.com/AnnOnym/MyCoolToolbox/issues"
"Documentation" = "https://mycooltoolbox.readthedocs.io/en/latest/"
Finally, here's the content of my requirements.txt
file:
sphinx==7.0.1
sphinx_rtd_theme==1.3.0
sphinx-autodoc-typehints==1.24.0
scipy == 1.11.0
numpy == 1.25.0
matplotlib == 3.7
opencv-python == 4.8.0.76
openpyxl == 3.1
pygame == 2.5
praat-parselmouth == 0.4.3
chardet == 5.2.0
PyAudio == 0.2.13
seaborn == 0.12.2
If I remove PyAudio from the dependencies or requirements, the documentation compiles on the ReadTheDocs... But I want to keep the package in the dependencies so that PyAudio gets installed if someone installs my module.
From what I understand, the problem is that the virtual environment used for compiling the documentation does not have PortAudio... How do I specify to ReadTheDocs that I need it to compile (or that ReadTheDocs doesn't need PyAudio to compile the documentation anyway)?
Thanks!
After tweaking around, I found the answer! I will leave it here for posterity.
The problem was not in pyproject.toml
, but rather in .readthedocs.yaml
. Here it is:
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
apt_packages:
- portaudio19-dev
python:
install:
- requirements: docs/source/requirements.txt
- method: pip
path: .
extra_requirements:
- docs
sphinx:
configuration: docs/source/conf.py
The important part being to add apt_packages: -portaudio19-dev
so that the virtual environment can then create the wheel for PyAudio.