-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add: hatch plus meson-python python package example to guidebook #274
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected indirection bug
static PyObject * | ||
temperature_celsius_to_fahrenheit(PyObject *self, PyObject *args) | ||
{ | ||
long celsius; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend adding fahrenheit variable and make the assignment correctly named (fahrenheit = ...celsius and celsius = ...fahrenheit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great suggestion. All seems to work now, thanks!
Co-authored-by: Ken Seehart <ken@seehart.com>
@all-contributors please add @ryanskeith -- Ryan THANK YOU for your help with this pr. Cheng shared your GH handle with me! hey @ucodery i know we have a LOT of pr's to go through - i'm just adding ryan here as a contributor since he was so so helpful in getting this package to correctly install. Ken more from me as well once i've caught up a bit more! you all are amazing! i know the community will really benefit from this PR in a BIG WAY! |
I couldn't determine any contributions to add, did you specify any contributions? I couldn't determine any contributions to add, did you specify any contributions? I couldn't determine any contributions to add, did you specify any contributions? |
@all-contributors please add @ryanskeith @kenseehart for code, review |
I've put up a pull request to add @ryanskeith! 🎉 |
@all-contributors please add @kenseehart for code, review |
I've put up a pull request to add @kenseehart! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ucodery i have a few questions but we can merge this. my questions
- license - it's super tiny but should we be consistent in all of our packages?
- This is a hatch question - i had understood that there was something more complex about hatch that required plugins or something custom to be able to use hatch with other back ends? But in this case, we were running hatch build to build the package and then we were installing it and it ran.
to me (bare with me i'm still learning about extensions) - i don't see any plugins here just a meson.build file (well two of them) and a pyproject.toml + init file.
am i missing something?
examples/extension-hatch/meson.build
Outdated
'examplePy', | ||
'c', | ||
version: '0.1.dev0', | ||
license: 'BSD-3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use MIT throughout as that is the generally recommended (simpler) license? Choose a license suggests it and we decided to go that route too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't even notice. I took this part right from the scientific python example and didn't proof. I can change it to MIT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! yes lets change.
@@ -0,0 +1,3 @@ | |||
An example Python package used to support Python packaging tutorials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ucodery could you add a bit more about how this works with meson-python? the key elements that make it work which i suspect are the meson.build files?
it seems like hatch just magically recognizes it and then builds for us. thank you AGAIN for this. i know this was a lot of work between you - @kenseehart and @ryanskeith !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "magic" is that this project declares mesonpy
as its backend in pyproject.toml, which is a universal tool-agnostic standard. Hatch is compliant with PEP standards, thus it acquiesces and when asked to build the project uses mesonpy to create the wheel, which hatch can then do more tool-agnostic actions with, like install locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so related to below - what i'm remembering is folks arguing about hatch's approach to plugins ... i could probably find it for you. this might have been BEFORE pycon 2023 (so before we met) ... and that argument could actually have been around hatchling (the backend) and at the time hatch did NOT support other backends.
this makes sense to me now. thank you for the explanation. in this case i think you are saying hatch the front-end tool just runs build and build knows to use mesonpy which knows to find the meson.build file? so everything just works as it should.
It is not more complex than you perceive. To build a Python distribution that links to foreign code, the author must choose a backend that supports compiling/ linking to that foreign code (mesonpy being a prime example). Once chosen this backend must be designated in the pyproject.toml Once that is done the author (and any uses of the source) are free to use any frontend they want. Here we used Hatch and because PEP-517/518 are almost universally supported it just works. Hatch has always worked this way. What I think you are remembering, and what is a potentially more complex setup, is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ucodery once you've made the license update to MIT please merge! :)
addresses #252