-
-
Notifications
You must be signed in to change notification settings - Fork 464
Refactor Python wrapper so the sdist includes the core library code #530
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
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.
Thanks for your effort to help with this, much appreciated.
wrappers/python/CMakeLists.txt
Outdated
endif() | ||
else() | ||
zxing_add_package(pybind11 pybind11 ${pybind11_git_repo} ${pybind11_git_rev}) | ||
endif() | ||
|
||
# Check pybind helpers are availible | ||
find_package(pybind11 CONFIG) |
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.
find_package
is automatically called inside zxing_add_package
if BUILD_DEPENDENCIES
is set to AUTO
which happens in the toplevel CMakeLists.txt
which is only available/evaluated if hasParent
is true. So in the sdist
case, the following line should do the trick if added near line 16 above: set(BUILD_DEPENDENCIES "AUTO")
.
With that in-place one single zxing_add_package
call and no extra find_package
should hopefully work for all use cases. Could you please check if I'm correct with this assessment?
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'll have to have a look. I recall this was a workaround for a Windows build failure, when it couldn't locate pybind. Will check if your suggestion helps
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.
Worked great with that change across all the platforms. There's a single zxing_add_package
now for finding pybind11
wrappers/python/pyproject.toml
Outdated
@@ -4,5 +4,6 @@ requires = [ | |||
"setuptools_scm", | |||
"wheel", | |||
"cmake>=3.14", | |||
"pybind11[global]>=2.10.4", |
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.
- This line would force the presence of the pybind11 module (to be later found via
find_package
) right? - What does the
[global]
do?
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 believe it was the Windows build which couldn't find pybind11, even with this change and spawned the extra find package above
- Docs here. It's use here in the
pyproject.toml
build system is how it's meant to be used. Without it, all the systems failed to locate pybind11 when build (not just windows)
…egating the download at build time
There might be some minimum pybind11 version for the wrapper code to compile but it is not 2.10.4
This PR allows the sdist to include the core library code in the archive, instead of downloading the code at build time. This should be enough for Piwheels to build armv7 wheels, though I'm not positive, mostly due to the existence of
zxing_add_package_stb
.The change uses symlinks to create the
core
directory and requiredzxing.cmake
file in the wrapper folder, without copying the files from the parent at archive creation time. The MANIFEST.in then includes these files (and follows the symlinks properly) to create a self contained archive.I've tested all the following:
wrappers/python
pip wheel .
python3 -m build --wheel
python3 -m build --sdist