Closed Bug 1680162 Opened 3 years ago Closed 3 years ago

./mach bootstrap fails with "psutil/_psutil_common.c:9:10: fatal error: 'Python.h' file not found"

Categories

(Firefox Build System :: Bootstrap Configuration, defect)

defect

Tracking

(firefox-esr78 unaffected, firefox83 unaffected, firefox84 unaffected, firefox85 fixed)

RESOLVED FIXED
85 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox83 --- unaffected
firefox84 --- unaffected
firefox85 --- fixed

People

(Reporter: dholbert, Assigned: mhentges)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

STR:
(Steps 1 and 2 are to put you into a state where bootstrap will attempt to rebuild psutil. Step 3 puts you into a "freshly installed OS" state, from the perspective of this bug. Step 4 triggers the actual issue.)

  1. Delete your $HOME/ .cache/pip directory (because it might contain a cached precompiled version of psutil).

  2. Delete your $MOZBUILD_STATE_PATH/_virtualenvs directory.

  3. Remove your linux distro's packages for python-dev and python3-dev. e.g. on Ubuntu, run:
    sudo apt-get remove python-dev python3-dev && sudo apt-get autoremove

  4. ./mach bootstrap, choose option 2, and accept all the default options.

ACTUAL RESULTS:
This error:

Building wheels for collected packages: psutil
  Building wheel for psutil (setup.py) ... error
  ERROR: Command errored out with exit status 1:
[...SNIP...]
  psutil/_psutil_common.c:9:10: fatal error: 'Python.h' file not found
  #include <Python.h>
           ^~~~~~~~~~
  1 error generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psutil
  Running setup.py clean for psutil
Failed to build psutil

This is the same as bug 1679616, except on developers' machines rather than in CI.

I think we need to update the various mozboot files like https://searchfox.org/mozilla-central/source/python/mozboot/mozboot/debian.py in order to address this. I only have Ubuntu locally, so that's all I can test, so I'll only try to fix it there for now.

Hmm -- I was hoping that I could just fix this by adding python-dev and python3-dev to that mozboot debian.py file's COMMON_PACKAGES list, but that doesn't quite fix this after all, because it looks like we don't try to install COMMON_PACKAGES until after we've set up the _virtualenv and failed to compile psutil.

I think this strawman fix would work if you run bootstrap twice (with the second invocation only being useful to install psutil), but that's kinda sloppy.

mhenteges, do you know if there's a cleaner/better fix here?

Flags: needinfo?(mhentges)

(I posted the strawman patch purely for reference, BTW; I'm not intending to take this bug myself, though we could theoretically push the strawman patch as a stopgap if there's in fact nothing better that we can do. If you know the right way to fix this, please proceed and don't worry about stepping on any toes. :))

Set release status flags based on info from the regressing bug 1666345

Assignee: nobody → mhentges
Flags: needinfo?(mhentges)
Status: NEW → ASSIGNED

Heh, thanks for the report! The CI-specific issue should've tipped me off that this was possible on dev machines too :)
We have a similar chicken-and-egg problem around needing a compiler to build python packages, but installing the compiler via a python script (which depends on the python environment, which depends on the packages).
I'll take a look to remember how we solved that, and to see if a similar approach can be used here.

Native python packages will probably require python headers. For some
systems, these are available in a separate system package (such as
python[3]-dev).

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1a5dcdffe6c1
Install python packages after system packages r=firefox-build-system-reviewers,glandium
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: