Skip to content
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: setup.py can now find numpy #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arcitec
Copy link

@Arcitec Arcitec commented May 29, 2024

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.

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.
@Arcitec
Copy link
Author

Arcitec commented May 29, 2024

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
Copy link
Author

Arcitec commented May 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setup.py imports numpy
1 participant