There is 2 way in which you can build the project:
- As a CloudCompare Plugin
- As "standalone" Python packages
When built as CloudCompare plugin, at the end of the process, you will have a standard CloudCompare plugin that embeds Python to allow running Python script directly in the app and allow scripts to interact with the currently running CloudCompare like a regular C++ plugin would. The plugin built, also embeds various Python bindings of CloudCompare's libraries to be used in your script.
When build as standalone packages, you will install the Python bindings of the CloudCompare's libraries in your Python environment.
The process to build is explained in the sections below.
Supported platforms: [Windows, Linux, macOS]
In the following sections we assume that you know how to compile CloudCompare from source, otherwise refer to the CloudCompare documentation on how to do.
To compile this plugin you need to have Python installed.
This plugin is known to compile and work with CloudCompare commit d17314ca8538e187bf12d4ebe97525d61886b735.
Python 3.9 or more is required to build as a plugin.
Clone this project into CloudCompare/plugins/private
Create a virtual environment via
venv
orconda
# Python's venv python -m venv .\pyccvenv # Conda environment conda create -n pyccenv
Activate the environment
# Python's venv (PowerShell) .\pyccenv\Scripts\Activate.ps1 # Conda environment conda activate pyccenv
install dependencies
pip install -r requirements-release.txt
Generate the cmake config
To generate the cmake config you have 2 options:
Start the cmake generation while still within the activated environment
Add
-DPYTHON_EXECUTABLE="somepath_to_python.exe"
Wheresomepath_to_python.exe
is the absolute path to the python executable of the pyccenv created earlier.To get it, run:
python -c "import sys;print(sys.executable)"
(while in the activated env)
In both cases the cmake option to add in order to build the plugin in
-DPLUGIN_PYTHON=ON
Build
Install
Clone this project in CloudCompare/plugins/private
Install additional dependencies
Ubuntu:
libpython3-dev
andpybind11-dev
(only available since 20.04)Fedora:
python3-devel
andpybind11-devel
Run cmake with
-DPLUGIN_PYTHON=ON
Build
Install
Clone this project in CloudCompare/plugins/private
Make sure you have python3 installed (and Qt)
Install additional dependencies
In this example, we will use brew
brew install pybind11
Run cmake with
-DPLUGIN_PYTHON=ON
Build
Install
Supported platforms: [Windows, Linux, macOS]
It is also possible to build and install the bindings as standard python packages to use them in python scripts (run by a standalone python executable and not the embedded python in the plugin).
To build as standalone wheels, it is not necessary to clone the repo in CloudCompare's plugins/private folder.
Important
To be able to pip install from source, you need pip version >= 21.1 Run pip install --upgrade pip to get the latest version
To do so:
- Clone this project
- Set path to Qt (Windows/macOS)
# Windows (PowerShell)
$env:CMAKE_PREFIX_PATH+=";C:\Qt\5.15.2\msvc2019_64"
macOS (bash)
export CMAKE_PREFIX_PATH=/usr/local/opt/qt@5
- Run
# Building the wheels
pip wheel --no-deps wrapper/cccorelib
pip wheel --no-deps wrapper/pycc
# Installing directly
pip install wrapper/cccorelib
pip install wrapper/pycc
Some CloudCompare plugins (the ones in C++) are available through python. And are compiled only if the corresponding C++ plugin is also being compiled.
Currently the only available "plugin wrapper" is one for qM3C2
plugin.
To compile this wrapper do:
Add -DPLUGIN_STANDARD_QM3C2=ON
to the cmake configuration.
Before the pip
command, add -DPLUGIN_STANDARD_QM3C2=ON
to the SKBUILD_CONFIGURE_OPTIONS
environment variable.
export SKBUILD_CONFIGURE_OPTIONS="-DPLUGIN_STANDARD_QM3C2=ON"
This section is only interesting for maintainers.
Tests works by running CloudCompare in command line mode. To run them, you need pytest, and you need to provide to pytest the path the where CloudCompare is installed
# in CloudCompare/plugins/private/CloudCompare-PythonPlugin: pytest --cloudcompare_exe "C:\CMakeBuilds\CloudCompare\Release\install\CloudCompare\CloudCompare.exe" tests
Building the documentation also works by running CloudCompare in command line mode. To build the documentation:
cd docs .\make-docs.ps1 "C:\CMakeBuilds\CloudCompare\Release\install\CloudCompare\CloudCompare.exe"
Which by default will build the docs in HTML in docs/_build. Open docs/_build/index.html to view it. (The output dir can be changed using the -OutputDir option)
Building the Windows installer requires the following:
- PowerShell Core (To run the creation script).
- Wix Toolset version 3.x (The actual toolset that creates the installer)
- Your custom built CloudCompare (with the Python Plugin) must have been installed. In other words the install target (
cmake --install .
) must have been done.
To create the installer, go in the installer
directory and start the ./Create-Installer.ps1
script
and give it as the first positional argument the absolute path to the directory where your custom built CC
was installed.
Example:
# in "installer" folder: ./Create-Installer "C:\CMakeBuilds\CloudCompare\Release\install\CloudCompare" # or pwsh ./Create-Installer "C:\CMakeBuilds\CloudCompare\Release\install\CloudCompare"
Note
A custom cmake target (that can be launched from your IDE or command line) is available in Release build to create the installer for you (it simply calls the script with the correct parameters).
cmake --build build_dir --target python_plugin_installer .