pytorch / pytorch/audio

CMake cannot fine Python.h when building from source

Open
#3,069 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triaged
Dominant language
Python
Stars
2.9k
Forks
799
Avg merge
58m
Merged PRs (30d)
3

Description

🐛 Describe the bug

I'm attempting to build torchaudio from source, in order to package it for the Homebrew project. (PyTorch is already packaged for Homebrew, so that makes it a lot easier!) However, I'm running into a problem where CMake is unable to find the Python.h header file. It appears that perhaps the CMakeLists.txt file is not searching for it correctly?

Here is a Gist with my work-in-progress Homebrew formula, and the error message that I'm seeing. One of the other Homebrew maintainers (who knows CMake better than I do) noted that it should work if you search for the header file using find_package(Python3 ..., which the top-level CMakeLists.txt file is doing, but only for WIN32, which seems strange. I'm trying to build on a Mac, and getting an error.

Is there someone who can help me figure out how to make this build on Mac?

Versions

0.13.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the top-level CMakeLists.txt and cmake/TorchAudioHelper.cmake, especially the Python3 package lookup currently limited to WIN32. Reproduce the source build on macOS using the linked Homebrew formula and error details. Done means CMake locates Python.h and the torchaudio build proceeds on that platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.