mherkazandjian / fastgrab

Python package for taking super-fast screenshots
GNU General Public License v3.0
60 stars 4 forks source link

fix: setup.py can now find numpy #19

Open Arcitec opened 5 months ago

Arcitec commented 5 months ago

The old setup.py code was unable to build the fastgrab module, due to missing numpy during the setup stage. It's unlikely that anyone ever installed this library via PyPi in the past, due to this oversight.

However, it's possible to patch the build process class to do late injection of the numpy headers path. This technique comes from the following post:

https://stackoverflow.com/a/21621689/8874388

It works by telling setuptools that we need numpy, and then modifying the build process class to add numpy's path before we actually build fastgrab.

Further fixes were performed to make it buildable on Python 3.12 with the latest libraries.

Closes #18.

Arcitec commented 5 months ago

Tested on Python 3.12 with the latest numpy and fastgrab code.

Python successfully builds everything and captures screenshots on Linux X11.

PS: You may also read the https://stackoverflow.com/a/60740731/8874388 answer, but just ignore that. It's a deprecated method which doesn't work whatsoever anymore. So the injection method I'm using, while it's a bit ugly, gets the job done and is reliable in both old and new Python versions.

Arcitec commented 5 months ago

After merge, please remember to push a new tag and a new PyPi package, so that people can finally use your sweet library.

These are my performance results on a Ryzen 7800X3D CPU with NVIDIA RTX 3090 GPU:

benchmark capture frame rate using frames
the benchmark will capture 800 frames

resolution standard | resolution    |  measured fps
--------------------+---------------+--------------
360p                |  480x360      |  1132.2   
720p                |  1280x720     |  311.5   
1080p               |  1920x1080    |  147.9   
4K                  |  3840x2160    |  35.7   
8K                  |  7680x4320    |  failed