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

freecad mac app bundle ie. FreeCAD.app runtime issue, cannot find the runtime dependency pyside2 #278

Open
ipatch opened this issue Dec 10, 2021 · 18 comments

Comments

@ipatch
Copy link
Collaborator

ipatch commented Dec 10, 2021

presently running brew install freecad should either install freecad from one of the provided bottles for catalina or big sur. if running a different OS ie. mojave or monterey then freecad will have to be build from source locally.

so depending how the dependencies are setup ie. [email protected] freecad will fail to load the pyside2 runtime dep when launching the FreeCAD gui when double clicking the app bundle. ie. FreeCAD.app.

presently, either pyside@2 or the tap provided [email protected] need to be manually linked before running

brew install freecad -s -v

and the runtime issue should be resolved, but haven't fully tested.

the CI, cmake scripts or freecad.rb formula file need to be updated to support (finding) the install of pyside in order to copy the necessary dependencies into the FreeCAD.app bundle.

as mentioned in a prior comment ie.

#237 (comment)

it may be possible to tweak the freecad gui launch script to specify the path to the pyside2 installation. once again, i haven't fully tested this locally on my machine or with the CI/CD (github actions yet)

@ipatch
Copy link
Collaborator Author

ipatch commented Dec 10, 2021

error messages after launching the FreeCAD.app GUI

18:31:43  During initialization the error "No module named 'PySide2'" occurred in /Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/Draft/InitGui.py
18:31:43  Please look into the log file for further information
18:31:45  During initialization the error "No module named 'PySide2'" occurred in /Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/Arch/InitGui.py
18:31:45  Please look into the log file for further information
18:31:45  During initialization the error "No module named 'PySide2'" occurred in /Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/AddonManager/InitGui.py
18:31:45  Please look into the log file for further information
18:31:46  During initialization the error "No module named 'PySide2'" occurred in /Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/Tux/InitGui.py
18:31:46  Please look into the log file for further information
18:31:48  Unknown command 'Std_AddonMgr'
18:31:48  Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/Start/StartPage/StartPage.py", line 29, in <module>
    from . import TranslationTexts
  File "/Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/Mod/Start/StartPage/TranslationTexts.py", line 24, in <module>
    from PySide import QtGui
  File "/Users/brewmaster/homebrew/Cellar/freecad/0.19/FreeCAD.app/Contents/MacOS/PySide/__init__.py", line 2, in <module>
    from PySide2 import __version__
<class 'ModuleNotFoundError'>: No module named 'PySide2'
18:31:48  No module named 'PySide2'

@ipatch
Copy link
Collaborator Author

ipatch commented Dec 10, 2021

#164 (comment)

@ipatch
Copy link
Collaborator Author

ipatch commented Dec 10, 2021

image

@neurodigitaltechnologies

Hi @ipatch,
Any updates so far on this issue, please?
Many thanks in advance for all your support and hard work on this.
All the best,
Luis.

@ipatch
Copy link
Collaborator Author

ipatch commented Dec 22, 2021

i haven't done any work with the freecad tap or specifically this issue in a week or so. the holidays caught up with me so my time has been limited.

if you're trying to install freecad using the tap provided formula ie. freecad.rb then a possible work around would be the below

install all the freecad dependencies first

brew install freecad/freecad/freecad -v --only-dependenices

manually link [email protected] and [email protected]

brew link -v [email protected]
brew link -v [email protected]

then build freecad from source using the tap provided formula

brew install freecad -v -s

@vejmarie
Copy link
Contributor

I am currently looking at it. My build is broken on Mac, and still try to figuring out from where it comes.

@vejmarie
Copy link
Contributor

vejmarie commented Jan 1, 2022

This PR #5316 in FreeCAD shall be helping a lot

@ipatch
Copy link
Collaborator Author

ipatch commented Jan 1, 2022

FreeCAD/FreeCAD#5316

@ipatch
Copy link
Collaborator Author

ipatch commented Jan 22, 2022

  • is there a way to check if the brew process ie. can the install process (using the CI) be aware that it is being run in a CI?
    • if so, would it be possible to run additional steps to perform the necessary linking for pyside & shiboken2

@clyang
Copy link

clyang commented Apr 19, 2022

i haven't done any work with the freecad tap or specifically this issue in a week or so. the holidays caught up with me so my time has been limited.

if you're trying to install freecad using the tap provided formula ie. freecad.rb then a possible work around would be the below

install all the freecad dependencies first

brew install freecad/freecad/freecad -v --only-dependenices

manually link [email protected] and [email protected]

brew link -v [email protected]
brew link -v [email protected]

then build freecad from source using the tap provided formula

brew install freecad -v -s

I'm able to build app bundle by using this workaround. However, when I tried to run it, it shows the following error.

During initialization the error "Failed to wrap widget" occurred in /Applications/FreeCAD.app/Contents/Mod/Tux/InitGui.py
Please look into the log file for further information

Is there any solution to this issue?

@ipatch
Copy link
Collaborator Author

ipatch commented Apr 19, 2022

@clyang

do you mind opening a new issue, just copy and paste what you go here?

and can you post your brew setup, ie. the output of your brew config , brew doctor

are you using m1 or intel, the more information you can provide the more we're able to help. 🤝

@clyang
Copy link

clyang commented Apr 19, 2022

Thanks for the prompt response!

I compiled it on my M1 laptop. After the successful build, here is my steps:

1. cd /opt/homebrew/Cellar/freecad/0.19
2. open FreeCAD.app

My brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  tbb@2020
  [email protected]

brew config

HOMEBREW_VERSION: 3.4.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: 09e766f83c8a420cce9e2210c46a24ec3864a094
Last commit: 30 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 9e6c2e2b31ec47136266ada0c32a2ecf0589c20e
Core tap last commit: 63 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 13.1.6 build 1316
Git: 2.32.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.3.1-arm64
CLT: 13.3.1.0.1.1648687083
Xcode: 13.3.1
Rosetta 2: false

@ipatch
Copy link
Collaborator Author

ipatch commented Jul 9, 2022

little update on this issue. i think the simple solution to getting the cmake build process to properly locate the pyside2 installation is to prepend the pyside installation bin to the path while running cmake. i tested a couple of cases where i had the pyside bin directory prepended (top entry) in my $USER path and without. i get the following snippet without the pyside2 bin path entry...

-- Shiboken2:            [Shiboken2_DIR-NOTFOUND] []
-- PySide2:              []
--  IncludeDir:         Unable to find, python version mismatch?
-- PySide2Tools:        [/usr/local/opt/qt@5/bin/uic] [/usr/local/opt/qt@5/bin/rcc]

when i add pyside2 to my path with the following,

fish_add_path -p $bp/Cellar/pyside@2/5.15.5/bin

and...

brew unlink [email protected]
Unlinking /usr/local/Cellar/[email protected]/5.15.5... 0 symlinks removed.

brew unlink pyside@2
Unlinking /usr/local/Cellar/pyside@2/5.15.5... 0 symlinks removed.

i see the below in the cmake report output...

-- Shiboken2:           5.15.5 [/usr/local/Cellar/pyside@2/5.15.5/lib/cmake/Shiboken2-5.15.5] [/usr/local/Cellar/pyside@2/5.15.5/include/shiboken2;/usr/local/opt/[email protected]/Frameworks/Python.framework/Headers]
-- PySide2:             5.15.5 [/usr/local/Cellar/pyside@2/5.15.5/include/PySide2]
-- PySide2Tools:        [/usr/local/opt/qt@5/bin/uic] [/usr/local/opt/qt@5/bin/rcc]

not sure if this will resolve all the runtime related issues with pyside but seems like a step in the right direction.

@ipatch
Copy link
Collaborator Author

ipatch commented Jul 9, 2022

and i think this will help us with keg only deps in the freecad formula ie. pyside2 being keg only because of it's upstream pyside6 counterpart, so if this works then hopefully brew install freecad will just work without having to manually link the keg only deps of shiboken2 and pyside2 🤞

@ipatch
Copy link
Collaborator Author

ipatch commented Jul 12, 2022

#335

should help in getting closer to having brew install freecad to just work without any manual unlink/link commands

@ipatch
Copy link
Collaborator Author

ipatch commented Jul 28, 2022

another little update on this. a quick way to see if shiboken and pyside are setup properly for a cmake build is to open a pythone repl

python3

# i'm using python3 provided by homebrew-core [email protected]
import shiboken2
import PySide2
from PySide2 import QtCore

i was running into some edge cases yesterday where i was able to import PySide2 but was not able to load any of the accompanying qt modules.

i made certain that my shiboken2 and pyside2 installation are not linked.

i got a build going right now (non mac bundle) that seems to have picked up on my shiboken and pyside installations on a m1 mac. however i did have to add a .pth file for each package into my site-packages dir for [email protected].

and if i understand everything correctly, running the brew link [PKG] it copies everything from the site-packages in the Cellar for shiboken and pyside to the opt site-packages for the python installation. hence why things worked when linking the above packages.

so not entirely sure i can add the .pth files for shiboken2 and pyside to pick up the installations without having to link the packages but hopefully this will be a step closer. and this will eventually help with homebrew CI builds. 🤞

a little q/a about the .pth files and site-packages dir

https://stackoverflow.com/a/7901603/708807

@ipatch
Copy link
Collaborator Author

ipatch commented Aug 17, 2022

feeling confident this issue should be resolved with the below commit

addab68

if anybody experiences any issues feel to search the open issues and leave comment if something comes up or if your issue is completely separate, please open a new issue.

i believe adding the below lines to the freecad.rb formula resolved this issue at least in all my local testing.

# NOTE: ipatch, exp with PYTHONPATH
ENV.prepend_path "PYTHONPATH", Formula["[email protected]"].opt_prefix/Language::Python.site_packages(python3)
ENV.prepend_path "PYTHONPATH", Formula["[email protected]"].opt_prefix/Language::Python.site_packages(python3)

@ipatch ipatch closed this as completed Aug 17, 2022
@ipatch ipatch reopened this Aug 24, 2022
@ipatch
Copy link
Collaborator Author

ipatch commented Aug 24, 2022

did a brew install freecad/freecad/freecad to test the bottle built via the CI. it appears some more work will be required for the FreeCAD GUI cmd to pick up on the runtime dependencies of shiboken2 and PySide2.

the quick fix is to manually create .pth file pointing the site-packages directory for both the shiboken2 and PySide2 installations. after creating those two files.

one quick test is to run the below cmd.

python3

should open the the python3 REPL that is installed via homebrew and which freecad relies upon, and then attempt to import both shiboken2 and pyside2 with the below commands

import shiboken2
import PySide2

got my bottle installation of freecad v0.20.1 going.

obviously this far from perfect, and more work will be required to get all this ironed out for future bottled releases.

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