Building from Source
This page explains how to build PythonSCAD from source code on various platforms.
Linux
Install Dependencies
PythonSCAD provides a script that automatically installs all required build dependencies for most Linux distributions (Debian, Ubuntu, Fedora, Arch, openSUSE, and others):
To see what the script would do without actually installing anything, use:
Build
Once dependencies are installed, configure and build with CMake:
Run
After a successful build, run the application:
CMake Options
You can customize the build by passing options to CMake
with the -D flag:
| Option | Default | Description |
|---|---|---|
ENABLE_TESTS |
ON | Enable the test suite |
HEADLESS |
OFF | Build without GUI (for servers/CI) |
EXPERIMENTAL |
ON | Enable experimental features |
ENABLE_PYTHON |
ON | Enable Python support |
USE_QT6 |
OFF | Use Qt6 instead of Qt5 |
ENABLE_CGAL |
ON | Enable CGAL geometry backend |
ENABLE_MANIFOLD |
ON | Enable Manifold geometry backend |
Example with custom options:
Windows
Option 1: MSYS2 (Recommended)
MSYS2 provides a Unix-like build environment on Windows with all required dependencies available as packages.
Install MSYS2
Download and install MSYS2 from msys2.org. Then open an MSYS2 UCRT64 terminal.
Install MSYS2 Dependencies
From the repository root inside the MSYS2 terminal:
Build with MSYS2
mkdir build && cd build
cmake .. -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DUSE_QT6=ON
cmake --build . -j$(nproc)
Option 2: Visual Studio + vcpkg
Visual Studio Prerequisites
-
Git: Install Git and ensure it's in your PATH. Follow the installation instructions.
-
Visual Studio 2022: Install Visual Studio 2022 with the "Desktop development with C++" workload selected.
-
WinFlexBison: Download binaries from the WinFlexBison GitHub page, extract them somewhere convenient, and add that location to your PATH.
-
vcpkg: Install vcpkg in a location with a short path (e.g.,
C:\vcpkgorD:\vcpkg): -
Environment variables: Add vcpkg to your PATH and set
VCPKG_ROOT:
Build with Visual Studio
Clone the repository and run the build script:
The build script will:
- Install all required packages through vcpkg
- Generate Visual Studio project files in the
builddirectory - Build Release and Debug versions
Build outputs will be in build\Debug and build\Release.
Troubleshooting
If you encounter issues installing vcpkg packages, try manually installing them:
macOS
Option 1: Homebrew (Recommended)
The easiest way to build on macOS is using Homebrew.
Install Homebrew Dependencies
Run the provided script from the repository root:
This installs all required dependencies via Homebrew, including Qt6 by default. For Qt5 instead, run:
Build on macOS
Option 2: Build Dependencies from Source
For more control or if Homebrew is not available:
Then build as described above.
Running Tests
After building, you can run the test suite from the build directory:
# Run all default tests with parallel jobs
ctest -j8
# Run tests matching a pattern
ctest -R <pattern>
# Run all tests including heavy ones
ctest -C All
Development Setup
Code Formatting
PythonSCAD uses clang-format for consistent code style.
Format your changes before committing:
Pre-commit Hooks
Install pre-commit hooks to automatically check code before commits:
If you encounter problems building, please create an issue on our GitHub page.