.. _My target: Mac - OSX ========= In order to compile entire CC3D code on Mac (not just the developer zone) you need to install OSX core developer tools: .. code-block:: console xcode-select --install For CompuCell3D development we also need miniconda installation - please follow instructions from Miniconda website: https://docs.anaconda.com/free/miniconda/ Next let's install ``mamba`` which give you much faster package dependency resolution. Open new terminal and tun the following: .. code-block:: console conda install -c conda-forge mamba .. note:: We will use ``~`` to denote home directory. This is standard Linux/Unix/OSX convention On my computer miniconda is installed to ``~/miniconda_arm64`` folder. It is likely that on yours it will be a different folder so please make a note of this because later we will need the location of the miniconda to configure compilation of CompuCell3D Once you have those tools you are ready to create conda environment into which we will install all the libraries and compilers that are needed for CC3D compilation. There are multiple ways to handle the installation of those prerequisites but the easiest one is to use ``environment.yaml`` files where we list all needed packages and provide this file to conda which takes care of installing them. .. note:: From now on I will assume that all git repositories and files have been saved to ``~/src-cc3d``, that is to ``src-cc3d`` folder placed inside your home directory (``~``) First, let's clone CompuCell3D, cc3d-player5 and cc3d-twedit5 git repositories to ``!/src-cc3d`` .. code-block:: console mkdir -p ~/src-cc3d cd ~/src-cc3d git clone https://github.com/CompuCell3D/CompuCell3D.git git clone https://github.com/CompuCell3D/cc3d-player5.git git clone https://github.com/CompuCell3D/cc3d-twedit5.git Next, let's create file ``~/src-cc3d/environment.yaml`` with the following content: .. code-block:: yaml channels: - conda-forge - compucell3d dependencies: # compile dependencies - cmake=3.21 - swig>=4 - numpy=2.2.6 - clang_osx-arm64 - clangxx_osx-arm64 - llvm-openmp - python=3.12 - vtk=9.2 - eigen>=3.4,<3.5 - tbb-devel=2021 - boost=1.85 - psutil - deprecated - cc3d-network-solvers>=0.3.1 # cc3d run dependencies - simservice - notebook - ipywidgets - ipyvtklink - sphinx - graphviz - scipy - pandas - jinja2 - lxml # player dependencies - webcolors - requests - pyqt=5 - pyqtgraph # twedit dependencies - chardet - pyqtwebkit - qscintilla2 - sphinx - pywin32 # [win] .. note:: To generate this environment.yaml file it is best to to start the conda build process of cc3d package and navigate to the ``work`` folder within conda-bld directory and then copy all packages from the ``metadata_conda_debug.yaml`` file e.g. in my case the file I used was ``~/miniconda3_arm64/conda-bld/cc3d_1711231453909/work/metadata_conda_debug.yaml``. The important thing is to copy this file away from this folder while the conda build still runs (otherwise after successful build this file will disappear) and to remove duplicates from the package list. We also added few packages that Player and Twedit++ use. They are not necessary to compile CompuCell3D but they will be useful later when we will run CompuCell3D via ``cc3d-player`` Once we created ``environment.yaml`` let's ``cd`` to ``~/src-cc3d`` and create environment called ``cc3d_compile`` by running the following command: .. code-block:: console cd ~/src-cc3d mamba env create -f environment.yaml --name cc3d_compile The output of of the last command should look something like this .. code-block:: console + yarl 1.9.4 py310hd125d64_0 conda-forge/osx-arm64 Cached + zeromq 4.3.5 hebf3989_1 conda-forge/osx-arm64 Cached + zipp 3.17.0 pyhd8ed1ab_0 conda-forge/noarch Cached + zlib 1.2.13 h53f4e23_5 conda-forge/osx-arm64 Cached + zstd 1.5.5 h4f39d0f_0 conda-forge/osx-arm64 Cached Summary: Install: 337 packages Total download: 0 B Downloading and Extracting Packages Preparing transaction: done Verifying transaction: done Executing transaction: \ / done # # To activate this environment, use # # $ conda activate cc3d_compile # # To deactivate an active environment, use # # $ conda deactivate After environment in installed let's activate this environment - as suggested but above printout by running: .. code-block:: console conda activate cc3d_compile At this point we are ready to configure CompuCell3D for compilation. We will be using CMake. Let's run the following command: .. code-block:: console cmake -S ~/src-cc3d/CompuCell3D/CompuCell3D -B ~/src-cc3d/CompuCell3D_build -DPython3_EXECUTABLE=$CONDA_PREFIX/bin/python -DNO_OPENCL=ON -DBUILD_STANDALONE=OFF -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=~/src-cc3d/CompuCell3D_install Let's explain command line arguments we used when calling ``cmake`` command ``-S`` - specifies location of the CompUCdl3D source code and the actual C++ code resides indeed in ``~/src-cc3d/CompuCell3D/CompuCell3D`` ``-B`` specifies the location of the temporary compilation files ``-DPython3_EXECUTABLE=`` specifies the location of the python interpreter. Notice that it points to the conda environment we creates (``/envs/cc3d_compile/bin/python``). **Important:** We used ``$CONDA_PREFIX`` env var to point to the conda environment we have just activated. In my case it points to ``/Users/m/miniconda3_arm64/envs/cc3d_compile``. In your case it will be different but ouu can always check by executing ``echo $CONDA_PREFIX`` from the terminal where you activate ``cc3d_compile`` environment ``-DNO_OPENCL=ON `` - is a CC3D-specific setting that tells cmake to skip generating GPU diffusion solvers. Note, the support for OpenCL on OSX is/might be problematic, hence we are using morte conservative setting and skip generation of those solvers ``-DBUILD_STANDALONE=OFF`` - is a CC3D-specific setting that tells cmake to install all python packages to python interpreter directory - i.e. inside ``$CONDA_PREFIX`` (e.g. ``/Users/m/miniconda3_arm64/envs/cc3d_compile``) ``-DCMAKE_INSTALL_PREFIX=`` specifies location of installed CompuCell3D binaries ``-G "Unix Makefiles"`` instructs cmake to generate unix Makefiles that we will use for compilation of CompuCell3D After running the las t command the output should look as follows: .. code-block:: console ... -- Found Freetype: /Users/m/miniconda3_arm64/envs/cc3d_compile/lib/libfreetype.dylib (found version "2.12.1") VTK_MAJOR_VERSION=9 NUMPY_INCLUDE_DIR VTK_LIB_DIRS THIS IS cc3d_py_source_dir: /Users/m/src-cc3d/CompuCell3D/CompuCell3D/../cc3d USING BUNDLE -- Configuring done CMake Warning (dev) at compucell3d_cmake_macros.cmake:200 (ADD_LIBRARY): Policy CMP0115 is not set: Source file extensions must be explicit. Run "cmake --help-policy CMP0115" for policy details. Use the cmake_policy command to set the policy and suppress this warning. File: /Users/m/src-cc3d/CompuCell3D/CompuCell3D/core/CompuCell3D/steppables/PDESolvers/hpppdesolvers.h Call Stack (most recent call first): core/CompuCell3D/steppables/PDESolvers/CMakeLists.txt:187 (ADD_COMPUCELL3D_STEPPABLE) This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /Users/m/src-cc3d/CompuCell3D_build (cc3d_compile) m@Maciejs-MacBook-Pro src-cc3d % At this point we are ready to compile CC3D: .. code-block:: console cd ~/src-cc3d/CompuCell3D_build make -j 8 We are changing to the "build directory" where or cmake, Makefile, and transient compilation files are stored and we are running ``make`` command with 8 parallel compilation threads to speed up the compilation process. The successful compilation printout should look something like that: .. code-block:: console [ 99%] Linking CXX shared module _PlayerPython.so [ 99%] Built target PlayerPythonNew 16 warnings generated. [100%] Linking CXX shared module _CompuCell.so [100%] Built target CompuCell After the compilation is done we will call ```make install` .. code-block:: console make install The installed files will be placed in ``~/src-cc3d/CompuCell3D_install`` , exactly as we specified in the ``cmake`` command - ``-DCMAKE_INSTALL_PREFIX=~/src-cc3d/CompuCell3D_install`` Assuming we are still in cc3d_compile conda environment (run ``conda activate cc3d_compile`` if you opened new terminal) we can run our first simulation using newly compiled CompuCell3D. We will run it without the player first and next we will show you how to get player and twedit++ working. .. code-block:: python -m cc3d.run_script -i ~/src-cc3d/CompuCell3D/CompuCell3D/core/Demos/Models/cellsort/cellsort_2D/cellsort_2D.cc3d .. note:: First time you execute run command on OSX it takes a while to load all the libraries. Subsequent runs start much faster The output of the run should look something like this .. code-block:: console (cc3d_compile) m@Maciejs-MacBook-Pro CompuCell3D_build % python -m cc3d.run_script -i ~/src-cc3d/CompuCell3D/CompuCell3D/core/Demos/Models/cellsort/cellsort_2D/cellsort_2D.cc3d ################################################# # CompuCell3D Version: 4.5.0 Revision: 2 Commit Label: f8ddda9 ################################################# Random number generator: MersenneTwister WILL RUN SIMULATION FROM BEGINNING CALLING FINISH ------------------PERFORMANCE REPORT:---------------------- ----------------------------------------------------------- TOTAL RUNTIME 9 s : 639 ms = 9.639 s ----------------------------------------------------------- ----------------------------------------------------------- PYTHON STEPPABLE RUNTIMES cellsort_2DSteppable: 0.01 ( 0.1%) ----------------------------------------------------------- Total Steppable Time: 0.01 ( 0.1%) Compiled Code (C++) Run Time: 9.54 (99.0%) Other Time: 0.08 ( 0.9%) ----------------------------------------------------------- Installing Player and Twedit++ into the compiled environment ------------------------------------------------------------ After successful compilation and ``make install``, the newly compiled CompuCell3D Python package is installed into the active conda environment. To run the Player and Twedit++ from the same environment, we need to make the ``cc3d-player5`` and ``cc3d-twedit5`` repositories available inside that environment's ``site-packages/cc3d`` folder. Make sure you are still in the ``cc3d_compile`` environment: .. code-block:: console conda activate cc3d_compile On macOS with conda, ``site-packages`` is typically located under ``$CONDA_PREFIX/lib/python3.12/site-packages``. To avoid hard-coding the Python version or the exact Miniconda/Miniforge installation path, we can ask Python where ``site-packages`` is located: .. code-block:: console SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])") The easiest development setup is to create symbolic links from your cloned repositories into the compiled environment: .. code-block:: console ln -s ~/src-cc3d/cc3d-player5/cc3d/player5 "$SITE_PACKAGES/cc3d/player5" ln -s ~/src-cc3d/cc3d-twedit5/cc3d/twedit5 "$SITE_PACKAGES/cc3d/twedit5" If you prefer a copied installation instead of symbolic links, use: .. code-block:: console cp -R ~/src-cc3d/cc3d-player5/cc3d/player5 "$SITE_PACKAGES/cc3d/player5" cp -R ~/src-cc3d/cc3d-twedit5/cc3d/twedit5 "$SITE_PACKAGES/cc3d/twedit5" After this step you can run Player or Twedit++ using the newly compiled CompuCell3D binaries: .. code-block:: console python -m cc3d.player5 python -m cc3d.twedit5 In Player, use ``File->Open...`` to select a ``.cc3d`` project, for example ``~/src-cc3d/CompuCell3D/CompuCell3D/core/Demos/Models/cellsort/cellsort_2D/cellsort_2D.cc3d``.