-
Notifications
You must be signed in to change notification settings - Fork 579
Python wheels #2731
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
base: develop
Are you sure you want to change the base?
Python wheels #2731
Conversation
fix: typo fix: typo fix: dir fix fix fix fix fix fix ci: add libpng ci: add libpng fix
|
I'm sure @hassec will be keen to take a look at this PR |
hassec
left a comment
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.
@shimwell thanks for tagging me!😊
And great to see this PR @akoen!
- I think its worth considering to enhance the
setup.pysuch that apip installcorrectly builds and installs the project. - I'd suggest to add a job to test these wheels as well to ensure that everything is packaged & relocated correctly.
| CIBW_BUILD: "cp311-${{ matrix.cibw-arch }}" | ||
| CIBW_ARCHS_MACOS: x86_64 arm64 | ||
| CIBW_ARCHS_LINUX: x86_64 | ||
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | ||
| CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH="/usr/local/lib64:${LD_LIBRARY_PATH}" PIP_ONLY_BINARY="numpy" | ||
| CIBW_BEFORE_ALL_LINUX: | |
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.
Have you considered moving the cibuildwheel configuration into the pyproject.toml?
I've found that it makes testing the build locally easier.
| @@ -0,0 +1,63 @@ | |||
| name: Build Wheels | |||
|
|
|||
| on: [push, workflow_dispatch] | |||
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.
Might just be because it's still draft but this probably doesn't need to run on every push. I'd suggest to run on every tag creation.
| add_custom_command(TARGET openmc POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy | ||
| $<TARGET_FILE:openmc> | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/openmc/lib/$<TARGET_FILE_NAME:openmc> | ||
| COMMENT "Copying openmc binary to Python module directory") | ||
|
|
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.
I know that the libopenmc library already gets relocated into the source tree, but IMHO that's always felt a bit "unclean" to put build artifacts into the source tree.
This might be a chance to move away from that approach.
If you are interested, in my attempt at creating a pip package I had made changes to the setup.py to include the build step by implementing a setuptools.Extension for OpenMC which builds in a temporary directory.
That's one way, I'm sure there is more 🤷
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.
Yes, what we have currently for libopenmc is very hacky, so I would not advocate for doubling down on it and handling the executable the same way. The approach you have there @hassec sounds a lot better. The other option that comes to mind is to use scikit-build (see #916). It looks like there are some other build backends out there that might merit a look.
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.
FWIW, @shimwell had a version that tried to use scikit-build, and I started out with that approach in the beginning but couldn't really get it to work as well as with the setuptools.Extension which was more flexible and easier to setup as scikit-build had limited docs. But there as been a lot of recent activity on the new scikit-build-core.
I don't have any experience with that package yet.
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.
I recently started tinkering with scikit build core (which I think now replaces scikit-build) on branch if anyone is interested develop...shimwell:openmc:trying-scikit-core
| import sysconfig | ||
| import sys | ||
|
|
||
| os.execv(sysconfig.get_path("platlib") + "/openmc/lib/openmc", sys.argv) |
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.
Didn't know about this before. I was doing this with Popen, but this is much neater 👍
|
Thanks @hassec and @paulromano for the feedback! I hadn't realized that others had made similar efforts. A few thoughts:
I'm happy to clean this PR up and address some of this feedback, but a rework with scikit-build is likely not something I'll have time for since I'm nearing the end of my internship. |
|
Had a watch on an issue (pypa/auditwheel#340) over at |
Could you expand on this? Were not able to get it work on all environments that you asked for, or are you trying to run on one platform and build for another? If it's the latter I think just throwing different GHA runners at it should be good enough. |
| # 5.5.0 breaks with pyne std::isnan bug | ||
| MOAB_TAG='5.3.0' |
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.
5.5.1 has been released, might fix the pyne std::isnan bug
| # 5.5.0 breaks with pyne std::isnan bug | |
| MOAB_TAG='5.3.0' | |
| MOAB_TAG='5.5.1 |
| MOAB_TAG='5.3.0' | ||
| MOAB_REPO='https://bitbucket.org/fathomteam/moab/' | ||
|
|
||
| DAGMC_TAG='v3.2.2' |
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.
another version bump
| DAGMC_TAG='v3.2.2' | |
| DAGMC_TAG='v3.2.3' |
|
FYI: I was looking into how Looking at their GHA it is actually pretty straightfoward-ish. They most rely on cibuildwheel, which seems to do most of the work for them. |
|
Great to catch up at the meshing group @akoen I just wanted to make note of something paulromano found. This pypi package includes Python bindings for the MPI and includes MPICH binaries which is something we had not noticed before. Perhaps the first pypi package to include mpi binaries I notice this nice wheel you have made does not include MPI but perhaps with this package it might be able to |
Description
Adds a CI step to build python wheels with cibuildwheel. Currently only builds for CPython 3.11 but can be expanded to encompass 3.7--3.12 with a one-line change.
Discussion at: https://openmc.discourse.group/t/alpha-python-wheels-for-openmc-including-apple-sillicon/3518
Checklist