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

Fix kiwisolver recipe fatal error: 'Python.h' file not found #3118

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

mriscoc
Copy link
Contributor

@mriscoc mriscoc commented Mar 6, 2025

From #3115: Fixes the problem with the KiwiSolver recipe in the current develop branch of pythonforandroid.

Error to fix:

[DEBUG]:        running build_ext
[DEBUG]:        building 'kiwisolver._cext' extension
[DEBUG]:        creating build/temp.linux-x86_64-cpython-311/py/src
...
[DEBUG]:        In file included from py/src/constraint.cpp:10:
[DEBUG]:        In file included from /tmp/build-env-lzty91e_/lib/python3.11/site-packages/cppy/include/cppy/cppy.h:16:
[DEBUG]:        /tmp/build-env-lzty91e_/lib/python3.11/site-packages/cppy/include/cppy/defines.h:10:10: fatal error: 'Python.h' file not found
[DEBUG]:        #include <Python.h>
[DEBUG]:                 ^~~~~~~~~~
[DEBUG]:        1 error generated.
[DEBUG]:        error: command '/usr/bin/ccache' failed with exit code 1
[DEBUG]:   
[DEBUG]:        ERROR Backend subprocess exited when trying to invoke build_wheel

buildozer.spec:

requirements = python3,kivy,kiwisolver
android.archs = arm64-v8a
p4a.branch = develop
log_level = 2

Minimal test:

import kivy

from kivy.app import App
from kivy.uix.button import Button
from kiwisolver import Variable, Solver

def callback(instance):
  x1 = Variable('x1')
  x2 = Variable('x2')
  xm = Variable('xm')
  constraints = [x1 >= 0, x2 <= 100, x2 >= x1 + 10, xm == (x1 + x2) / 2]
  solver = Solver()
  for cn in constraints:
    solver.addConstraint(cn)
  solver.addEditVariable(xm, 'strong')
  solver.suggestValue(xm, 60)
  solver.updateVariables()
  print(f"xm = {xm.value()}, x1 = {x1.value()}, x2 = {x2.value()}")


class MyApp(App):
  def build(self):
    btn1 = Button(text='Kiwisolver demo', size=(100, 50))
    btn1.bind(on_press=callback)
    return btn1

if __name__ == '__main__':
    MyApp().run()

Fixes the problem with the recipe for KiwiSolver and the current development branch of pythonforandroid.
@mriscoc mriscoc changed the title Fix kiwisolver recipe error: no PYTHON path Fix kiwisolver recipe fatal error: 'Python.h' file not found Mar 6, 2025
@AndreMiras
Copy link
Member

Thanks for the pull request @mriscoc
CI was failing and was fixed in #3119
Do you mind rebasing to develop, so that the CI runs on your PR.
Assuming you named the remote "upstream" you can use this command:

git pull --rebase upstream develop
git push -f

@AndreMiras
Copy link
Member

Thanks, I guess a git pull does the job too, I can always squash/rebase upon merging.
Ubuntu tests are passing, but not macOS ones, do you have an idea why?
I'll try to build prior the change to simply make sure it's not a regression and we're good for a merge.

@mriscoc
Copy link
Contributor Author

mriscoc commented Mar 7, 2025

Thanks, I guess a git pull does the job too, I can always squash/rebase upon merging. Ubuntu tests are passing, but not macOS ones, do you have an idea why? I'll try to build prior the change to simply make sure it's not a regression and we're good for a merge.

Sorry, I don't know why it doesn't work on MacOS, it also fails on kiwisolver, maybe something to do with the compiler?

@AndreMiras
Copy link
Member

Sorry, I don't know why it doesn't work on MacOS, it also fails on kiwisolver, maybe something to do with the compiler?

Yeah I haven't dug too much into it, but I tried to build it from develop and on macos-13 (not 14) and it's also not building, so I'll assume this isn't a regression from your PR. I'm good with merging, thanks again

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks you all for looking this up

@AndreMiras AndreMiras merged commit ceed049 into kivy:develop Mar 7, 2025
25 of 33 checks passed
@mriscoc mriscoc deleted the Fix_KiwiSolver branch March 7, 2025 08:56
Comment on lines +15 to +16
env["CFLAGS"] = flags
env["CPPFLAGS"] = flags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mriscoc I'm seeing this late, but why didn't we append the flags rather than overriding?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, that might be the reason macos runner might be failing. (Btw I am to blame for this)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the recipe wasn't building anyway, so overall situation is better than the previous state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants