Installing Frida with pip is easy when a compatible wheel is available. But what happens when you need a custom build, a modified native extension, or a wheel for a specific platform?
In those situations, building Frida's Python package from source gives you more control over what gets installed.
The process is slightly different from building a regular Python package. Frida includes a native extension called _frida, which connects the Python API to Frida's underlying instrumentation engine. That extension must be built for the target platform and packaged alongside the Python modules.
There are two useful ways to approach this: let the frida-python repository build the extension for you, or supply an extension that you have already built separately.
What Actually Goes Into a Frida Python Wheel?
The frida Python package contains two important parts:
- Python modules that expose Frida's API.
- A compiled native extension named
_frida.
The native extension is essential. Without a compatible binary, the Python package cannot provide Frida's instrumentation functionality.
The frida-python repository handles this integration through its packaging configuration. Its setup.py defines the frida._frida extension and provides two build paths: one that builds the extension through the repository's Makefile and another that copies an existing compiled extension.
This distinction is important because building the Python wheel and compiling the native component are connected, but they are not necessarily the same operation.
Source: Frida Python repository.
1. Prepare the Build Environment
Frida's native build requires a C/C++ toolchain, Git, and Node.js 18 or newer. Python and pip are also needed for the packaging stage.
On Ubuntu, Frida's official build documentation lists these prerequisites:
sudo apt-get update
sudo apt-get install build-essential git \
lib32stdc++-9-dev libc6-dev-i386 nodejs npm
Check your Node.js version before continuing:
node --version
Make sure it is version 18 or newer. Some Linux distributions ship older Node.js versions, so you may need to install a newer version separately.
Now create an isolated Python environment:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
This keeps the packaging tools separate from your system Python installation.
The dependencies can differ across operating systems and target architectures, so use Frida's official build documentation when preparing a non-Ubuntu environment.
2. Get the Frida Python Source
Clone the official repository, including its submodules:
git clone --recurse-submodules https://github.com/frida/frida-python.git
cd frida-python
The repository includes dependencies such as releng and frida-bindgen, which are involved in its build process.
One detail worth knowing is that the Makefile already checks whether required submodules are available and initializes them when necessary. Cloning with --recurse-submodules is still a good starting point because it avoids missing source dependencies later.
For a reproducible build, use a reviewed commit or release revision rather than relying on whatever happens to be at the tip of the repository's development branch.
Remark: Keep the Python bindings and native Frida components from compatible source revisions. Mixing unrelated versions can produce a wheel that builds successfully but fails when imported or used.
3. Build the Wheel Directly From the Repository
For the normal source-build workflow, you do not need to manually locate _frida and pass its path.
From the root of frida-python, run:
python -m pip wheel . --no-deps --wheel-dir dist
This asks pip to build a wheel from the current project and place the resulting package in dist.
Here is what happens behind the scenes.
The project's setup.py registers a custom build extension command. When no existing extension is supplied through FRIDA_EXTENSION, it invokes the repository's Makefile.
The Makefile delegates the work to Frida's Meson-based build tooling, using ./build as the build directory. After the native extension is generated, the packaging script finds the resulting _frida binary and copies it into the Python package.
It also includes generated files required by the bindings:
__init__.pyaio.py_frida.pyi
The resulting wheel contains the Python modules and the compiled extension together.
This is the simplest workflow when you want the repository to build and package its own native extension.
Source: frida-python setup.py and Makefile.
4. Package an Existing Custom Native Extension
Sometimes you already have a compiled Frida extension. Perhaps you modified the native source code, used a custom build configuration, or generated the binary through a separate Frida build.
In that situation, compiling the extension again during Python packaging is unnecessary.
The frida-python setup script supports an environment variable named FRIDA_EXTENSION. It tells the packaging process to use an existing native binary instead of invoking the normal native build.
For example, on Linux:
export FRIDA_VERSION="17.x.y"
export FRIDA_EXTENSION="/absolute/path/to/_frida.so"
python -m pip wheel . --no-deps --wheel-dir dist
Replace 17.x.y with the actual version of your custom Frida build.
On Windows, the native extension generally uses the .pyd extension:
C:\path\to\_frida.pyd
The important detail is that the directory containing the supplied extension must also contain the generated Python files expected by the packaging script: __init__.py, aio.py, and _frida.pyi.
When FRIDA_EXTENSION is provided, setup.py copies the native binary and those generated files into the wheel. It does not compile the supplied binary again.
What Does FRIDA_VERSION Do?
The package also supports FRIDA_VERSION, which controls the version metadata assigned to the generated distribution when version detection falls through to that environment variable.
The setup script checks for a source package's PKG-INFO first. Otherwise, it checks FRIDA_VERSION, followed by Frida's version-detection tooling in releng.
This means an existing PKG-INFO can take precedence over the environment variable.
Use a version that corresponds to the native extension you are packaging. Giving a custom binary an unrelated package version can make dependency management and debugging confusing.
Remark: FRIDA_EXTENSION supplies an already-built extension; it does not tell Frida how to compile modified native source code. The native build must be completed separately before using this packaging workflow.
The project's README demonstrates this process with a Windows development build and a .pyd extension.
Source: Official Frida Python README.
5. Check the Generated Wheel
After the build finishes, inspect the output directory:
ls dist/
You should find a wheel with a name similar to:
frida-17.x.y-cp34-abi3-linux_x86_64.whl
The exact filename depends on the version, packaging configuration, and target platform.
The abi3 part indicates use of Python's limited ABI. Frida's setup configuration declares py_limited_api=True, and its README demonstrates an abi3 wheel.
However, this does not make the wheel universally portable. The native extension still needs to match the operating system and CPU architecture.
For example, a Linux x86-64 wheel cannot simply be installed on Windows ARM64 by changing its filename.
Install the wheel in a clean virtual environment on the intended target:
python -m pip install --force-reinstall dist/frida-*.whl
Then check whether both the Python package and native extension can be imported:
python -c "import frida; from frida import _frida; print(frida.__file__); print(_frida.__file__)"
If the imports succeed, Python has found the package and its native extension.
For a stronger check, run a small Frida operation in an environment where Frida can access a compatible target process or device.
6. Common Problems During the Build
A wheel can fail during compilation, or it can build successfully and still fail when installed. The error message usually gives a useful clue.
Missing submodules or releng files
If Meson or the build scripts cannot find Frida's build tooling, inspect the submodules:
git submodule update --init --recursive
Then rerun the build.
Node.js version is too old
Frida's documented build requirements specify Node.js 18 or newer. Check node --version and update the toolchain if necessary.
The custom extension cannot be found
Check the full path supplied through FRIDA_EXTENSION. It must point to the actual _frida binary, not to a directory or an unrelated Frida library.
Also verify that the generated Python files are present alongside it.
Wheel installs but importing Frida fails
This often points to a binary compatibility problem. Check the target operating system, CPU architecture, Python compatibility, and native dependencies. A successful packaging step does not prove that the binary can run on the destination machine.
The wheel has an unexpected version
Inspect PKG-INFO and the value detected by Frida's build tooling. Remember that an existing PKG-INFO takes precedence over FRIDA_VERSION.
The build produces no native extension
Check the earliest Meson or compiler error in the build output. The final packaging error may only be reporting that _frida was never generated.
Conclusion
Building a custom Frida Python wheel is mainly about bringing the native _frida extension and the Python bindings together correctly.
For a normal build, the frida-python repository can invoke its Makefile and Meson tooling to generate the extension before packaging it. When you already have a custom native binary, FRIDA_EXTENSION allows you to package it without compiling it again.
The details that deserve the most attention are source-version matching, generated package files, and platform compatibility. A wheel that builds successfully is not necessarily a wheel that will work on every machine.
Once those pieces are aligned, creating a custom Frida Python wheel becomes a straightforward part of a repeatable native build process.



