Skip to content

Running Cura from Source

Joey de l'Arago edited this page Aug 17, 2022 · 39 revisions

Note: We're currently still in the process of updating our workflow how to run Cura from source. Although most of the workflow has been determined already, there are bound to be some changes along the way. If you run into any issues, please feel free to to open an issue on our Cura repository.

System requirements

Make sure that the binaries for the system dependencies can be found on the PATH

Windows

  • Windows 10 or higher
  • Visual Studio with MSVC 2022 or higher
  • Python 3.6 or higher
  • venv
  • CMake 3.23 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher

Executing from the Powershell is preferred.

macOS

For M1 Mac users you must follow the build instructions using a Rossetta terminal

We recommend using brew to install these dependencies.

  • macOS 10.15 or higher
  • xcode 11.4 or higher
  • apple-clang-9.0 or higher
  • Python 3.6 or higher
  • venv
  • altool
  • automake
  • CMake 3.23 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher

Linux

  • Ubuntu/Debian/Arch/Manjaro (glibc 2.28 or higher)
  • gcc-12 or higher
  • Python 3.6 or higher
  • venv
  • CMake 3.23 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher
  • autoreconf

Installation

1. Configure Conan

pip install conan --upgrade
conan config install https://github.com/ultimaker/conan-config.git
conan profile new default --detect --force

Community developers would have to remove the Conan cura repository because it requires credentials.

Ultimaker developers need to request an account for our JFrog Artifactory server at IT

conan remote remove cura

2. Clone Cura

Clone Cura and enter the Cura root directory.

git clone https://github.com/Ultimaker/Cura.git 
cd Cura

3. Initialize the Virtual Python Development Environment

Install the dependencies for the development environment and initialize a virtual Python environment. Execute the following command in the root directory of the Cura repository.

# optional for a specific version: conan install . cura/<version>@<user>/<channel> --build=missing --update
conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv

If you use PyCharm, append -g PyCharmRunEnv. This will create a run/debug/test configurations. You must click Add Configuration..., and click Apply for these to be displayed.

4. Activate the Virtual Python Environment

Activate the virtual environment by executing the following command in the root directory of the Cura repository.

# For Linux/MacOS
source venv/bin/activate
# For Windows (Powershell)
.\venv\Scripts\activate.ps1

5. Run Cura

python cura_app.py

Process description and workflow

Note: Most notable changes compared to the previous workflow is the deprecation of cura-build and cura-build-environment.

Cura consists of a Python module in this repository and multiple other dependencies (C++, C++ Python bindings, Python modules) either owned by Ultimaker or third-parties. Ultimaker owned repositories which are party of Cura will be build or exported with a GitHub Action on a certain repository events, such as a push to a branch. These exported packages and/or binaries can then be used by other repositories when required. This workflow greatly reduces complexity, maintenance and build time. The figure below shows the sequence diagram for an individual repository.

push-build

C++ and C++ Python binding dependencies are now managed by Conan, while the Python modules are managed by Pip. Conan is the orchestrator for the complete installation and setting up the development environment. All dependencies are build, stored and used in such away that interaction and 'pollution' of the global system should be non-existing. Installing dependencies for Cura and initializing a Virtual Python environment should be as simple as executing a single command in the end.

Cross dependency development (All OSes)

Note: This is a work in progress and largely untested at the moment.

When you're working on Cura it could be needed to work on other repositories such as Uranium and/or CuraEngine in parallel. Conan allows you to put a package into editable mode Instead of pointing to a Conan package in the local Conan cache it will point to the working directory of the other repository.

You can find out which version of a package is used by Cura by examining the conandata.yml file in the root directory of the Cura repository. The specific data, including the version of a requirment is stored per version key, e.q.: cura/5.1.0-beta+1234 will use curaengine/latest@ultimaker/stable

Make sure Cura and her dependencies are cloned locally and are located in the same workspace directory.

workspace_root  
|  
└─ Cura  
└─ CuraEngine  
└─ Uranium  
└─ libSavitar  
└─ libArcus  
└─ libNest2D  
└─ pynest2d  

You can put a dependency, such as CuraEngine into editable mode by executing the following command in the root directory of the CuraEngine

conan editable add . curaengine/latest@ultimaker/stable

If you then perform a new conan install command as usual (See: Initializing a Virtual Python Development Environment (All OSes)) the correct paths should be set for the CuraEngine dependency, and you should be able to develop for Cura and CuraEngine simultaneously.

Hybrid old/new cross dependency development (All OSes)

Since the above described methods isn't fully tested yet you can also set things up the 'old fashion method'. Keep in mind that the following steps are workarounds and intended as a temporary solution. At least until we have implemented to full cross dependency development method. as described above.

Cura and CuraEngine

Make sure Cura and CuraEngine are both cloned locally and are located in the same directory.

workspace_root  
|  
└─ Cura  
└─ CuraEngine  

Set up the development environment by executing the following command in the root directory of the Cura repository.

conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv

Do the same for CuraEngine, by executing the following command in the root directory of the CuraEngine repository.

conan install . --build=missing --update

If you want to run CuraEngine in debug mode you can append the last command with -s build_type=Debug, this will create the debug configuration for CuraEngine.

The CMake configuration and the binaries will be build in cmake-build-release or cmake-build-debug you can build CuraEngine by executing the following command in the build directory of the CuraEngine repository.

cmake --toolchain=conan/conan_toolchain.cmake ..

and build it with

cmake --build .

If you start up Cura (make sure you have activated the Virtual Python Environment) with the following command.

# For Linux/MacOS
source venv/bin/activate
python cura_app.py --external-backend
# For Windows (Powershell)
.\venv\Scripts\activate.ps1
python cura_app.py --external-backend

You can try to slice a model. While Cura waits till CuraEngine connects to the process. Run CuraEngine (from the CuraEngine build folder) with the following command or from the IDE. Make sure you add the connect 127.0.0.1:49674 as an argument to the run/debug configuration

# For Linux/MacOS
./CuraEngine connect 127.0.0.1:49674
# For Windows (Powershell)
.\CuraEngine\CuraEngine.exe connect 127.0.0.1:49674

Cura and Uranium

Make sure Cura and Uranium are both cloned locally and are located in the same directory.

workspace_root  
|  
└─ Cura  
└─ Uranium  

Set up the development environment by executing the following command in the root directory of the Cura repository.

conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv

Do the same for Uranium, by executing the following command in the root directory of the Uranium repository.

conan install . --build=missing --update

Because the previous conan install command for also installed Uranium in the site-packages folder of the Cura virtual environment. You will first have to remove that. Do so by activating the virtual Python environment in Cura and executing the following command.

# For Linux/MacOS
source venv/bin/activate
pip uninstall Uranium
# For Windows (Powershell)
source venv/bin/activate
pip uninstall Uranium

You can now start Cura with the Uranium (from source) dependency by prepending the root of Uranium to the PYTHONPATH environment variable.

# For Linux/MacOS
export PYTHONPATH=<path_to_root_of_uranium>:$PYTHONPATH
python cura_app.py
# For Windows (Powershell)
$Env:PYTHONPATH=<path_to_root_of_uranium>;$Env:PYTHONPATH
python cura_app.py
Clone this wiki locally