TomWhitwell / SlowMovie

MIT License
342 stars 67 forks source link

add code to handle python venv #151

Closed JonCellini closed 9 months ago

JonCellini commented 10 months ago

Added code to handle the creation and use of a python venv for SlowMovie.

Addresses issue #150

robweber commented 10 months ago

Thanks for tackling this. Have you fully tested it on Bullseye or Bookworm? I'll clone it to my local instance tonight and give it a run. My local SlowMovie is still on Bullseye so I'll at least be able to test backwards compatibility.

JonCellini commented 10 months ago

I'll test it on my local RPI here in a bit and post back. Mine is also on Bullseye at the moment (due to the incompatibility)

JonCellini commented 10 months ago

It works fine on Bullseye arm64 :)

The venv code I wrote works as expected on Bookworm arm64; however, SlowMovie fails to install due to an unrelated issue with the IT8951 package.

The failure output is here:

` Running setup.py install for RPi.GPIO ... done DEPRECATION: IT8951 is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 Running setup.py install for IT8951 ... error error: subprocess-exited-with-error

× Running setup.py install for IT8951 did not run successfully. │ exit code: 1 ╰─> [54 lines of output] running install /home/pi/SlowMovie/.venv/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.linux-aarch64-cpython-311 creating build/lib.linux-aarch64-cpython-311/IT8951 copying IT8951/interface.py -> build/lib.linux-aarch64-cpython-311/IT8951 copying IT8951/constants.py -> build/lib.linux-aarch64-cpython-311/IT8951 copying IT8951/display.py -> build/lib.linux-aarch64-cpython-311/IT8951 copying IT8951/init.py -> build/lib.linux-aarch64-cpython-311/IT8951 running build_ext building 'IT8951.spi' extension creating build/temp.linux-aarch64-cpython-311 creating build/temp.linux-aarch64-cpython-311/IT8951 aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/pi/SlowMovie/.venv/include -I/usr/include/python3.11 -c IT8951/spi.c -o build/temp.linux-aarch64-cpython-311/IT8951/spi.o IT8951/spi.c: In function ‘Pyx_TraceSetupAndCall’: IT8951/spi.c:22082:37: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’} 22082 | if (CYTHON_TRACE && (frame)->f_trace == NULL) { | ^~ IT8951/spi.c:22084:21: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’} 22084 | (frame)->f_trace = Py_None; | ^~ IT8951/spi.c:438:62: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’} 438 | #define Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) | ^~ IT8951/spi.c:22091:5: note: in expansion of macro ‘Pyx_PyFrame_SetLineNumber’ 22091 | Pyx_PyFrame_SetLineNumber(frame, firstlineno); | ^~~~~~~ IT8951/spi.c: In function ‘__Pyx_PyBytes_Equals’: IT8951/spi.c:23312:13: warning: ‘ob_shash’ is deprecated [-Wdeprecated-declarations] 23312 | hash1 = ((PyBytesObject)s1)->ob_shash; | ^~~~~ In file included from /usr/include/python3.11/bytesobject.h:62, from /usr/include/python3.11/Python.h:50, from IT8951/spi.c:6: /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here 7 | Py_DEPRECATED(3.11) Py_hash_t ob_shash; | ^~~~ IT8951/spi.c:23313:13: warning: ‘ob_shash’ is deprecated [-Wdeprecated-declarations] 23313 | hash2 = ((PyBytesObject*)s2)->ob_shash; | ^~~~~ /usr/include/python3.11/cpython/bytesobject.h:7:35: note: declared here 7 | Py_DEPRECATED(3.11) Py_hash_t ob_shash; | ^~~~ IT8951/spi.c: In function ‘Pyx_AddTraceback’: IT8951/spi.c:438:62: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’} 438 | #define Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) | ^~ IT8951/spi.c:24384:5: note: in expansion of macro ‘Pyx_PyFrame_SetLineNumber’ 24384 | Pyx_PyFrame_SetLineNumber(py_frame, py_line); | ^~~~~~~ error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> IT8951

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.`

JonCellini commented 10 months ago

That IT8951 issue appears to be a dupe of what was reported earlier here .

robweber commented 10 months ago

I was looking into that issue over the weekend and found a fix in the maintainer's repo. Didn't have time to test it myself though: https://github.com/GregDMeyer/IT8951/issues/58

It would be nice if it could be fixed upstream but I see that repo has a few PRs just hanging out there. Worst case would be to drop that library but I know those displays are popular.

JonCellini commented 10 months ago

Yep, I just came across the same fix and tested it on my Bookworm install that I was testing this PR against, and it builds cleanly. The workaround is a very simple change to the installer which I'm happy to commit as well.

JonCellini commented 10 months ago

Latest commit addresses issue #152.

The venv changes are solid; however, the IT8951 code now installs but fails to actually run properly on Bookworm.

JonCellini commented 10 months ago

I did some testing this evening on a totally fresh image and found an error which I resolved. A fresh install should build cleanly in a venv on Buster

JonCellini commented 10 months ago

So I think I tracked down the issue with waveshare_epd working on Bookworm. They are looking for gpiomem-bcm2835 which appears to have been replaced with raspberrypi-gpiomem.

I did a clean install of my code on a fresh Bookworm system and it works as expected; however, the waveshare_epd will fail to run as is it is hard coded to look for gpiomem-bcm2835 to determine it's on a PI. That is over my depth of understanding to resolve at the moment.

robweber commented 10 months ago

Thanks for all the work on this. Going to get Bookworm going on an SD card and see what I can figure out for the waveshare stuff.

robweber commented 10 months ago

I put more info in #150 but just a note that we'll put a hold on this until the Bookworm issues in the Waveshare library can be resolved since that's a big chunk of the user base. For now using Bullseye is probably the best bet.

robweber commented 10 months ago

I added a few comments based on the changes to the IT8951 branch since it builds properly now.

JonCellini commented 10 months ago

I went ahead and revised my fork to incorporate the changes discussed above based on the changes to the IT8951 upstream. Let me know what you think makes sense to do about handling the venv sourcing.

JonCellini commented 10 months ago

Let me know if you think any other changes are needed. I tested it locally and everything works as I expect.

robweber commented 10 months ago

Just had the one comment but otherwise I think it's good. I'm going to wait just a bit longer (1-2 days) and give the official Waveshare repo a chance to merge in the Bookworm code fixes. If not I'm going to merge in the omni-epd code that uses the fork. Either way once omni-epd is Bookworm compatible we can merge this in and everything should be good. Technically we could merge this now but since the Waveshare stuff will all still be broken it's less confusing to hold off for a bit and get it all working at the same time.

JonCellini commented 10 months ago

Makes total sense. Thanks for letting me contribute to this project :)