abey79 / vpype

The Swiss-Army-knife command-line tool for plotter vector graphics.

Home Page:https://vpype.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

m1 mac w/ homebrew workaround; display glitches

bleything opened this issue · comments

I've been trying to get vpype installed on my m1 mac with homebrew and I think I've made some progress. I'm pretty new to python and I'm not sure if I'm doing anything wrong, so I wanted to share what I've figured out and get some feedback. If it all looks good I'd be happy to put together a PR for the docs.

To begin with, I read #320 and ran into the same problems as @krummrey and @notwaldorf. I tried to follow the advice in that thread, specifically installing numpy and scipy via homebrew, but pretty quickly got into dependency hell. I spent a couple of hours digging in and eventually got stuck because pip couldn't find PySide even when it was installed, linked, and usable. Maybe there's a standard way to tell pip how to find packages but I couldn't figure it out.

Ultimately I decided to start over with pyenv and pyenv-virtualenv to keep things clean. I started by installing those tools and some dependencies:

$ brew install pyenv pyenv-virtualenv geos openblas

Next I ran through the setup instructions in the pyenv and pyenv-virtualenv docs, then installed 3.9.12 and set up a new venv:

$ pyenv install 3.9.12
$ pyenv virtualenv 3.9.12 vpype
$ pyenv activate vpype

Then I installed PySide2 using these instructions but changed the build command for homebrew install dirs:

$ CLANG_INSTALL_DIR=/opt/homebrew/opt/llvm python setup.py install  \
    --qmake=/opt/homebrew/opt/qt@5/bin/qmake --build-tests --ignore-git --parallel=8 --reuse-build

After waiting forever while pyside built, it was pretty smooth sailing:

$ pip install 'vpype[all]'
$ vpype random show

However, every time I quit the viewer I get a segfault. It seems to work okay until I quit, though? There are also some graphical glitches. I took an svg from vsketch's schotter example, rendered on my windows machine where everything's working, and opened it in vpype's viewer. You can see that some of the boxes are not fully closed:

Screen Shot 2022-05-06 at 7 57 06 PM

The classic viewer (and inkscape) render the file correctly so I think it's gotta be an issue somewhere in this vpype install. Unsure if it's a bug or what.

Thanks for trying to figure this out! 👍🏻

I really am unsure where this glitch comes from. It's not unlike a glitch that I sometime see with very dense line work (small segments with large change of direction) – but never with such simples squares. It would be interesting to see if those glitches can be reproduced with a "nominal" install (MacPorts & al). Also, can you send me that particular file and command, so I can test on my end just to be sure?

As for your workflow, if I understand correctly, it boils down to Homebrew's PySide2 being somehow broken, which is good to know. I've resorted to manual compilation of PySide2 a lot myself (before it was properly supported by MacPorts). I'd be wary of --reuse-build – I've been bitten in the past when changing stuff (was it Python version or Qt installation?). Also, this command creates wheels in the /dist subdir (or at least it would be the case if you swap install for bdist_wheel in the command). These wheels can readily be installed by pip. This is what I use nowadays to avoid --system-site-packages.

Whoops, sorry for the delay. Here's the svg: schotter_liked_1

Generated using vsk run examples/schotter on my windows machine with a correctly functioning install, verified in inkscape on both windows and mac. The glitches show up when I run vpype read schotter_liked_1.svg show on my mac.

I tried zooming way in and got a little better look at the issue:

Screen Shot 2022-05-16 at 2 04 44 PM

(also, I can't zoom with my mouse on the mac, I need to use pinch/zoom on the trackpad... am I doing something wrong?)

As for your workflow, if I understand correctly, it boils down to Homebrew's PySide2 being somehow broken, which is good to know.

It's not 100% clear to me if homebrew's pyside2 is broken or not. It installs correctly and I can import it in the python repl, but vsk (or one of its dependencies) can't find it during build. I don't know enough about python to debug it any further right now, unfortunately.

I'll try rebuilding pyside2 without --reuse-build and see how that goes. And I'll try installing the wheels instead, thanks for that tip!

Thanks for your writeup. Again I am stuck.

...
[ 26%] Linking CXX shared library libsample.dylib
[ 26%] Built target libsample
[ 26%] Linking CXX static library ../tests/libapiextractor.a
[ 26%] Built target apiextractor
make: *** [all] Error 2
error: Error compiling shiboken2
Traceback (most recent call last):
  File "/Users/jan/Documents/ML/vpype/pyside-setup/setup.py", line 296, in <module>
    setup_runner.run_setup()
  File "/Users/jan/Documents/ML/vpype/pyside-setup/build_scripts/setup_runner.py", line 168, in run_setup
    raise RuntimeError(msg)
RuntimeError: 
setup.py invocation failed with exit code: 1.

setup.py invocation was: /opt/homebrew/Caskroom/miniforge/base/envs/vpype/bin/python setup.py install --qmake=/opt/homebrew/opt/qt@5/bin/qmake --build-tests --ignore-git --parallel=8 --reuse-build --internal-build-type=shiboken2

Full error here: https://pastebin.com/5PcgEAWt

@krummrey I don't remember coming across this error when I was manually compiling shiboken & pyside2. It looks related to Numpy. Maybe try to make sure you have numpy properly installed with brew.

@bleything Can you retry installing vpype with Homebrew with #552 (either that branch or with master once I merge)? I'm expecting that it should be much smoother now, since PySide6 is available from pypi.

@abey79 oh sweet! I probably won't be able to try it until tomorrow but I'll take a look asap

@bleything sure not rush!

@abey79: mentioned this in discord but for posterity: vpype installs correctly and vpype random show works as expected but the schotter example is still rendering incorrectly.

looks like the render issue is covered by #318. going to close this.