Skip to content

Running Cura from Source

[email protected] edited this page Jul 8, 2022 · 39 revisions

Running Cura from Source

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.

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.

System requirements

For the above workflow to actually work, the following system requirements must first be met.

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

Windows

  • Windows 10 or higher
  • Visual Studio with MSVC 2019 or higher
  • Python 3.6 or higher
  • CMake 3.20 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher

Executing from the Powershell is preferred.

macOS

  • macOS 10.15 or higher
  • xcode 11.4 or higher
  • apple-clang-9.0 or higher
  • Python 3.6 or higher
  • CMake 3.20 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher

Linux

  • Ubuntu/Debian/Arch/Manjaro (glibc 2.28 or higher)
  • gcc-9 or higher
  • Python 3.6 or higher
  • CMake 3.20 or higher
  • Ninja 1.10 or higher
  • Conan 1.48 or higher

Configuring Conan (All OSes)

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

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

conan remote remove cura

Initializing a Virtual Python Development Environment (All OSes)

Note: The way we handle versions will probably change in the future. For now it has to be explicitly set.

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.

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

if you have PyCharm as an IDE you can append the last command with -g PyCharmRunEnv this will create a run/debug configuration for PyCharm.

Use the Virtual Python Environment and run Cura from Source (All OSes)

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

Then execute the following command to start Cura.

python cura_app.py

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'

Cura and CuraEngine

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

workspace_root  
|  
└─ Cura  
└─ CuraEngine  

Setup 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

For CuraEngine start it as an external engine and debug/run it with the following command. Remember to also activate the environment before you do that.

FIXME: Expand this explaination.

# start Cura
python cura_app.py --external-engine
# open a model and press slice
# run CuraEngine
<path_to_root_of_curaengine>/cmake-build-release/CuraEngine 

For Uranium add it to the PYTHONPATH when you start the cura_app.py script. Remember to also activate the environment before you do that.

PYTHONPATH=<path_to_root_of_uranium>:$PYTHONPATH python cura_app.py
Clone this wiki locally