| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Geeks: Example PC SP 32:64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thu, Sep 20th, 2022 Building FreeCAD from source using CondaBuilding FreeCAD for development on macOS Monterey for M1There are currently two methods to build FreeCAD. The Homebrew script on https://github.com/FreeCAD/homebrew-freecad is well documented and works, although with a few quirks. It does not currently create a working macOS Bundle though, and it does not easily work with a local source tree. The official ARM64 Bundle is built using Conda. Conda, like Homebrew, installs FreeCAD dependencies before launching CMake. The dependencies, build instructions, and "feedstock" live in https://github.com/FreeCAD/FreeCAD_Conda . Unfortunately I don't know much about Conda, but if I want to get any development for macOS done, I will have to find a way to build the latest release including my changes from a local source tree, so here is my step-by-step report. Conda Step by StepFirst we remove Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"And a previous attempt to install Conda: conda install anaconda-clean anaconda-clean anaconda-clean --yes rm -r ~/miniconda3And remove Conda reference in `~/.bash_profile` Now off to installing what we need from scratch. Xcode is obviously needed. Xcode command line tools are installed next: xcode-select --install xcode-select -pNext, we want a fresh install of what the Conda developers call MiniConda. Go to https://docs.conda.io/en/latest/miniconda.html and download the shell script "Miniconda3 macOS Apple M1 64-bit bash" bash -b ~/Downloads/Miniconda3-latest-MacOSX-arm64.shFor some reason, Conda did not bother to add its path to .bashrc, so we call: conda init bashAnd since I am using ~/.bashrc, I have to append the content of ~/.bash_profile and delete ~/.bash_profile Restart the terminal or modify the path manually. We disable the default Conda environment when launching a shell: conda config --set auto_activate_base falseBut we can re-enable it any time by calling: conda activate base Three ways to choose from(And they are all more or less wrong) 1: https://makewithtech.com/freecad-pre-releases-on-macos/ conda update --all conda create --name fcenv --channel conda-forge freecad(Condo-forge, is that pointing to GitHub: https://github.com/conda-forge/freecad-feedstock ? There is also https://github.com/FreeCAD/FreeCAD_Conda) Fails with "packages are not available" 2: https://vectronic.io/posts/building-freecad-on-macos-big-sur/ conda install python=3.10 conda install -c freecad/label/dev freecad -yFills with wrong Python version 3.10 3: https://wiki.freecadweb.org/Conda conda config --add channels conda-forge conda create --name fcenv-dev --channel freecad/label/dev freecad conda activate fcenv-dev conda update freecad freecad conda deactivateThis works great in creating an ARM64 binary with all dependencies, HTML views, and no script errors at startup. However, it does not create a Bundle, and it doesn't build from a local source tree. The Bundle seems to be created via CI here: https://github.com/FreeCAD/FreeCAD-Bundle , but we have to check if that runs locally without too many changes. CI calls "brew update" for macOS which we don't use if I see that correctly. The rest happens in "conda/osx-arm64/create_bundle.sh" which links back up the tree into other scripts. On to build the BundleWe will need the package manager "Mamba" to create the Bundle. conda activate base conda install mamba -n base -c conda-forge conda activate fcenv-devSo I clone the FreeCAD-Bundle repo (actually, I forked it and cloned my own version because I may want to create a Pull Request later). git clone https://github.com/MatthiasWM/FreeCAD-Bundle.git # Or git clone https://github.com/FreeCAD/FreeCAD-Bundle.git cd FreeCAD-Bundle/conda/osx-arm64 ./create_bundle.shAnd let it run for about 10 minutes (MacBook Pro M1), and without any further intervention, I actually get the disk image which contains a full and fresh version of FreeCAD. Wow! NOTE: the bundle is built in place and the icon files are renamed, so the bundle can not be built twice from the same FreeCAD-Bundle unless those files are restored: git restore APP/FreeCAD.app/Contents/Resources/freecad-doc.icns git restore APP/FreeCAD.app/Contents/Resources/freecad.icns git restore APP/FreeCAD.app/Contents/Resources/qt.confSo, um, we have solved the issue of getting a working macOS ARM64 Bundle. Now we need to find out how to build the bundle form a local source tree... . Late to the partyIt ssems that the whole Conda setup does not build from source, but instead just downloads binaries. It's possible though. Find the correct `meta.yaml` file and call `conda build` on that folder. conda install conda-build conda build -c conda-forge --debug --no-test /Users/matt/miniconda3/pkgs/freecad-0.21.pre-py310h69569d2_38/info/recipe/ # or whatever your path istAlso check out : /Users/matt/miniconda3/pkgs/freecad-0.21.pre-py310h69569d2_38/info/recipe/meta.yamlwhich may solve our issue with building from a local source tree, but it does not build our QuickLook plugin or the Bundle, so no real testing here either. BTW, if tthe command above fails with: CMake Error at cMake/FreeCAD_Helpers/SetupCoin3D.cmake:25 (file): file failed to open for reading (Not a directory): /Library/Frameworks/Inventor.framework/Inventor/C/basic.hThen a previous system-wide installation of Inventor is in the way. We can fix that temporarily by doing sudo mv /Library/Frameworks/Inventor.framework /Library/Frameworks/Inventor.framework.bak # don't forget to undoSo we do get the binary and a subfolder structure in `...conda.../fcenv-dev/pkgs/freecad-0.21.pre-py310h69569d2_38/bin/freecad, but it can't find python 3.10 or Qt. Sigh. |
Using Conda And MambaTrying to teach the package manager Mamba to use the local freecad archive instead of pulling it from GitHub, I created `/Users/matt/dev/FreeCAD/FreeCAD-Bundle/conda/osx-arm64/create_local_bundle.sh` which adds `-c /Users/matt/miniconda3/envs/fcenv-dev/conda-bld/osx-arm64/` as the first `-c` argument in `mambe create ...`. The good thing is, that we end up with a working package. If that was built using our local Conda setup still must be tested. In `/Users/matt/miniconda3/pkgs/freecad-0.21.pre-py310h69569d2_38/info/recipe/meta.yaml` in the `source: section, we comment out the lines for `url:` and `fn:` and add ` path: /Users/matt/dev/FreeCAD/FreeCAD` instead. We should now be able to build FC using the local source tree: conda build --no-test --debug --no-anaconda-upload /Users/matt/miniconda3/pkgs/freecad-0.21.pre-py310h69569d2_38/info/recipe/And YES, this works! I can build macOS Bundles from a local source tree! |
(c) 2021 messagepad@matthiasm.com - Impressum |