Installing CLDK
CLDK is a Python SDK on PyPI. You can install it with any Python package manager.
Installation
Section titled “Installation”pip install cldkpoetry add cldkuv add cldkLanguage-specific dependencies
Section titled “Language-specific dependencies”CLDK analyzes several languages. Each language needs its own dependencies:
The CLDK Python SDK and Python analysis both need Python 3.11 or later. pyenv installs and manages several Python versions on one machine.
For Java analysis, CLDK uses a companion backend, codeanalyzer-java. In CLDK 2.0, install it as an extra: pip install --pre "cldk[java]". The backend carries its own JVM. To build the target project with Maven, you need the Java Development Kit (JDK), version 11 or later.
SDKMAN installs and manages JDK versions.
-
Install SDKMAN with this command:
Terminal window curl -s "https://get.sdkman.io" | bash -
Open a new terminal, or load the SDKMAN scripts:
Terminal window source "$HOME/.sdkman/bin/sdkman-init.sh"
Next, install Java 11 or later with SDKMAN:
-
List the available Java versions:
Terminal window sdk list java | grep semThe output looks like this:
Terminal window Semeru | | 21.0.5 | sem | | 21.0.5-sem| | 17.0.13 | sem | | 17.0.13-sem| | 11.0.25 | sem | | 11.0.25-sem| | 8.0.432 | sem | | 8.0.432-sem -
Install Java 11 or later. This example uses
11.0.25-sem:Terminal window sdk install java 11.0.25-sem -
Set Java 11 as the current (or default) Java version:
Terminal window sdk use java 11.0.25-sem# If want to default to java 11 for all sessions, use the following command instead:# sdk default java 11.0.25-sem -
Make sure that the installation works:
Terminal window java -versionThe command shows the installed Java version.
Terminal window openjdk 11.0.25 2024-10-15IBM Semeru Runtime Open Edition 11.0.25.0 (build 11.0.25+9)Eclipse OpenJ9 VM 11.0.25.0 (build openj9-0.48.0, JRE 11 Linux amd64-64-Bit Compressed References 20241107_1233 (JIT enabled, AOT enabled)OpenJ9 - 1d5831436eOMR - d10a4d553JCL - edded3f65c based on jdk-11.0.25+9)
Finally, for call graphs and deeper levels, the Java backend builds your project automatically with Maven or Gradle. For a Maven project, install Maven with SDKMAN:
-
Install Maven:
Terminal window sdk install maven -
The
mvncommand must be on yourPATH. If it is not, add this line to your~/.zshrc,~/.bashrc, or~/.bash_profilefile:Terminal window export PATH="$HOME/.sdkman/candidates/maven/current/bin:$PATH"Then load the file again:
Terminal window source ~/.zshrc # or ~/.bashrc or ~/.bash_profile -
Make sure that the installation works:
Terminal window mvn -versionThe command shows the installed Maven version.
For TypeScript and JavaScript analysis, CLDK uses a companion backend, codeanalyzer-ts. The prebuilt binary itself needs no Bun or Node. To install the dependencies of your project, the backend needs npm, which ships with Node. The cldk package installs codeanalyzer-typescript at the version that CLDK pins, so the SDK needs no separate install. The package adds a cants command to your PATH. To install only the command, use PyPI or Homebrew.
Install it from PyPI:
pip install codeanalyzer-typescriptOr with Homebrew:
brew install codellm-devkit/homebrew-tap/codeanalyzer-typescriptMake sure that the installation works:
cants --helpThe package is named codeanalyzer-typescript, but the command is cants. To resolve library call targets, the backend needs the dependencies of the project. If npm is on your PATH, the backend creates node_modules for you. To skip this step, use --no-build. For the full list of CLI options, see the codeanalyzer-ts backend reference.
For infrastructure-as-code analysis, the companion backend is codeanalyzer-iac. Its command is caniac. It ships as a prebuilt binary and needs no Helm CLI.
Install it from PyPI:
pip install codeanalyzer-iacOr with Homebrew:
brew install codellm-devkit/tap/codeanalyzer-iacMake sure that the installation works:
caniac --helpThere is no CLDK.iac(...) factory yet. Run caniac as a command, or read the Neo4j graph that it writes. For the analysis levels and output modes, see the codeanalyzer-iac backend reference.
CLDK does not analyze Rust yet. You need a Rust toolchain only to contribute Rust code, for example the Rust frontend. Use rustup to install Rust and manage toolchains. rustup keeps Rust versions separate, and you can change between them.
- Install rustup. Run this command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThen follow the instructions on screen.
- Configure your environment. Add this line to your shell init script:
source $HOME/.cargo/env- Make sure that the installation works. Show the version:
rustc --versionThe output looks like this. The version number can be different:
rustc 1.70.0 (90c541806 2023-05-31)Additional development tools
Section titled “Additional development tools”If you build Python from source, for example with pyenv, some operating systems need additional development tools:
-
Install the Xcode Command Line Tools:
Terminal window xcode-select --install -
Some builds also need these Homebrew packages:
Terminal window brew install openssl readline sqlite3 xz zlib tcl-tk libffi
-
Install the build tools:
Terminal window sudo apt-get install build-essential python3-dev libssl-dev zlib1g-dev \libbz2-dev libreadline-dev libsqlite3-dev curl git \libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
-
Install the build tools:
Terminal window sudo dnf group install c-development development-tools gcc make \patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel\openssl-devel tk-devel libffi-devel xz-devel
Supported Python versions
Section titled “Supported Python versions”CLDK needs Python 3.11 or later:
| Python Version | Compatible cldk Versions |
|---|---|
| 3.11 | ≥0.4.0 |