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

3D view broken in own-compiled package, but the one from Debian repo is good #1291

Open
VanessaE opened this issue Nov 11, 2022 · 7 comments

Comments

@VanessaE
Copy link
Contributor

VanessaE commented Nov 11, 2022

I gave my PC a much-needed clean-out and reinstall, just to wipe away years' worth of cruft and my own blunders. 😄 I went from a mixed Debian stable+testing setup to a pure install of Debian stable "Bullseye" v11.5.0. The whole reinstall, while time-consuming, went just fine -- by the book.

Of course reinstalling the OS also meant rebuilding and reinstalling my 3d printing toolchain, since underlying libraries will no doubt have changed, but that's where the problem starts.

I can build Pronterface just fine, no obvious errors... compilation Just Works™, though there *still* isn't a suitable Wx wheel that'll work for Bullseye (need v4.1.0 plus cp39), so the system had to compile it.

The whole build seemed to go without incident:

Show build log...
apt -y install build-essential cmake python3-venv python3-pip \
  python-dbus-dev python3-serial python3-cairo-dev python3-cairosvg \
  python3-cairocffi python-dbus-dev libglib2.0-dev libgtk-3-dev gettext \
  libglu1-mesa-dev python3-opengl python3-pyglet python3-numpy

[apt spew omitted]

vanessa@rainbird:~$ cd /home/vanessa/RepRap/
vanessa@rainbird:~/RepRap$ rm -rf Printrun /home/vanessa/.cache/Printrun/
vanessa@rainbird:~/RepRap$ rm -rf /home/vanessa/.config/Printrun /home/vanessa/.cache/pip

vanessa@rainbird:~/RepRap$ git clone https://github.com/kliment/Printrun.git
Cloning into 'Printrun'...
remote: Enumerating objects: 12625, done.
remote: Counting objects: 100% (140/140), done.
remote: Compressing objects: 100% (88/88), done.
remote: Total 12625 (delta 61), reused 100 (delta 42), pack-reused 12485
Receiving objects: 100% (12625/12625), 80.80 MiB | 23.26 MiB/s, done.
Resolving deltas: 100% (7931/7931), done.
vanessa@rainbird:~/RepRap$ cd Printrun
vanessa@rainbird:~/RepRap/Printrun$ python3 -m venv venv
vanessa@rainbird:~/RepRap/Printrun$ . venv/bin/activate
(venv) vanessa@rainbird:~/RepRap/Printrun$ python -m pip install wheel Cython
Collecting wheel
  Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
Collecting Cython
  Downloading Cython-0.29.32-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 4.2 MB/s 
Installing collected packages: wheel, Cython
Successfully installed Cython-0.29.32 wheel-0.38.4
(venv) vanessa@rainbird:~/RepRap/Printrun$ python -m pip install -r requirements.txt
Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment
Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment
Collecting pyserial>=3.0
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 1.8 MB/s 
Collecting wxPython==4.1.0
  Downloading wxPython-4.1.0.tar.gz (65.8 MB)
     |████████████████████████████████| 65.8 MB 27.1 MB/s 
Collecting numpy>=1.8.2
  Downloading numpy-1.23.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
     |████████████████████████████████| 17.1 MB 39.8 MB/s 
Collecting pyglet>=1.1
  Downloading pyglet-2.0.0-py3-none-any.whl (966 kB)
     |████████████████████████████████| 966 kB 25.1 MB/s 
Collecting cffi
  Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     |████████████████████████████████| 441 kB 36.1 MB/s 
Collecting cairocffi
  Downloading cairocffi-1.4.0.tar.gz (69 kB)
     |████████████████████████████████| 69 kB 7.7 MB/s 
Collecting cairosvg>=1.0.9
  Downloading CairoSVG-2.5.2-py3-none-any.whl (45 kB)
     |████████████████████████████████| 45 kB 3.8 MB/s 
Collecting psutil>=2.1
  Downloading psutil-5.9.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)
     |████████████████████████████████| 280 kB 32.0 MB/s 
Collecting lxml>=2.9.1
  Downloading lxml-4.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.0 MB)
     |████████████████████████████████| 7.0 MB 21.0 MB/s 
Collecting appdirs>=1.4.0
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting dbus-python>=1.2.0
  Downloading dbus-python-1.3.2.tar.gz (605 kB)
     |████████████████████████████████| 605 kB 29.7 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting pillow
  Downloading Pillow-9.3.0-cp39-cp39-manylinux_2_28_x86_64.whl (3.3 MB)
     |████████████████████████████████| 3.3 MB 36.0 MB/s 
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cssselect2
  Downloading cssselect2-0.7.0-py3-none-any.whl (15 kB)
