Haiku-PyAPI: Python bindings for the Haiku API

We have text boxes, buttons, text, and windows to put them in. I suppose those are all of the essential widgets.

Then I suppose now is the time for 0.1.

2 Likes

The 0.1 release is done! You can now install haiku_pyapi_python39 and haiku_pyapi_python310 from HaikuDepot.

11 Likes

I’ve tried targeting abi3 (by adding -DPy_LIMITED_API=0x030900 to SubDirC++Flags on the Jamfile, but sadly, that’s a no go, as pybind11 seems to use/need plenty of stuff outside of what’s available when Py_LIMITED_API is defined. Oh well… was worth a try :slight_smile:.

BTW, when trying that define, the build seemed to enter a loop, and was kinda hard to kill all the jam related processes.

On the plus side… got PyAPI working on 32 bits (haiku_pyapi_x86_python310). Created a PR for the needed changes on Haiku-PyAPI’s side (the recipe changes will have to wait for a 0.2 release :stuck_out_tongue:).

3 Likes

This actually seems like it’s possible, see an example of how to register plugins using decorators for an idea of how this would be done.

The main issue I could see would be the lifespan, ownership and construction time of the BMessage object.

Yes. For some functions, I think you want to copy into a new BMessage. Constructors for subclasses of Invoker, at least. Probably others.

I talked with @coolcoder613 over IRC about this. The trouble is that the function decorators don’t have access to the class’s members. This is because the decorators don’t take a parameter for self.

If you would like to know more, you can visit Python decorators in classes.

A Haiku about a Python API:

App, Support, Storage,
And all the rest, for Python
Now available!

I think it’s about time I start working on releasing v0.2, since the app kit is pretty much done.

11 Likes

We’re encountering some errors when compiling for R1/B4 and not when compiling on a nightly. One commit that is causing these discrepancies is https://git.haiku-os.org/haiku/commit/?id=3cb845283eb430c9b905dc0b17d83e5ff8f0c0de. It names some previously unnamed enums. Thanks @trungnt2910, it makes our code cleaner :slight_smile: . But now the question is whether we should support R1/B4, and make our code a little messier, or just make sure it runs on R1/B4. It must be about time to release R1/B5 :wink: .

2 Likes

Thanks @trungnt2910, it makes our code cleaner :slight_smile: .

Not a Python enthusiast myself, but great to hear that my code has made positive impact beyond my own projects :slight_smile:

whether we should support R1/B4

Beta releases are probably called “Beta” for a reason. Things are bound to change, even among Haiku apps themselves. Therefore, in my opinion, it is not really worth it.

Depends on who’s going to be using it. If you see someone picking this up in the first week of the Haiku experience, then it has to support the official release (even if it’s named “beta”, it’s what we have.) If it’s more a die-hard fringe, maybe not as important.

(I don’t know anything you don’t know, but quite a while can elapse between releases. I wouldn’t hold my breath.)

2 Likes

The question is, when is R1/Beta5 coming out?
If it is coming in late 2024 or something, then we should try to support beta4.
But if beta5 is coming soon, we’ll just wait until then to support the latest beta.

Yes, it certainly would be useful to know when the next beta will be released.

Yes, it should run on R1/B4, though I haven’t tested it. The question is just whether to make the code a little messier to support compiling on it.

The more “official” version is Beta4. A new beta may take a long to be released, so it would be better if the software is tested to run in the Beta4. The nightlies, as explained, are test releases and can break things any time.

Do the buildmasters run on beta4 or the nightlies?

The buildmasters run Beta4. To be more precise: haiku-r1~beta4_hrev56578_87-1 at the moment.

Ok, in that case we’ll probably have to support compiling on R1/B4

1 Like

Yes, the entire OS is in beta, which means mostly feature complete but with bugs.
The beta releases themselves get updates but only minor bugfixes, no big compatibility breaking changes.

The nightlies on the other have have no compatibility promises.

28 posts were split to a new topic: Haiku-PyAPI app: Feed aggregator BGator2 (name may change)

Haiku-PyAPI 0.2 has been released :tada:. In 0.1, pretty much the app kit and a little bit of the interface kit were available. Now, a good many other kits are available.

Here are some apps that you can run with it:

Special thanks to @TmTFx and @coolcoder613 for their work!

16 Likes