-
Notifications
You must be signed in to change notification settings - Fork 88
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 PyInstaller hook #180
Fix PyInstaller hook #180
Conversation
Using editable installation of freetype-py hides the fact that `freetype.__pyinstaller` is not being installed, and that consequently the provided PyInstaller hook entry-points are de-funct in real-world.
Have the PyInstaller hook test ensure that the freetype shared library is bundled with the frozen application. Otherwise, the frozen application might still work in spite of defunct hook due to the fact that the system-wide freetype shared library is available (which is likely true in the case of the CI system).
Ensure `freetype.__pyinstaller` is installed as part of `freetype-py`. Fixes the provided PyInstaller hook entry-points in real-world installations (PyPI wheels and non-editable installs).
Move PyInstaller hook test (test_freetype.py and conftest.py) into tests sub-directory. This prevents the test from using the local (source) version of `freetype` instead of the installed one (which contains the shared library); this problem arises with pytest's default `prepend` import mode due to the project's structure (i.e., not using the `src/freetype` layout).
A few comments:
So I am not convinced about how you are doing it (moving files without explaining, and not adding mac os x CI at least, if not Windows also), and why you are doing it (editable install is always available). |
This PR looks great to me, you fixed it the proper way. I can't believe I missed the Regarding @HinTak's feedback:
It's okay to reorganize the unit tests for the pyinstaller hook into their own folder, I think. It's a minor change with no impact beyond the pyinstaller hook.
We could consider adding two more CI jobs to test the pyinstaller hook on macos and windows, but I doubt it will make any difference. I don't think it's worth the added build complexity and time for such a small feature. In fact, the linux CI job is the most challenging one since it has a system freetype available and a bundled freetype. So it's a good environment to test that our hook prefers the bundled build. All in all, the ubuntu CI job for the pyinstaller hook is sufficient IMHO.
We're not breaking or changing anything about the ability to do an editable install. The point of this PR is to specifically address the use case where users have installed freetype-py from a wheel on pypi to use in their project, and create a distributable of their project using pyinstaller. If you are concerned that we are not supporting the scenario where a user runs pyinstaller on a project with an editable freetype-py install, that's also supported. However, this PR is only intended to address a bug in the current packaging setup. It's not adding a new feature or expanding the set of use cases that are supported. The
I am convinced of the correctness of this PR and would vote to merge it. We can always open another PR to improve it further. For now it addresses the bug correctly. |
Besides the moving files, there are a number of unnecessary(?) code changes bundled too (the |
The only changes of that nature I can see are in The import had to be changed because we're now using Beyond that it's very easy to tell from the diff that the tests files were moved without other stylistic changes, beyond what was necessary to improve the test as explained in the PR description. I think it's a little unreasonable to block this PR on that. To summarize the changes in this PR:
I hope this makes it easier to understand the PR and addresses your concerns. |
Nobody is "blocking" a pull. Pulls are accepted IMO when they are convincing as address a bug or add a feature. The latter is easier - if a pull has no effect on existing usage, it is usually accepted (hence the initial work, #162 got in quite quickly without much question). I.e. a user uses the new functionality knowing that it is new and possibly buggy. If a pull is supposed to address a bug, then it should just do only that, and not introduce either stylistic changes or rearrangements more than necessary. So it is harder to be accepted, or even be looked at. The worst - a change buried in an rearrangement. Personally I don't want to spend time checking whether such an event has happened, so if the pull looks too much, I don't spend time looking at it. That's purely my own opinion. |
Ok. So then we can merge this? |
As I already wrote, I don't want to spend time looking at "more than necessary" code. Other's opinion might differ. |
I have time aplenty to look at such code but no rights to merge. I have to say I am a bit puzzled as to why you decided to cc me. I invested a lot of time to help you review the PR and you're essentially just disregarding all of it. I would appreciate not being cc'd again if it doesn't make a difference for the end result anyway. I will unsubscribe now and leave it to others. |
Also not sure what's the purpose of this code - freetype-py (and freetype) are available on all major Linux platforms, so it seems a bit strange to do bundle for Linux (versus other platforms), and also only test on Linux. Anyway, I'll leave this to others who want to look at it. |
@rougier would you mind merging this? The pyinstaller hook is missing from the
The pyinstaller hook is not used to create freetype distributables. I'll try to explain what pyinstaller is, how it is used, and why it's valuable and worthwhile to include a pyinstaller hook in freetype-py. Hopefully this will also help you understand why it's not necessary to execute the hook test on other platforms.
The bug that this PR is fixing, is that the hook is not shipped as part of the wheels. So what happens with the current release of freetype-py, is that pyinstaller will query the entrypoint, try to import the hook, and then fail. So, in summary, by shipping the pyinstaller hook in freetype-py, end users will be able to create distributables of python applications that depend on freetype-py. |
An alternative solution (if @Korijn is fine with it) would be to remove the hook code and related entry-point from the The removal here is not really necessary per se (if |
I'm okay with any path that results in functional pyinstaller support for freetype-py. So for @rougier that's either merging this PR, or removing the hook entirely in a new PR and maintaining the hook externally. |
Or merging #179, if its is preferable to leave tests as they are, and just fix the entry-point. |
Freetype-py is available on all Linux platforms already packaged, so it doesn't make sense to re-package something already packaged. If somebody wants to bundle freetype-py with something else, then such (re-)packaging-related code naturally belongs to that 'something else', rather than freetype-py. And if somebody wants to re-package/bundle freetype-py, then they should work from source rather than from pre-packaged package. There is a need to bundle freeype-py with feeetype and a python interpreter on non-linux. Hence, I would say, remove this code, or make CI works with non-linux. That said, the moving/relocation in this pull is still questionable. |
that's just your opinion. Others may prefer their python app to be self-contained, not have external non-python requirements and control exactly which version of freetype they use. Anyway so much digital ink wasted.. this PR does no harm and actually fixes a bug, so I'm going to merge it. Thanks @rokm and @Korijn |
we need to export FREETYPEPY_BUNDLE_FT to ensure the correct build deps (e.g. cmake) are installed. Also run pytest --pyargs to ensure that the installed freetype is tested, not the one found in the current directory.
[ci] fix test-pyinstaller broken after #180 was merged
@anthrotype There is a point where merging random additional code/dependency needs to stop, for long term maintenance. If anything that a user might needs as a singular convenience should be merged, I might propose including the whole of skia-python as a dependency to provide OT-SVG color font support. That's a 30MB blob on most platforms. |
The fact that non-needed recent addition causes problems may be an indication that it should be removed. |
So I am suggesting that if there is another issue filed with this code, it should be removed. |
The PyInstaller hook was added in #162, but currently its entry-points are defunct in real-world installations (PyPI wheels, non-editable installs) because
freetype.__pyinstaller
is not installed as part of thefreetype-py
.This is masked on the CI because editable install is used, and also because
freetype
in the frozen application will happily use the system-available copy of the freetype shared library if the bundled one is not available. So a basic import test is insufficient, especially on a linux-based CI runner, where the system-available copy of freetype shared library is guaranteed to be available.