Collecting tinycss2
  Downloading tinycss2-1.2.1-py3-none-any.whl (21 kB)
Collecting defusedxml
  Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting webencodings
  Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: wxPython, dbus-python, cairocffi
  Building wheel for wxPython (setup.py) ... 
  Created wheel for wxPython: filename=wxPython-4.1.0-cp39-cp39-linux_x86_64.whl size=131601229 sha256=aa09e1c399ad2f9c512afede1789e040fc8df8184b79130a7e076805cac364af
  Stored in directory: /home/vanessa/.cache/pip/wheels/72/f6/4a/a8e855bf98edc5e92970fc81b4e5f0efcb755d0f45f0ce5eda
  Building wheel for dbus-python (PEP 517) ... done
  Created wheel for dbus-python: filename=dbus_python-1.3.2-cp39-cp39-linux_x86_64.whl size=121095 sha256=5d2a46067e23ab26458e98bcb15b6c139b94a721b5a95f3b174ae54571c06706
  Stored in directory: /home/vanessa/.cache/pip/wheels/27/85/e1/b15bc5a2c09c521621b4f5a32a2aa85b08586fbb80cea67ffd
  Building wheel for cairocffi (setup.py) ... done
  Created wheel for cairocffi: filename=cairocffi-1.4.0-py3-none-any.whl size=88775 sha256=79f56aaab118687731ae2d16cf4927fdf43007d86242dfed76880358786cae0f
  Stored in directory: /home/vanessa/.cache/pip/wheels/2a/f8/2e/1ba974e3c465ce58d97d09238f159afa8a36bc284bfc380241
Successfully built wxPython dbus-python cairocffi
Installing collected packages: webencodings, pycparser, tinycss2, cffi, six, pillow, numpy, defusedxml, cssselect2, cairocffi, wxPython, pyserial, pyglet, psutil, lxml, dbus-python, cairosvg, appdirs
Successfully installed appdirs-1.4.4 cairocffi-1.4.0 cairosvg-2.5.2 cffi-1.15.1 cssselect2-0.7.0 dbus-python-1.3.2 defusedxml-0.7.1 lxml-4.9.1 numpy-1.23.4 pillow-9.3.0 psutil-5.9.4 pycparser-2.21 pyglet-2.0.0 pyserial-3.5 six-1.16.0 tinycss2-1.2.1 webencodings-0.5.1 wxPython-4.1.0
(venv) vanessa@rainbird:~/RepRap/Printrun$ python setup.py build_ext --inplace
Compiling printrun/gcoder_line.pyx because it changed.
[1/1] Cythonizing printrun/gcoder_line.pyx
running build_ext
building 'printrun.gcoder_line' extension
creating build
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/printrun
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/vanessa/RepRap/Printrun/venv/include -I/usr/include/python3.9 -c printrun/gcoder_line.c -o build/temp.linux-x86_64-3.9/printrun/gcoder_line.o
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/printrun
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-z,relro -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.9/printrun/gcoder_line.o -o build/lib.linux-x86_64-3.9/printrun/gcoder_line.cpython-39-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.9/printrun/gcoder_line.cpython-39-x86_64-linux-gnu.so -> printrun
(venv) vanessa@rainbird:~/RepRap/Printrun$ 

However, when I run it, the plater/gcode preview is only the old top-down 2d view. The program throws errors to the terminal complaining that it can't initialize the 3d view:

Show runtime errors...
vanessa@rainbird:~$ cd RepRap/Printrun/
vanessa@rainbird:~/RepRap/Printrun$ python3 -m venv venv
vanessa@rainbird:~/RepRap/Printrun$ . venv/bin/activate
(venv) vanessa@rainbird:~/RepRap/Printrun$ ./pronterface.py 
3D view mode requested, but we failed to initialize it.
Falling back to 2D view, and here is the backtrace:
Traceback (most recent call last):
  File "/home/vanessa/RepRap/Printrun/printrun/gui/viz.py", line 69, in __init__
    import printrun.gcview
  File "/home/vanessa/RepRap/Printrun/printrun/gcview.py", line 22, in <module>
    from .gl.panel import wxGLPanel
  File "/home/vanessa/RepRap/Printrun/printrun/gl/panel.py", line 28, in <module>
    from pyglet.gl import glEnable, glDisable, GL_LIGHTING, glLightfv, \
ImportError: cannot import name 'GL_LIGHTING' from 'pyglet.gl' (/home/vanessa/RepRap/Printrun/venv/lib/python3.9/site-packages/pyglet/gl/__init__.py)


(pronterface.py:300375): Gtk-CRITICAL **: 23:40:09.089: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkSpinButton

(pronterface.py:300375): Gtk-CRITICAL **: 23:40:09.089: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkSpinButton

(pronterface.py:300375): Gtk-CRITICAL **: 23:40:09.090: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkSpinButton

(that last message is probably unrelated but I include it here because it says "critical" and repeats about a zillion times)

Googling around has provided no answers, except for some handwaving blaming numpy.

HOWEVER, I also discovered that Pronterface is in Debian's standard repository (didn't notice if it was from main or contrib though), currently at version 2.0.0-rc8.

I blew away my local Pronterface sources and apt install-ed the Debian package. It works completely normally, 100% fine for routine printing (I have not tried things like the excluder or gcode plater but I assume they'd work fine also).

So apparently something that works within the Debian packaging environment is silently failing during my build.

One interesting detail, which I mention because it's surely related to WxWidgets being different inside the Debian package compared to what went into my old pre-OS-reinstall build:

The top row buttons ("Load File", "SD", "Print", etc.), and my custom buttons at the bottom of the window, are all a bit larger now than before. Don't change them, though -- now they're just right (they used to be a little too small for my bad eyes and poor dexterity).

@rockstorm101 I was advised to ping you about this.

@DivingDuck
Copy link
Collaborator

DivingDuck commented Nov 11, 2022

Hi @VanessaE,
I ran in similar problems last week with my windows version of Pronterface. I thought it was time to change to VS 2022 and all went good up to the moment I build my virtual environment for python 3.10 and ended as well with 2d instead of 3d.

The problem is introduce from pyglet as they have released version 2.0 a couple of days before. Unfortunately this version isn't compatible with version 1.xx. I hadn't the time to investigate the source code of panel.py.

I have a workaround for this that works for windows and I hope this will work for you as well. Change in requirements.txt the line
pyglet (>= 1.1)
to
pyglet >= 1.1, <2.0

This take care that you stick to the latest version 1.xx

Let me know if this work for you.

@rockstorm101
Copy link
Collaborator

HOWEVER, I also discovered that Pronterface is in Debian's standard repository (didn't notice if it was from main or contrib though), currently at version 2.0.0-rc8.

Yep, Printrun has been part of the official Debian repositories since early 2016 (it is in 'main', as it is fully free software :) ). However the package is now almost two years old (early 2021) so it probably lacks a few new additions here and there. (nudge intended to push for a 2.0.0 release, got some features in the oven ready for a 2.1.0 release even :P )

The problem is introduce from pyglet as they have released version 2.0 a couple of days before. Unfortunately this version isn't compatible with version 1.xx.

Quick look at your build and runtime logs, there's clearly something going on with pyglet so @DivingDuck is probably on the right track there. The package currently in stable (a.k.a Bullseye or 11) is using Python 3.9, wxWidgets 4.0 and pyglet 1.5. These versions differ from those on your build log. Let me know if I can help you any further.

@VanessaE
Copy link
Contributor Author

@rockstorm101 I would suggest @DivingDuck's fix to requirements.txt be updated on the repo rather than in my environment, since we're talking about building under the latest stable release of a major distro. 😄

Besides, I'm content to use the Debian package, so I won't need to test building that way myself.

rockstorm101 added a commit that referenced this issue Dec 13, 2022
Temporary fix to deal with #1291 until full fix is implemented.
@rockstorm101
Copy link
Collaborator

Note to future self: 8fd9b8b introduced a workaround, issue left open until Printrun supports Pyglet >= 2.0.

@real-artswan
Copy link

Would be good to fix README where it talks about running from sources on Ubuntu/Debian
replace
pip3 install --user pyglet
with
pip3 install --user --force-reinstall -v "pyglet >= 1.1, < 2.0"

@rockstorm101
Copy link
Collaborator

Would be good to fix README where it talks about running from sources on Ubuntu/Debian replace pip3 install --user pyglet with pip3 install --user --force-reinstall -v "pyglet >= 1.1, < 2.0"

Thanks @real-artswan for bringing our attention to this. I'm tempted to even delete the whole Ubuntu/Debian section there. Users of these distributions probably either use the official package or run from source using a virtual environment. I would say this method using a mix of system and PyPI packages is obsolete and probably should not be encouraged. Did you run Printrun using such method?

@DivingDuck
Copy link
Collaborator

It is maybe worth to add requirements.txt in general to the manual build instruction. We we had limit the version beside of pyglet in addition cairosvg and wxpython there as well.

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

No branches or pull requests

4 participants